-
Notifications
You must be signed in to change notification settings - Fork 16
fix(response_format): added role mapping + changed default serialization #648
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
base: main
Are you sure you want to change the base?
Conversation
ebebac2
to
2d635f6
Compare
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.
Pull Request Overview
This PR fixes response format handling and serialization issues in the UiPath Python SDK. The changes improve message format compatibility and resolve JSON serialization errors when using Pydantic BaseModel classes as parameters.
- Enhanced message format support to accept both dictionaries and tuples with role normalization
- Improved serialization handling for Pydantic BaseModel classes and instances
- Added comprehensive test coverage for the new functionality
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/uipath/_services/llm_gateway_service.py |
Added role mapping and message format conversion to support tuples and normalize roles |
src/uipath/tracing/_utils.py |
Enhanced serialization to handle Pydantic BaseModel classes with schema representation |
tests/tracing/test_traced.py |
Added comprehensive test for Pydantic BaseModel serialization and tuple message handling |
pyproject.toml |
Version bump to 2.1.73 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
e06040f
to
40af737
Compare
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.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
5f9f886
to
066c2e9
Compare
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 addressing this! :)
066c2e9
to
7ffcd26
Compare
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.
LGTM 🚀
Description
Updated the
chat_completions
method inllm_gateway_service.py
to accept both lists of dictionaries and lists of tuples as message input, normalizing roles like "human" and "ai" to "user" and "assistant" for consistency.Improved the
_simple_serialize_defaults
function intracing/_utils.py
to handle PydanticBaseModel
instances and classes, including schema serialization for classes and preventing serialization of class types as instances.Fix Issue Invoking
chat_completions
withresponse_format=pydantic_model
throws exception #635