-
Notifications
You must be signed in to change notification settings - Fork 304
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
Adds support for json structured return through tools #840
Conversation
@@ -199,7 +199,11 @@ def _invoke_llm( | |||
# TODO: Update this to tools | |||
# Configure function calling if applicable (only for non-streaming) | |||
fn_kwargs = {} | |||
if base_model and not kwargs.get("stream", False): | |||
if ( |
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.
this preserves the legacy support for the old default support for old openai functions
guardrails/guard.py
Outdated
@@ -1259,6 +1261,19 @@ def to_dict(self) -> Dict[str, Any]: | |||
|
|||
return i_guard_dict | |||
|
|||
def augment_tools_with_schema( |
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.
Not a blocker bc we can always deprecate in favor of something else once we make a decision, but since this is intended to facility function calling can we make the name reflect that?
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.
updated to add_json_function_calling_tool
Question about this:
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 |
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