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, normalizing roles like "human" and "ai" to "user" and "assistant" for consistency.

  • 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 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 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 🚀

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.

2 participants