Use existing required args obj if specified (#9883)

We always overwrote the required args but we infer them by default.
Doing it only the old way makes it so the llm guesses even if an arg is
optional (e.g., for uuids)
This commit is contained in:
William FH 2023-08-28 14:40:22 -07:00 committed by GitHub
parent b14d74dd4d
commit 3103f07e03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,9 @@ def format_tool_to_openai_function(tool: BaseTool) -> FunctionDescription:
if isinstance(tool, StructuredTool):
schema_ = tool.args_schema.schema()
# Bug with required missing for structured tools.
required = sorted(schema_["properties"]) # BUG WORKAROUND
required = schema_.get(
"required", sorted(schema_["properties"]) # Backup is a BUG WORKAROUND
)
return {
"name": tool.name,
"description": tool.description,