-
Notifications
You must be signed in to change notification settings - Fork 18
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
translator: toolCalls support in OpenAI to Bedrock #132
Conversation
- add more unit tests Signed-off-by: yweng14 <[email protected]>
Signed-off-by: yweng14 <[email protected]>
Signed-off-by: yweng14 <[email protected]>
Could you shorten the title so that it fits in the commit title |
Update the commit message with readable paragraph. |
Signed-off-by: yweng14 <[email protected]>
…f slice Signed-off-by: yweng14 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the multiple iterations. style wise LGTM, so deferring to @yuzisun for the actual logic final approval
Signed-off-by: yweng14 <[email protected]>
Thanks you for helping review, I will send another PR to add ToolCalls support in converse stream |
Signed-off-by: yweng14 <[email protected]>
Signed-off-by: yweng14 <[email protected]>
Choices: []openai.ChatCompletionResponseChoice{ | ||
{ | ||
Index: 0, | ||
FinishReason: openai.ChatCompletionChoicesFinishReasonStop, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The finish reason here should be “tool_calls” as the stop reason on ConverseOutput is set to toolUse in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the unit test, for input bedrock converse response, the stop reason is tool_use
for content with toolUseBlock. The output openai chat completion stop reason is expected to be tool_calls
Signed-off-by: yweng14 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @wengyao04 !!
In this PR, I improve the translator to handle toolCalls. If toolCalls is not in the OpenAI message we append toolResultBlock for assistant role message. In the Response body, we add toolCalls if bedrock content has toolUse I also refactor `openAIMessageToBedrockMessage` to have separate functions to convert message for different roles `user`, `assistant`, `system` and `tool`. When dealing with image content in the roles message, add a function to parse data uri and add proper error handling. --------- Signed-off-by: yweng14 <[email protected]>
In this PR, I improve the translator to handle toolCalls. If toolCalls is not in the OpenAI message we append toolResultBlock for assistant role message. In the Response body, we add toolCalls if bedrock content has toolUse
I also refactor
openAIMessageToBedrockMessage
to have separate functions to convert message for different rolesuser
,assistant
,system
andtool
.When dealing with image content in the roles message, add a function to parse data uri and add proper error handling.