langchain-ai/langchain-google

Attempting to use pydantic models as tool args causes `ParseError` in `ChatVertexAI`

Open

#1,076 建立於 2025年8月5日

在 GitHub 查看
 (4 留言) (3 反應) (0 負責人)Python (461 fork)auto 404
help wantedvertexai

倉庫指標

Star
 (392 star)
PR 合併指標
 (PR 指標待抓取)

描述

Example Pydantic schema:

class IntOrFloat(BaseModel):
    """A type that can be either an int or a float."""

    number: int | float

and tool:

@tool
def add(a: IntOrFloat, b: IntOrFloat) -> IntOrFloat:
    """Adds a and b."""
    return IntOrFloat(number=a.number + b.number)

Attempting to use this tool in a tool-calling agent with ChatVertexAI causes the following error:

ParseError: Failed to parse properties field: Failed to parse properties field: Failed to parse anyOf field: Failed to parse type field: Invalid enum value integer for enum type google.cloud.aiplatform.v1beta1.Type at Schema.properties[a].properties[number].anyOf[0].type....

貢獻者指南