Skip to content

Conversation

@giuliastf
Copy link
Collaborator

@giuliastf giuliastf commented Oct 7, 2025

Description

  • Updated the chat_completions method in llm_gateway_service.py to accept both lists of dictionaries and lists of tuples as message input.

  • Improved the _simple_serialize_defaults function in tracing/_utils.py to handle Pydantic BaseModel instances and classes, including schema serialization for classes and preventing serialization of class types as instances.
    Fix Issue Invoking chat_completions with response_format=pydantic_model throws exception #635

@giuliastf giuliastf self-assigned this Oct 7, 2025
@github-actions github-actions bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-llamaindex Triggers tests in the uipath-llamaindex-python repository labels Oct 7, 2025
@giuliastf giuliastf force-pushed the fix/response_format branch 3 times, most recently from ebebac2 to 2d635f6 Compare October 7, 2025 12:55
Copy link

Copilot AI left a 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.

@giuliastf giuliastf force-pushed the fix/response_format branch 2 times, most recently from e06040f to 40af737 Compare October 7, 2025 15:49
@giuliastf giuliastf requested a review from Copilot October 7, 2025 15:50
Copy link

Copilot AI left a 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.

@giuliastf giuliastf force-pushed the fix/response_format branch 2 times, most recently from 5f9f886 to 066c2e9 Compare October 7, 2025 16:04
Copy link
Collaborator

@akshaylive akshaylive left a 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! :)

@giuliastf giuliastf force-pushed the fix/response_format branch from 066c2e9 to 7ffcd26 Compare October 8, 2025 07:36
@giuliastf giuliastf requested a review from akshaylive October 8, 2025 07:48
Copy link
Collaborator

@akshaylive akshaylive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@giuliastf giuliastf force-pushed the fix/response_format branch from 7ffcd26 to 55aed6b Compare October 24, 2025 12:14
@giuliastf giuliastf changed the title fix(response_format): added role mapping + changed default serialization fix(response_format): changed default serialization Oct 24, 2025
@giuliastf giuliastf force-pushed the fix/response_format branch from 55aed6b to 2154b2d Compare October 24, 2025 12:21

request_body = {
"messages": messages,
"messages": converted_messages,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have a clear error message from llm gateway if the 'roles' passed are not the expected ones? If not we should validate them against a well known roles list before sending the request

@giuliastf giuliastf force-pushed the fix/response_format branch from 2154b2d to b630081 Compare October 24, 2025 14:01
@giuliastf giuliastf force-pushed the fix/response_format branch from b630081 to 80035ec Compare October 24, 2025 14:02
@giuliastf giuliastf merged commit ec20ba9 into main Oct 24, 2025
60 checks passed
@giuliastf giuliastf deleted the fix/response_format branch October 24, 2025 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-llamaindex Triggers tests in the uipath-llamaindex-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants