Skip to content

Commit c4665a2

Browse files
fix the output_tool
1 parent f3a4afd commit c4665a2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/models/openai.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,16 @@ There is a limit to the grammar complexity that GPT-5 supports, as such it is im
234234
Freeform function calling, with or without a context free grammar, can be used with the output tool for the agent:
235235

236236
```python
237-
from pydantic_ai import Agent, Tool
237+
from pydantic_ai import Agent
238238
from pydantic_ai.models.openai import OpenAIResponsesModel
239+
from pydantic_ai.output import ToolOutput
239240
from pydantic_ai.tools import FunctionTextFormat
240241

241242
sql_grammar_definition = '...' # (1)!
242243
def database_query(sql: str) -> str:
243244
return sql # (2)!
244245

245-
output_tool = Tool(database_query, text_format=FunctionTextFormat(syntax='lark', grammar=sql_grammar_definition))
246+
output_tool = ToolOutput(database_query, text_format=FunctionTextFormat(syntax='lark', grammar=sql_grammar_definition))
246247
model = OpenAIResponsesModel('gpt-5')
247248
agent = Agent(model, output_type=output_tool)
248249
```

0 commit comments

Comments
 (0)