Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: e2e: add agent test using tool (#426) #442

Merged
merged 2 commits into from
Feb 28, 2025

Conversation

aabchoo
Copy link
Contributor

@aabchoo aabchoo commented Feb 28, 2025

Commit Message

  • adding e2e test making sure that we can use a tool and return the proper response from the LLM

This PR also contains a few fixes that allow this test to work

  • added validateToolCallID as its needed for the bedrock message or it fails
  • Validate and cast the openai content value into bedrock content block
  • before we assumed it was always a string but it can also be an array
  • Merge the content blocks if one has text and the other has toolcall but no text - bedrockResp.Output.Message.Content is not 1:1 with openai choice.Message.Content.. we get the result in chunks that should be merged, for example the text and it's toolconfig were in seperate elements but openai expects them to be in the same
  • in openAIMessageToBedrockMessageRoleAssistant we assume that either there is a refusal or a content text, but we actually dont pass in a text. this was causing an error as the length of the array was set to 1 so the first was empty and there must be a key specified in each content element.

note: i think this is another bug that im trying to look into/create unit test for, but since there is already a lot in this PR, maybe its best to follow up with that one the next one. basically, the assistant openai param message's content doesn't seem to be translating to this method, and we have no content. this doesn't prevent anything else from working though, we are just missing a text field like {"content":[{"text":"Certainly! I can help you get the weather information for New York City. To do that, I'll use the available weather tool. Let me fetch that information for you right away."}

the rests are tests

**Commit Message**

* adding e2e test making sure that we can use a tool and return the
proper response from the LLM

This PR also contains a few fixes that allow this test to work 
* added validateToolCallID as its needed for the bedrock message or it
fails
* Validate and cast the openai content value into bedrock content block
- before we assumed it was always a string but it can also be an array
* Merge the content blocks if one has text and the other has toolcall
but no text - bedrockResp.Output.Message.Content is not 1:1 with openai
choice.Message.Content.. we get the result in chunks that should be
merged, for example the text and it's toolconfig were in seperate
elements but openai expects them to be in the same
* in openAIMessageToBedrockMessageRoleAssistant we assume that either
there is a refusal or a content text, but we actually dont pass in a
text. this was causing an error as the length of the array was set to 1
so the first was empty and there must be a key specified in each content
element.

note: i think this is another bug that im trying to look into/create
unit test for, but since there is already a lot in this PR, maybe its
best to follow up with that one the next one. basically, the assistant
openai param message's content doesn't seem to be translating to this
method, and we have no content. this doesn't prevent anything else from
working though, we are just missing a text field like
`{"content":[{"text":"Certainly! I can help you get the weather
information for New York City. To do that, I'll use the available
weather tool. Let me fetch that information for you right away."}`

the rests are tests

---------

Signed-off-by: Alexa Griffith <agriffith96@gmail.com>
Signed-off-by: Alexa Griffith  <agriffith96@gmail.com>
Signed-off-by: Dan Sun <dsun20@bloomberg.net>
Co-authored-by: Dan Sun <dsun20@bloomberg.net>
@aabchoo
Copy link
Contributor Author

aabchoo commented Feb 28, 2025

Backporting commit into release branch

@aabchoo aabchoo changed the base branch from main to release/v0.1 February 28, 2025 17:44
@aabchoo aabchoo changed the title e2e: add agent test using tool (#426) backport: e2e: add agent test using tool (#426) Feb 28, 2025
**Commit Message**

This allows `backport` to be used as a commit title / PR title prefix.

**Related Issues/PRs (if applicable)**

Related to #437

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake
Copy link
Member

mathetake commented Feb 28, 2025

hehe yeah i think we needed the title into the base release/v0.1 (PR targer)... let's ignore the title check for now - should be no problem. But backporting the title check here anyways make sense

@aabchoo aabchoo marked this pull request as ready for review February 28, 2025 17:58
@aabchoo aabchoo requested a review from a team as a code owner February 28, 2025 17:58
@mathetake mathetake enabled auto-merge (squash) February 28, 2025 18:00
@mathetake mathetake disabled auto-merge February 28, 2025 18:00
@mathetake mathetake changed the title backport: e2e: add agent test using tool (#426) e2e: add agent test using tool (#426) Feb 28, 2025
@mathetake mathetake enabled auto-merge (squash) February 28, 2025 18:02
@mathetake
Copy link
Member

image

huh - what's this

@mathetake mathetake changed the title e2e: add agent test using tool (#426) backport : e2e: add agent test using tool (#426) Feb 28, 2025
@mathetake mathetake changed the title backport : e2e: add agent test using tool (#426) backport: e2e: add agent test using tool (#426) Feb 28, 2025
@aabchoo
Copy link
Contributor Author

aabchoo commented Feb 28, 2025

The original commits are verified. I wonder if cherry picking commits alters that 🤔

@mathetake
Copy link
Member

i think all resolved now (i disable some checks on the protection rule)

@mathetake mathetake disabled auto-merge February 28, 2025 18:04
@mathetake mathetake merged commit 3ea774e into release/v0.1 Feb 28, 2025
15 of 18 checks passed
@mathetake mathetake deleted the merge-aws-tooling branch February 28, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants