|
37 | 37 | capture_run_messages, |
38 | 38 | ) |
39 | 39 | from .._json_schema import JsonSchema |
40 | | -from .._output import OutputToolset |
| 40 | +from .._output import OutputToolset, _flatten_output_spec # pyright: ignore[reportPrivateUsage] |
41 | 41 | from .._tool_manager import ToolManager |
42 | 42 | from ..builtin_tools import AbstractBuiltinTool |
43 | 43 | from ..models.instrumented import InstrumentationSettings, InstrumentedModel, instrument_model |
@@ -958,35 +958,32 @@ def decorator( |
958 | 958 | self._system_prompt_functions.append(_system_prompt.SystemPromptRunner[AgentDepsT](func, dynamic=dynamic)) |
959 | 959 | return func |
960 | 960 |
|
961 | | - def output_json_schema(self, output_type: OutputSpec[OutputDataT] | None = None) -> JsonSchema: |
| 961 | + def output_json_schema(self, output_type: OutputSpec[OutputDataT | RunOutputDataT] | None = None) -> JsonSchema: |
962 | 962 | """The output JSON schema.""" |
963 | 963 | if output_type is None: |
964 | 964 | output_type = self.output_type |
965 | 965 |
|
966 | 966 | # call this first to force output_type to an iterable |
967 | | - output_type = list(_output._flatten_output_spec(output_type)) |
| 967 | + output_type = list(_flatten_output_spec(output_type)) |
968 | 968 |
|
969 | 969 | # flatten special outputs |
970 | 970 | for i, _ in enumerate(output_type): |
971 | 971 | if isinstance(_, _output.NativeOutput): |
972 | | - output_type[i] = _output._flatten_output_spec(_.outputs) |
| 972 | + output_type[i] = _flatten_output_spec(_.outputs) |
973 | 973 | if isinstance(_, _output.PromptedOutput): |
974 | | - output_type[i] = _output._flatten_output_spec(_.outputs) |
| 974 | + output_type[i] = _flatten_output_spec(_.outputs) |
975 | 975 | if isinstance(_, _output.ToolOutput): |
976 | | - output_type[i] = _output._flatten_output_spec(_.output) |
| 976 | + output_type[i] = _flatten_output_spec(_.output) |
977 | 977 |
|
978 | 978 | # final flattening |
979 | | - output_type = _output._flatten_output_spec(output_type) |
| 979 | + output_type = _flatten_output_spec(output_type) |
980 | 980 |
|
981 | 981 | json_schemas: list[JsonSchema] = [] |
982 | 982 | for _ in output_type: |
983 | 983 | if inspect.isfunction(_) or inspect.ismethod(_): |
984 | 984 | function_schema = _function_schema.function_schema(_, GenerateToolJsonSchema) |
985 | 985 | json_schema = function_schema.json_schema |
986 | 986 | json_schema['description'] = function_schema.description |
987 | | - elif isinstance(_, _messages.BinaryImage): |
988 | | - json_schema = TypeAdapter(_).json_schema(mode='serialization') |
989 | | - json_schema = {k: v for k, v in json_schema['properties'].items() if k in ['data', 'media_type']} |
990 | 987 | else: |
991 | 988 | json_schema = TypeAdapter(_).json_schema(mode='serialization') |
992 | 989 |
|
|
0 commit comments