openai-agents 0.0.4__tar.gz → 0.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of openai-agents might be problematic. Click here for more details.
- openai_agents-0.0.5/.github/ISSUE_TEMPLATE/model_provider.md +26 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/.github/workflows/tests.yml +2 -2
- {openai_agents-0.0.4 → openai_agents-0.0.5}/Makefile +17 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/PKG-INFO +4 -4
- {openai_agents-0.0.4 → openai_agents-0.0.5}/README.md +2 -2
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/agents.md +13 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/models.md +27 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/tracing.md +9 -2
- openai_agents-0.0.5/examples/agent_patterns/forcing_tool_use.py +99 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/basic/agent_lifecycle_example.py +1 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/basic/hello_world_jupyter.py +1 -1
- openai_agents-0.0.5/examples/basic/tools.py +34 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/handoffs/message_filter.py +2 -2
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/handoffs/message_filter_streaming.py +2 -2
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/model_providers/custom_example_agent.py +9 -5
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/model_providers/custom_example_global.py +9 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/model_providers/custom_example_provider.py +10 -6
- {openai_agents-0.0.4 → openai_agents-0.0.5}/pyproject.toml +7 -3
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/__init__.py +10 -5
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/_run_impl.py +101 -22
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/agent.py +55 -7
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/agent_output.py +4 -4
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/function_schema.py +4 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/guardrail.py +1 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/handoffs.py +4 -4
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/items.py +4 -2
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/models/openai_chatcompletions.py +6 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/result.py +7 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/run.py +10 -10
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/tool.py +34 -10
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/tracing/create.py +1 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/tracing/processors.py +2 -2
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/tracing/scope.py +1 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/tracing/setup.py +1 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/tracing/span_data.py +2 -2
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/tracing/spans.py +1 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/tracing/traces.py +1 -1
- openai_agents-0.0.5/src/agents/util/_coro.py +2 -0
- openai_agents-0.0.5/src/agents/util/_error_tracing.py +16 -0
- openai_agents-0.0.5/src/agents/util/_json.py +31 -0
- openai_agents-0.0.5/src/agents/util/_pretty_print.py +56 -0
- openai_agents-0.0.5/src/agents/util/_transforms.py +11 -0
- openai_agents-0.0.5/src/agents/util/_types.py +7 -0
- openai_agents-0.0.5/tests/README.md +25 -0
- openai_agents-0.0.5/tests/__init__.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_agent_runner.py +82 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_agent_tracing.py +114 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_function_tool.py +2 -2
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_function_tool_decorator.py +57 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_output_tool.py +4 -2
- openai_agents-0.0.5/tests/test_pretty_print.py +201 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_responses_tracing.py +32 -1
- openai_agents-0.0.5/tests/test_tool_use_behavior.py +194 -0
- openai_agents-0.0.5/tests/test_tracing_errors.py +605 -0
- openai_agents-0.0.5/tests/test_tracing_errors_streamed.py +777 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/testing_processor.py +35 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/uv.lock +118 -84
- openai_agents-0.0.4/src/agents/_utils.py +0 -61
- openai_agents-0.0.4/tests/test_tracing_errors.py +0 -328
- openai_agents-0.0.4/tests/test_tracing_errors_streamed.py +0 -397
- {openai_agents-0.0.4 → openai_agents-0.0.5}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/.github/ISSUE_TEMPLATE/question.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/.github/workflows/docs.yml +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/.github/workflows/issues.yml +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/.github/workflows/publish.yml +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/.gitignore +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/.prettierrc +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/LICENSE +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/assets/images/favicon-platform.svg +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/assets/images/orchestration.png +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/assets/logo.svg +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/config.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/context.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/guardrails.md +1 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/handoffs.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/index.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/multi_agent.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/quickstart.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/agent.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/agent_output.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/exceptions.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/extensions/handoff_filters.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/extensions/handoff_prompt.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/function_schema.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/guardrail.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/handoffs.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/index.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/items.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/lifecycle.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/model_settings.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/models/interface.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/models/openai_chatcompletions.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/models/openai_responses.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/result.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/run.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/run_context.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/stream_events.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/tool.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/tracing/create.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/tracing/index.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/tracing/processor_interface.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/tracing/processors.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/tracing/scope.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/tracing/setup.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/tracing/span_data.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/tracing/spans.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/tracing/traces.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/tracing/util.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/ref/usage.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/results.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/running_agents.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/streaming.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/stylesheets/extra.css +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/docs/tools.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/__init__.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/agent_patterns/README.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/agent_patterns/agents_as_tools.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/agent_patterns/deterministic.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/agent_patterns/input_guardrails.py +1 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/agent_patterns/llm_as_a_judge.py +1 -1
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/agent_patterns/output_guardrails.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/agent_patterns/parallelization.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/agent_patterns/routing.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/basic/dynamic_system_prompt.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/basic/hello_world.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/basic/lifecycle_example.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/basic/stream_items.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/basic/stream_text.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/customer_service/main.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/model_providers/README.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/README.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/__init__.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/agents/__init__.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/agents/planner_agent.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/agents/search_agent.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/agents/writer_agent.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/main.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/manager.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/printer.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/sample_outputs/product_recs.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/sample_outputs/product_recs.txt +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/sample_outputs/vacation.md +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/research_bot/sample_outputs/vacation.txt +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/tools/computer_use.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/tools/file_search.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/examples/tools/web_search.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/mkdocs.yml +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/_config.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/_debug.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/computer.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/exceptions.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/extensions/__init__.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/extensions/handoff_filters.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/extensions/handoff_prompt.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/lifecycle.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/logger.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/model_settings.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/models/__init__.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/models/_openai_shared.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/models/fake_id.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/models/interface.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/models/openai_provider.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/models/openai_responses.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/run_context.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/stream_events.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/strict_schema.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/tracing/__init__.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/tracing/logger.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/tracing/processor_interface.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/tracing/util.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/usage.py +0 -0
- {openai_agents-0.0.4/tests → openai_agents-0.0.5/src/agents/util}/__init__.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/src/agents/version.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/conftest.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/fake_model.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_agent_config.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_agent_hooks.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_agent_runner_streamed.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_computer_action.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_config.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_doc_parsing.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_extension_filters.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_function_schema.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_global_hooks.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_guardrails.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_handoff_tool.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_items_helpers.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_max_turns.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_openai_chatcompletions.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_openai_chatcompletions_converter.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_openai_chatcompletions_stream.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_openai_responses_converter.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_responses.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_result_cast.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_run_config.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_run_step_execution.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_run_step_processing.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_strict_schema.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_tool_converter.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_trace_processor.py +0 -0
- {openai_agents-0.0.4 → openai_agents-0.0.5}/tests/test_tracing.py +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Custom model providers
|
|
3
|
+
about: Questions or bugs about using non-OpenAI models
|
|
4
|
+
title: ''
|
|
5
|
+
labels: bug
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
### Please read this first
|
|
11
|
+
|
|
12
|
+
- **Have you read the custom model provider docs, including the 'Common issues' section?** [Model provider docs](https://openai.github.io/openai-agents-python/models/#using-other-llm-providers)
|
|
13
|
+
- **Have you searched for related issues?** Others may have faced similar issues.
|
|
14
|
+
|
|
15
|
+
### Describe the question
|
|
16
|
+
A clear and concise description of what the question or bug is.
|
|
17
|
+
|
|
18
|
+
### Debug information
|
|
19
|
+
- Agents SDK version: (e.g. `v0.0.3`)
|
|
20
|
+
- Python version (e.g. Python 3.10)
|
|
21
|
+
|
|
22
|
+
### Repro steps
|
|
23
|
+
Ideally provide a minimal python script that can be run to reproduce the issue.
|
|
24
|
+
|
|
25
|
+
### Expected behavior
|
|
26
|
+
A clear and concise description of what you expected to happen.
|
|
@@ -18,6 +18,21 @@ mypy:
|
|
|
18
18
|
tests:
|
|
19
19
|
uv run pytest
|
|
20
20
|
|
|
21
|
+
.PHONY: coverage
|
|
22
|
+
coverage:
|
|
23
|
+
|
|
24
|
+
uv run coverage run -m pytest
|
|
25
|
+
uv run coverage xml -o coverage.xml
|
|
26
|
+
uv run coverage report -m --fail-under=95
|
|
27
|
+
|
|
28
|
+
.PHONY: snapshots-fix
|
|
29
|
+
snapshots-fix:
|
|
30
|
+
uv run pytest --inline-snapshot=fix
|
|
31
|
+
|
|
32
|
+
.PHONY: snapshots-create
|
|
33
|
+
snapshots-create:
|
|
34
|
+
uv run pytest --inline-snapshot=create
|
|
35
|
+
|
|
21
36
|
.PHONY: old_version_tests
|
|
22
37
|
old_version_tests:
|
|
23
38
|
UV_PROJECT_ENVIRONMENT=.venv_39 uv run --python 3.9 -m pytest
|
|
@@ -34,4 +49,6 @@ serve-docs:
|
|
|
34
49
|
.PHONY: deploy-docs
|
|
35
50
|
deploy-docs:
|
|
36
51
|
uv run mkdocs gh-deploy --force --verbose
|
|
52
|
+
|
|
53
|
+
|
|
37
54
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openai-agents
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: OpenAI Agents SDK
|
|
5
5
|
Project-URL: Homepage, https://github.com/openai/openai-agents-python
|
|
6
6
|
Project-URL: Repository, https://github.com/openai/openai-agents-python
|
|
@@ -19,7 +19,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
19
19
|
Classifier: Typing :: Typed
|
|
20
20
|
Requires-Python: >=3.9
|
|
21
21
|
Requires-Dist: griffe<2,>=1.5.6
|
|
22
|
-
Requires-Dist: openai>=1.66.
|
|
22
|
+
Requires-Dist: openai>=1.66.5
|
|
23
23
|
Requires-Dist: pydantic<3,>=2.10
|
|
24
24
|
Requires-Dist: requests<3,>=2.0
|
|
25
25
|
Requires-Dist: types-requests<3,>=2.0
|
|
@@ -35,7 +35,7 @@ The OpenAI Agents SDK is a lightweight yet powerful framework for building multi
|
|
|
35
35
|
### Core concepts:
|
|
36
36
|
|
|
37
37
|
1. [**Agents**](https://openai.github.io/openai-agents-python/agents): LLMs configured with instructions, tools, guardrails, and handoffs
|
|
38
|
-
2. [**Handoffs**](https://openai.github.io/openai-agents-python/handoffs/):
|
|
38
|
+
2. [**Handoffs**](https://openai.github.io/openai-agents-python/handoffs/): A specialized tool call used by the Agents SDK for transferring control between agents
|
|
39
39
|
3. [**Guardrails**](https://openai.github.io/openai-agents-python/guardrails/): Configurable safety checks for input and output validation
|
|
40
40
|
4. [**Tracing**](https://openai.github.io/openai-agents-python/tracing/): Built-in tracking of agent runs, allowing you to view, debug and optimize your workflows
|
|
41
41
|
|
|
@@ -170,7 +170,7 @@ The Agents SDK is designed to be highly flexible, allowing you to model a wide r
|
|
|
170
170
|
|
|
171
171
|
## Tracing
|
|
172
172
|
|
|
173
|
-
The Agents SDK automatically traces your agent runs, making it easy to track and debug the behavior of your agents. Tracing is extensible by design, supporting custom spans and a wide variety of external destinations, including [Logfire](https://logfire.pydantic.dev/docs/integrations/llms/openai/#openai-agents), [AgentOps](https://docs.agentops.ai/v1/integrations/agentssdk), [Braintrust](https://braintrust.dev/docs/guides/traces/integrations#openai-agents-sdk), [Scorecard](https://docs.scorecard.io/docs/documentation/features/tracing#openai-agents-sdk-integration), and [Keywords AI](https://docs.keywordsai.co/integration/development-frameworks/openai-agent). For more details about how to customize or disable tracing, see [Tracing](http://openai.github.io/openai-agents-python/tracing).
|
|
173
|
+
The Agents SDK automatically traces your agent runs, making it easy to track and debug the behavior of your agents. Tracing is extensible by design, supporting custom spans and a wide variety of external destinations, including [Logfire](https://logfire.pydantic.dev/docs/integrations/llms/openai/#openai-agents), [AgentOps](https://docs.agentops.ai/v1/integrations/agentssdk), [Braintrust](https://braintrust.dev/docs/guides/traces/integrations#openai-agents-sdk), [Scorecard](https://docs.scorecard.io/docs/documentation/features/tracing#openai-agents-sdk-integration), and [Keywords AI](https://docs.keywordsai.co/integration/development-frameworks/openai-agent). For more details about how to customize or disable tracing, see [Tracing](http://openai.github.io/openai-agents-python/tracing), which also includes a larger list of [external tracing processors](http://openai.github.io/openai-agents-python/tracing/#external-tracing-processors-list).
|
|
174
174
|
|
|
175
175
|
## Development (only needed if you need to edit the SDK/examples)
|
|
176
176
|
|
|
@@ -7,7 +7,7 @@ The OpenAI Agents SDK is a lightweight yet powerful framework for building multi
|
|
|
7
7
|
### Core concepts:
|
|
8
8
|
|
|
9
9
|
1. [**Agents**](https://openai.github.io/openai-agents-python/agents): LLMs configured with instructions, tools, guardrails, and handoffs
|
|
10
|
-
2. [**Handoffs**](https://openai.github.io/openai-agents-python/handoffs/):
|
|
10
|
+
2. [**Handoffs**](https://openai.github.io/openai-agents-python/handoffs/): A specialized tool call used by the Agents SDK for transferring control between agents
|
|
11
11
|
3. [**Guardrails**](https://openai.github.io/openai-agents-python/guardrails/): Configurable safety checks for input and output validation
|
|
12
12
|
4. [**Tracing**](https://openai.github.io/openai-agents-python/tracing/): Built-in tracking of agent runs, allowing you to view, debug and optimize your workflows
|
|
13
13
|
|
|
@@ -142,7 +142,7 @@ The Agents SDK is designed to be highly flexible, allowing you to model a wide r
|
|
|
142
142
|
|
|
143
143
|
## Tracing
|
|
144
144
|
|
|
145
|
-
The Agents SDK automatically traces your agent runs, making it easy to track and debug the behavior of your agents. Tracing is extensible by design, supporting custom spans and a wide variety of external destinations, including [Logfire](https://logfire.pydantic.dev/docs/integrations/llms/openai/#openai-agents), [AgentOps](https://docs.agentops.ai/v1/integrations/agentssdk), [Braintrust](https://braintrust.dev/docs/guides/traces/integrations#openai-agents-sdk), [Scorecard](https://docs.scorecard.io/docs/documentation/features/tracing#openai-agents-sdk-integration), and [Keywords AI](https://docs.keywordsai.co/integration/development-frameworks/openai-agent). For more details about how to customize or disable tracing, see [Tracing](http://openai.github.io/openai-agents-python/tracing).
|
|
145
|
+
The Agents SDK automatically traces your agent runs, making it easy to track and debug the behavior of your agents. Tracing is extensible by design, supporting custom spans and a wide variety of external destinations, including [Logfire](https://logfire.pydantic.dev/docs/integrations/llms/openai/#openai-agents), [AgentOps](https://docs.agentops.ai/v1/integrations/agentssdk), [Braintrust](https://braintrust.dev/docs/guides/traces/integrations#openai-agents-sdk), [Scorecard](https://docs.scorecard.io/docs/documentation/features/tracing#openai-agents-sdk-integration), and [Keywords AI](https://docs.keywordsai.co/integration/development-frameworks/openai-agent). For more details about how to customize or disable tracing, see [Tracing](http://openai.github.io/openai-agents-python/tracing), which also includes a larger list of [external tracing processors](http://openai.github.io/openai-agents-python/tracing/#external-tracing-processors-list).
|
|
146
146
|
|
|
147
147
|
## Development (only needed if you need to edit the SDK/examples)
|
|
148
148
|
|
|
@@ -130,3 +130,16 @@ robot_agent = pirate_agent.clone(
|
|
|
130
130
|
instructions="Write like a robot",
|
|
131
131
|
)
|
|
132
132
|
```
|
|
133
|
+
|
|
134
|
+
## Forcing tool use
|
|
135
|
+
|
|
136
|
+
Supplying a list of tools doesn't always mean the LLM will use a tool. You can force tool use by setting [`ModelSettings.tool_choice`][agents.model_settings.ModelSettings.tool_choice]. Valid values are:
|
|
137
|
+
|
|
138
|
+
1. `auto`, which allows the LLM to decide whether or not to use a tool.
|
|
139
|
+
2. `required`, which requires the LLM to use a tool (but it can intelligently decide which tool).
|
|
140
|
+
3. `none`, which requires the LLM to _not_ use a tool.
|
|
141
|
+
4. Setting a specific string e.g. `my_tool`, which requires the LLM to use that specific tool.
|
|
142
|
+
|
|
143
|
+
!!! note
|
|
144
|
+
|
|
145
|
+
If requiring tool use, you should consider setting [`Agent.tool_use_behavior`] to stop the Agent from running when a tool output is produced. Otherwise, the Agent might run in an infinite loop, where the LLM produces a tool call , and the tool result is sent to the LLM, and this infinite loops because the LLM is always forced to use a tool.
|
|
@@ -64,3 +64,30 @@ In cases where you do not have an API key from `platform.openai.com`, we recomme
|
|
|
64
64
|
!!! note
|
|
65
65
|
|
|
66
66
|
In these examples, we use the Chat Completions API/model, because most LLM providers don't yet support the Responses API. If your LLM provider does support it, we recommend using Responses.
|
|
67
|
+
|
|
68
|
+
## Common issues with using other LLM providers
|
|
69
|
+
|
|
70
|
+
### Tracing client error 401
|
|
71
|
+
|
|
72
|
+
If you get errors related to tracing, this is because traces are uploaded to OpenAI servers, and you don't have an OpenAI API key. You have three options to resolve this:
|
|
73
|
+
|
|
74
|
+
1. Disable tracing entirely: [`set_tracing_disabled(True)`][agents.set_tracing_disabled].
|
|
75
|
+
2. Set an OpenAI key for tracing: [`set_tracing_export_api_key(...)`][agents.set_tracing_export_api_key]. This API key will only be used for uploading traces, and must be from [platform.openai.com](https://platform.openai.com/).
|
|
76
|
+
3. Use a non-OpenAI trace processor. See the [tracing docs](tracing.md#custom-tracing-processors).
|
|
77
|
+
|
|
78
|
+
### Responses API support
|
|
79
|
+
|
|
80
|
+
The SDK uses the Responses API by default, but most other LLM providers don't yet support it. You may see 404s or similar issues as a result. To resolve, you have two options:
|
|
81
|
+
|
|
82
|
+
1. Call [`set_default_openai_api("chat_completions")`][agents.set_default_openai_api]. This works if you are setting `OPENAI_API_KEY` and `OPENAI_BASE_URL` via environment vars.
|
|
83
|
+
2. Use [`OpenAIChatCompletionsModel`][agents.models.openai_chatcompletions.OpenAIChatCompletionsModel]. There are examples [here](https://github.com/openai/openai-agents-python/tree/main/examples/model_providers/).
|
|
84
|
+
|
|
85
|
+
### Structured outputs support
|
|
86
|
+
|
|
87
|
+
Some model providers don't have support for [structured outputs](https://platform.openai.com/docs/guides/structured-outputs). This sometimes results in an error that looks something like this:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
BadRequestError: Error code: 400 - {'error': {'message': "'response_format.type' : value is not one of the allowed values ['text','json_object']", 'type': 'invalid_request_error'}}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This is a shortcoming of some model providers - they support JSON outputs, but don't allow you to specify the `json_schema` to use for the output. We are working on a fix for this, but we suggest relying on providers that do have support for JSON schema output, because otherwise your app will often break because of malformed JSON.
|
|
@@ -9,6 +9,8 @@ The Agents SDK includes built-in tracing, collecting a comprehensive record of e
|
|
|
9
9
|
1. You can globally disable tracing by setting the env var `OPENAI_AGENTS_DISABLE_TRACING=1`
|
|
10
10
|
2. You can disable tracing for a single run by setting [`agents.run.RunConfig.tracing_disabled`][] to `True`
|
|
11
11
|
|
|
12
|
+
***For organizations operating under a Zero Data Retention (ZDR) policy using OpenAI's APIs, tracing is unavailable.***
|
|
13
|
+
|
|
12
14
|
## Traces and spans
|
|
13
15
|
|
|
14
16
|
- **Traces** represent a single end-to-end operation of a "workflow". They're composed of Spans. Traces have the following properties:
|
|
@@ -88,10 +90,15 @@ To customize this default setup, to send traces to alternative or additional bac
|
|
|
88
90
|
1. [`add_trace_processor()`][agents.tracing.add_trace_processor] lets you add an **additional** trace processor that will receive traces and spans as they are ready. This lets you do your own processing in addition to sending traces to OpenAI's backend.
|
|
89
91
|
2. [`set_trace_processors()`][agents.tracing.set_trace_processors] lets you **replace** the default processors with your own trace processors. This means traces will not be sent to the OpenAI backend unless you include a `TracingProcessor` that does so.
|
|
90
92
|
|
|
91
|
-
External
|
|
93
|
+
## External tracing processors list
|
|
92
94
|
|
|
95
|
+
- [Arize-Phoenix](https://docs.arize.com/phoenix/tracing/integrations-tracing/openai-agents-sdk)
|
|
96
|
+
- [MLflow](https://mlflow.org/docs/latest/tracing/integrations/openai-agent)
|
|
93
97
|
- [Braintrust](https://braintrust.dev/docs/guides/traces/integrations#openai-agents-sdk)
|
|
94
98
|
- [Pydantic Logfire](https://logfire.pydantic.dev/docs/integrations/llms/openai/#openai-agents)
|
|
95
99
|
- [AgentOps](https://docs.agentops.ai/v1/integrations/agentssdk)
|
|
96
|
-
- [Scorecard](https://docs.scorecard.io/docs/documentation/features/tracing#openai-agents-sdk-integration)
|
|
100
|
+
- [Scorecard](https://docs.scorecard.io/docs/documentation/features/tracing#openai-agents-sdk-integration)
|
|
97
101
|
- [Keywords AI](https://docs.keywordsai.co/integration/development-frameworks/openai-agent)
|
|
102
|
+
- [LangSmith](https://docs.smith.langchain.com/observability/how_to_guides/trace_with_openai_agents_sdk)
|
|
103
|
+
- [Maxim AI](https://www.getmaxim.ai/docs/observe/integrations/openai-agents-sdk)
|
|
104
|
+
- [Comet Opik](https://www.comet.com/docs/opik/tracing/integrations/openai_agents)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
from typing import Any, Literal
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel
|
|
7
|
+
|
|
8
|
+
from agents import (
|
|
9
|
+
Agent,
|
|
10
|
+
FunctionToolResult,
|
|
11
|
+
ModelSettings,
|
|
12
|
+
RunContextWrapper,
|
|
13
|
+
Runner,
|
|
14
|
+
ToolsToFinalOutputFunction,
|
|
15
|
+
ToolsToFinalOutputResult,
|
|
16
|
+
function_tool,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
This example shows how to force the agent to use a tool. It uses `ModelSettings(tool_choice="required")`
|
|
21
|
+
to force the agent to use any tool.
|
|
22
|
+
|
|
23
|
+
You can run it with 3 options:
|
|
24
|
+
1. `default`: The default behavior, which is to send the tool output to the LLM. In this case,
|
|
25
|
+
`tool_choice` is not set, because otherwise it would result in an infinite loop - the LLM would
|
|
26
|
+
call the tool, the tool would run and send the results to the LLM, and that would repeat
|
|
27
|
+
(because the model is forced to use a tool every time.)
|
|
28
|
+
2. `first_tool_result`: The first tool result is used as the final output.
|
|
29
|
+
3. `custom`: A custom tool use behavior function is used. The custom function receives all the tool
|
|
30
|
+
results, and chooses to use the first tool result to generate the final output.
|
|
31
|
+
|
|
32
|
+
Usage:
|
|
33
|
+
python examples/agent_patterns/forcing_tool_use.py -t default
|
|
34
|
+
python examples/agent_patterns/forcing_tool_use.py -t first_tool
|
|
35
|
+
python examples/agent_patterns/forcing_tool_use.py -t custom
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class Weather(BaseModel):
|
|
40
|
+
city: str
|
|
41
|
+
temperature_range: str
|
|
42
|
+
conditions: str
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@function_tool
|
|
46
|
+
def get_weather(city: str) -> Weather:
|
|
47
|
+
print("[debug] get_weather called")
|
|
48
|
+
return Weather(city=city, temperature_range="14-20C", conditions="Sunny with wind")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
async def custom_tool_use_behavior(
|
|
52
|
+
context: RunContextWrapper[Any], results: list[FunctionToolResult]
|
|
53
|
+
) -> ToolsToFinalOutputResult:
|
|
54
|
+
weather: Weather = results[0].output
|
|
55
|
+
return ToolsToFinalOutputResult(
|
|
56
|
+
is_final_output=True, final_output=f"{weather.city} is {weather.conditions}."
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
async def main(tool_use_behavior: Literal["default", "first_tool", "custom"] = "default"):
|
|
61
|
+
if tool_use_behavior == "default":
|
|
62
|
+
behavior: Literal["run_llm_again", "stop_on_first_tool"] | ToolsToFinalOutputFunction = (
|
|
63
|
+
"run_llm_again"
|
|
64
|
+
)
|
|
65
|
+
elif tool_use_behavior == "first_tool":
|
|
66
|
+
behavior = "stop_on_first_tool"
|
|
67
|
+
elif tool_use_behavior == "custom":
|
|
68
|
+
behavior = custom_tool_use_behavior
|
|
69
|
+
|
|
70
|
+
agent = Agent(
|
|
71
|
+
name="Weather agent",
|
|
72
|
+
instructions="You are a helpful agent.",
|
|
73
|
+
tools=[get_weather],
|
|
74
|
+
tool_use_behavior=behavior,
|
|
75
|
+
model_settings=ModelSettings(
|
|
76
|
+
tool_choice="required" if tool_use_behavior != "default" else None
|
|
77
|
+
),
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
result = await Runner.run(agent, input="What's the weather in Tokyo?")
|
|
81
|
+
print(result.final_output)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if __name__ == "__main__":
|
|
85
|
+
import argparse
|
|
86
|
+
|
|
87
|
+
parser = argparse.ArgumentParser()
|
|
88
|
+
parser.add_argument(
|
|
89
|
+
"-t",
|
|
90
|
+
"--tool-use-behavior",
|
|
91
|
+
type=str,
|
|
92
|
+
required=True,
|
|
93
|
+
choices=["default", "first_tool", "custom"],
|
|
94
|
+
help="The behavior to use for tool use. Default will cause tool outputs to be sent to the model. "
|
|
95
|
+
"first_tool_result will cause the first tool result to be used as the final output. "
|
|
96
|
+
"custom will use a custom tool use behavior function.",
|
|
97
|
+
)
|
|
98
|
+
args = parser.parse_args()
|
|
99
|
+
asyncio.run(main(args.tool_use_behavior))
|
|
@@ -74,7 +74,7 @@ multiply_agent = Agent(
|
|
|
74
74
|
|
|
75
75
|
start_agent = Agent(
|
|
76
76
|
name="Start Agent",
|
|
77
|
-
instructions="Generate a random number. If it's even, stop. If it's odd, hand off to the
|
|
77
|
+
instructions="Generate a random number. If it's even, stop. If it's odd, hand off to the multiply agent.",
|
|
78
78
|
tools=[random_number],
|
|
79
79
|
output_type=FinalResult,
|
|
80
80
|
handoffs=[multiply_agent],
|
|
@@ -3,7 +3,7 @@ from agents import Agent, Runner
|
|
|
3
3
|
agent = Agent(name="Assistant", instructions="You are a helpful assistant")
|
|
4
4
|
|
|
5
5
|
# Intended for Jupyter notebooks where there's an existing event loop
|
|
6
|
-
result = await Runner.run(agent, "Write a haiku about recursion in programming.")
|
|
6
|
+
result = await Runner.run(agent, "Write a haiku about recursion in programming.") # type: ignore[top-level-await] # noqa: F704
|
|
7
7
|
print(result.final_output)
|
|
8
8
|
|
|
9
9
|
# Code within code loops,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
|
|
5
|
+
from agents import Agent, Runner, function_tool
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Weather(BaseModel):
|
|
9
|
+
city: str
|
|
10
|
+
temperature_range: str
|
|
11
|
+
conditions: str
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@function_tool
|
|
15
|
+
def get_weather(city: str) -> Weather:
|
|
16
|
+
print("[debug] get_weather called")
|
|
17
|
+
return Weather(city=city, temperature_range="14-20C", conditions="Sunny with wind.")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
agent = Agent(
|
|
21
|
+
name="Hello world",
|
|
22
|
+
instructions="You are a helpful agent.",
|
|
23
|
+
tools=[get_weather],
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
async def main():
|
|
28
|
+
result = await Runner.run(agent, input="What's the weather in Tokyo?")
|
|
29
|
+
print(result.final_output)
|
|
30
|
+
# The weather in Tokyo is sunny.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if __name__ == "__main__":
|
|
34
|
+
asyncio.run(main())
|
|
@@ -60,9 +60,9 @@ async def main():
|
|
|
60
60
|
|
|
61
61
|
print("Step 1 done")
|
|
62
62
|
|
|
63
|
-
# 2. Ask it to
|
|
63
|
+
# 2. Ask it to generate a number
|
|
64
64
|
result = await Runner.run(
|
|
65
|
-
|
|
65
|
+
first_agent,
|
|
66
66
|
input=result.to_input_list()
|
|
67
67
|
+ [{"content": "Can you generate a random number between 0 and 100?", "role": "user"}],
|
|
68
68
|
)
|
|
@@ -60,9 +60,9 @@ async def main():
|
|
|
60
60
|
|
|
61
61
|
print("Step 1 done")
|
|
62
62
|
|
|
63
|
-
# 2. Ask it to
|
|
63
|
+
# 2. Ask it to generate a number
|
|
64
64
|
result = await Runner.run(
|
|
65
|
-
|
|
65
|
+
first_agent,
|
|
66
66
|
input=result.to_input_list()
|
|
67
67
|
+ [{"content": "Can you generate a random number between 0 and 100?", "role": "user"}],
|
|
68
68
|
)
|
{openai_agents-0.0.4 → openai_agents-0.0.5}/examples/model_providers/custom_example_agent.py
RENAMED
|
@@ -3,7 +3,7 @@ import os
|
|
|
3
3
|
|
|
4
4
|
from openai import AsyncOpenAI
|
|
5
5
|
|
|
6
|
-
from agents import Agent, OpenAIChatCompletionsModel, Runner, set_tracing_disabled
|
|
6
|
+
from agents import Agent, OpenAIChatCompletionsModel, Runner, function_tool, set_tracing_disabled
|
|
7
7
|
|
|
8
8
|
BASE_URL = os.getenv("EXAMPLE_BASE_URL") or ""
|
|
9
9
|
API_KEY = os.getenv("EXAMPLE_API_KEY") or ""
|
|
@@ -32,18 +32,22 @@ set_tracing_disabled(disabled=True)
|
|
|
32
32
|
# Runner.run(agent, ..., run_config=RunConfig(model_provider=PROVIDER))
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
@function_tool
|
|
36
|
+
def get_weather(city: str):
|
|
37
|
+
print(f"[debug] getting weather for {city}")
|
|
38
|
+
return f"The weather in {city} is sunny."
|
|
39
|
+
|
|
40
|
+
|
|
35
41
|
async def main():
|
|
36
42
|
# This agent will use the custom LLM provider
|
|
37
43
|
agent = Agent(
|
|
38
44
|
name="Assistant",
|
|
39
45
|
instructions="You only respond in haikus.",
|
|
40
46
|
model=OpenAIChatCompletionsModel(model=MODEL_NAME, openai_client=client),
|
|
47
|
+
tools=[get_weather],
|
|
41
48
|
)
|
|
42
49
|
|
|
43
|
-
result = await Runner.run(
|
|
44
|
-
agent,
|
|
45
|
-
"Tell me about recursion in programming.",
|
|
46
|
-
)
|
|
50
|
+
result = await Runner.run(agent, "What's the weather in Tokyo?")
|
|
47
51
|
print(result.final_output)
|
|
48
52
|
|
|
49
53
|
|
{openai_agents-0.0.4 → openai_agents-0.0.5}/examples/model_providers/custom_example_global.py
RENAMED
|
@@ -6,6 +6,7 @@ from openai import AsyncOpenAI
|
|
|
6
6
|
from agents import (
|
|
7
7
|
Agent,
|
|
8
8
|
Runner,
|
|
9
|
+
function_tool,
|
|
9
10
|
set_default_openai_api,
|
|
10
11
|
set_default_openai_client,
|
|
11
12
|
set_tracing_disabled,
|
|
@@ -40,14 +41,21 @@ set_default_openai_api("chat_completions")
|
|
|
40
41
|
set_tracing_disabled(disabled=True)
|
|
41
42
|
|
|
42
43
|
|
|
44
|
+
@function_tool
|
|
45
|
+
def get_weather(city: str):
|
|
46
|
+
print(f"[debug] getting weather for {city}")
|
|
47
|
+
return f"The weather in {city} is sunny."
|
|
48
|
+
|
|
49
|
+
|
|
43
50
|
async def main():
|
|
44
51
|
agent = Agent(
|
|
45
52
|
name="Assistant",
|
|
46
53
|
instructions="You only respond in haikus.",
|
|
47
54
|
model=MODEL_NAME,
|
|
55
|
+
tools=[get_weather],
|
|
48
56
|
)
|
|
49
57
|
|
|
50
|
-
result = await Runner.run(agent, "
|
|
58
|
+
result = await Runner.run(agent, "What's the weather in Tokyo?")
|
|
51
59
|
print(result.final_output)
|
|
52
60
|
|
|
53
61
|
|
{openai_agents-0.0.4 → openai_agents-0.0.5}/examples/model_providers/custom_example_provider.py
RENAMED
|
@@ -12,6 +12,7 @@ from agents import (
|
|
|
12
12
|
OpenAIChatCompletionsModel,
|
|
13
13
|
RunConfig,
|
|
14
14
|
Runner,
|
|
15
|
+
function_tool,
|
|
15
16
|
set_tracing_disabled,
|
|
16
17
|
)
|
|
17
18
|
|
|
@@ -47,16 +48,19 @@ class CustomModelProvider(ModelProvider):
|
|
|
47
48
|
CUSTOM_MODEL_PROVIDER = CustomModelProvider()
|
|
48
49
|
|
|
49
50
|
|
|
51
|
+
@function_tool
|
|
52
|
+
def get_weather(city: str):
|
|
53
|
+
print(f"[debug] getting weather for {city}")
|
|
54
|
+
return f"The weather in {city} is sunny."
|
|
55
|
+
|
|
56
|
+
|
|
50
57
|
async def main():
|
|
51
|
-
agent = Agent(
|
|
52
|
-
name="Assistant",
|
|
53
|
-
instructions="You only respond in haikus.",
|
|
54
|
-
)
|
|
58
|
+
agent = Agent(name="Assistant", instructions="You only respond in haikus.", tools=[get_weather])
|
|
55
59
|
|
|
56
60
|
# This will use the custom model provider
|
|
57
61
|
result = await Runner.run(
|
|
58
62
|
agent,
|
|
59
|
-
"
|
|
63
|
+
"What's the weather in Tokyo?",
|
|
60
64
|
run_config=RunConfig(model_provider=CUSTOM_MODEL_PROVIDER),
|
|
61
65
|
)
|
|
62
66
|
print(result.final_output)
|
|
@@ -64,7 +68,7 @@ async def main():
|
|
|
64
68
|
# If you uncomment this, it will use OpenAI directly, not the custom provider
|
|
65
69
|
# result = await Runner.run(
|
|
66
70
|
# agent,
|
|
67
|
-
# "
|
|
71
|
+
# "What's the weather in Tokyo?",
|
|
68
72
|
# )
|
|
69
73
|
# print(result.final_output)
|
|
70
74
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "openai-agents"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.5"
|
|
4
4
|
description = "OpenAI Agents SDK"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.9"
|
|
@@ -9,7 +9,7 @@ authors = [
|
|
|
9
9
|
{ name = "OpenAI", email = "support@openai.com" },
|
|
10
10
|
]
|
|
11
11
|
dependencies = [
|
|
12
|
-
"openai>=1.66.
|
|
12
|
+
"openai>=1.66.5",
|
|
13
13
|
"pydantic>=2.10, <3",
|
|
14
14
|
"griffe>=1.5.6, <2",
|
|
15
15
|
"typing-extensions>=4.12.2, <5",
|
|
@@ -47,6 +47,7 @@ dev = [
|
|
|
47
47
|
"mkdocstrings[python]>=0.28.0",
|
|
48
48
|
"coverage>=7.6.12",
|
|
49
49
|
"playwright==1.50.0",
|
|
50
|
+
"inline-snapshot>=0.20.7",
|
|
50
51
|
]
|
|
51
52
|
[tool.uv.workspace]
|
|
52
53
|
members = ["agents"]
|
|
@@ -116,4 +117,7 @@ filterwarnings = [
|
|
|
116
117
|
]
|
|
117
118
|
markers = [
|
|
118
119
|
"allow_call_model_methods: mark test as allowing calls to real model implementations",
|
|
119
|
-
]
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
[tool.inline-snapshot]
|
|
123
|
+
format-command="ruff format --stdin-filename {filename}"
|
|
@@ -5,7 +5,7 @@ from typing import Literal
|
|
|
5
5
|
from openai import AsyncOpenAI
|
|
6
6
|
|
|
7
7
|
from . import _config
|
|
8
|
-
from .agent import Agent
|
|
8
|
+
from .agent import Agent, ToolsToFinalOutputFunction, ToolsToFinalOutputResult
|
|
9
9
|
from .agent_output import AgentOutputSchema
|
|
10
10
|
from .computer import AsyncComputer, Button, Computer, Environment
|
|
11
11
|
from .exceptions import (
|
|
@@ -57,6 +57,7 @@ from .tool import (
|
|
|
57
57
|
ComputerTool,
|
|
58
58
|
FileSearchTool,
|
|
59
59
|
FunctionTool,
|
|
60
|
+
FunctionToolResult,
|
|
60
61
|
Tool,
|
|
61
62
|
WebSearchTool,
|
|
62
63
|
default_tool_error_function,
|
|
@@ -73,6 +74,7 @@ from .tracing import (
|
|
|
73
74
|
SpanData,
|
|
74
75
|
SpanError,
|
|
75
76
|
Trace,
|
|
77
|
+
TracingProcessor,
|
|
76
78
|
add_trace_processor,
|
|
77
79
|
agent_span,
|
|
78
80
|
custom_span,
|
|
@@ -129,14 +131,15 @@ def set_default_openai_api(api: Literal["chat_completions", "responses"]) -> Non
|
|
|
129
131
|
|
|
130
132
|
def enable_verbose_stdout_logging():
|
|
131
133
|
"""Enables verbose logging to stdout. This is useful for debugging."""
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
logger.addHandler(logging.StreamHandler(sys.stdout))
|
|
134
|
+
logger = logging.getLogger("openai.agents")
|
|
135
|
+
logger.setLevel(logging.DEBUG)
|
|
136
|
+
logger.addHandler(logging.StreamHandler(sys.stdout))
|
|
136
137
|
|
|
137
138
|
|
|
138
139
|
__all__ = [
|
|
139
140
|
"Agent",
|
|
141
|
+
"ToolsToFinalOutputFunction",
|
|
142
|
+
"ToolsToFinalOutputResult",
|
|
140
143
|
"Runner",
|
|
141
144
|
"Model",
|
|
142
145
|
"ModelProvider",
|
|
@@ -190,6 +193,7 @@ __all__ = [
|
|
|
190
193
|
"AgentUpdatedStreamEvent",
|
|
191
194
|
"StreamEvent",
|
|
192
195
|
"FunctionTool",
|
|
196
|
+
"FunctionToolResult",
|
|
193
197
|
"ComputerTool",
|
|
194
198
|
"FileSearchTool",
|
|
195
199
|
"Tool",
|
|
@@ -209,6 +213,7 @@ __all__ = [
|
|
|
209
213
|
"set_tracing_disabled",
|
|
210
214
|
"trace",
|
|
211
215
|
"Trace",
|
|
216
|
+
"TracingProcessor",
|
|
212
217
|
"SpanError",
|
|
213
218
|
"Span",
|
|
214
219
|
"SpanData",
|