Closed dtam closed 1 week ago
Question about this:
note List[BaseModel] as a base_model is not supported as its technically not a pydantic object
How does this lack of support manifest? We were previously supporting function calling for root level lists here: https://github.com/guardrails-ai/guardrails/blob/main/guardrails/utils/pydantic_utils/v2.py#L130
The output_schema should also support top level lists.
[Edit]: I'm guessing this is what you're talking about: https://github.com/guardrails-ai/guardrails/pull/835/files#r1646518102
Question about this:
note List[BaseModel] as a base_model is not supported as its technically not a pydantic object
How does this lack of support manifest? We were previously supporting function calling for root level lists here: https://github.com/guardrails-ai/guardrails/blob/main/guardrails/utils/pydantic_utils/v2.py#L130
The output_schema should also support top level lists.
[Edit]: I'm guessing this is what you're talking about: https://github.com/guardrails-ai/guardrails/pull/835/files#r1646518102
neither the openai tools or functions api does supports array as the base type of the parameter
tool generated by convert_pydantic_model_to_openai_fn( with List[Delivery]
Error code: 400 - {'error': {'message': 'Invalid schema for function \'Delivery\': schema must be a JSON Schema of \'type: "object"\', got \'type: "array"\'.', 'type': 'invalid_request_error', 'param': 'functions[0].parameters', 'code': 'invalid_function_parameters'}}
tool generated with my code with List[Delivery]
Error code: 400 - {'error': {'message': 'Invalid schema for function \'gd_response_tool\': schema must be a JSON Schema of \'type: "object"\', got \'type: "array"\'.', 'type': 'invalid_request_error', 'param': 'tools[0].function.parameters', 'code': 'invalid_function_parameters'}}
.
adds support for tools based function calling as a strategy for from_pydantic guards to achieve structured output see usage below. this is only supported on openAI models that support function calling and
note List[BaseModel] as a base_model is not supported as its technically not a pydantic object. It can be achieved with two models see example below
fixes #846