Skip to content

Commit 9712a00

Browse files
committed
remove test and duplicate text
1 parent 189dce5 commit 9712a00

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

docs/output.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ RouterFailure(explanation='I am not equipped to provide travel information, such
237237

238238
#### Text output
239239

240-
If you provide an output function that takes a string, Pydantic AI will by default create an output tool like for any other output function. If instead you'd like the model to provide the string using plain text output, you can wrap the function in the [`TextOutput`][pydantic_ai.output.TextOutput] marker class.
240+
If you provide an output function that takes a string, Pydantic AI will by default create an output tool like for any other output function. If instead you'd like the model to provide the string using plain text output, you can wrap the function in the [`TextOutput`][pydantic_ai.output.TextOutput] marker class.
241241

242242
If desired, this marker class can be used alongside one or more [`ToolOutput`](#tool-output) marker classes (or unmarked types or functions) in a list provided to `output_type`.
243243

@@ -262,8 +262,6 @@ print(result.output)
262262

263263
_(This example is complete, it can be run "as is")_
264264

265-
Like other output functions, text output functions can optionally take [`RunContext`][pydantic_ai.tools.RunContext] as the first argument, and can raise [`ModelRetry`][pydantic_ai.exceptions.ModelRetry] to ask the model to try again with modified arguments (or with a different output type).
266-
267265
### Output modes
268266

269267
Pydantic AI implements three different methods to get a model to output structured data:

tests/test_agent.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,24 +1167,6 @@ def call_tool(messages: list[ModelMessage], info: AgentInfo) -> ModelResponse:
11671167
)
11681168

11691169

1170-
def test_output_type_text_output_function_with_deps():
1171-
"""Test that TextOutput functions can use RunContext with custom deps type."""
1172-
1173-
@dataclass
1174-
class Deps:
1175-
prefix: str
1176-
1177-
def add_prefix_and_split(ctx: RunContext[Deps], text: str) -> list[str]:
1178-
return f'{ctx.deps.prefix}: {text}'.split()
1179-
1180-
def return_text(messages: list[ModelMessage], info: AgentInfo) -> ModelResponse:
1181-
return ModelResponse(parts=[TextPart(content='Hello world')])
1182-
1183-
agent = Agent(FunctionModel(return_text), deps_type=Deps, output_type=TextOutput(add_prefix_and_split))
1184-
result = agent.run_sync('test prompt', deps=Deps(prefix='Response'))
1185-
assert result.output == snapshot(['Response:', 'Hello', 'world'])
1186-
1187-
11881170
@pytest.mark.parametrize(
11891171
'output_type',
11901172
[[str, str], [str, TextOutput(upcase)], [TextOutput(upcase), TextOutput(upcase)]],

0 commit comments

Comments
 (0)