Description
adds function that allows augmenting tools guard.call argument to augment tools with a function that allows structured response from llm
Why is this needed
models that support the openai tools api can generate structured response through forcing a tool choice and providing a with a signature that matches the desired outputs return format and mentioning the tool must be called last
Implementation details
add Guard.augment_tools_with_schema(
update callable return handling to handle function choice and arguments in response
End result
class Task(BaseModel):
status: str
priority: int
description: str
guard = Guard.from_pydantic(Tasks)
tools = [] # openai function calling tool array
output = guard(
openai.chat.completions.create,
model='gpt-4o',
msg_history=[
{
"role": "user",
"content": "You are a helpful assistant"
"read this email and return the tasks from it."
" some email blah blah blah.",
}
],
tools=guard.augment_tools_with_schema(tools),
tool_choice="required",
)
Description adds function that allows augmenting tools guard.call argument to augment tools with a function that allows structured response from llm
Why is this needed models that support the openai tools api can generate structured response through forcing a tool choice and providing a with a signature that matches the desired outputs return format and mentioning the tool must be called last
Implementation details add Guard.augment_tools_with_schema( update callable return handling to handle function choice and arguments in response
End result