openai-agents-python/mkdocs.yml
Rohan Mehta dd881eed9a
feat: Add Graphviz-based agent visualization functionality (#147)
This pull request introduces functionality for visualizing agent
structures using Graphviz. The changes include adding a new dependency,
implementing functions to generate and draw graphs, and adding tests for
these functions.

New functionality for visualizing agent structures:

* Added `graphviz` as a new dependency in `pyproject.toml`.
* Implemented functions in `src/agents/visualizations.py` to generate
and draw graphs for agents using Graphviz. These functions include
`get_main_graph`, `get_all_nodes`, `get_all_edges`, and `draw_graph`.

Testing the new visualization functionality:

* Added tests in `tests/test_visualizations.py` to verify the
correctness of the graph generation and drawing functions. The tests
cover `get_main_graph`, `get_all_nodes`, `get_all_edges`, and
`draw_graph`.

For example, given the following code:

```python
from agents import Agent, function_tool
from agents.visualizations import draw_graph


@function_tool
def get_weather(city: str) -> str:
    return f"The weather in {city} is sunny."


spanish_agent = Agent(
    name="Spanish agent",
    instructions="You only speak Spanish.",
)

english_agent = Agent(
    name="English agent",
    instructions="You only speak English",
)

triage_agent = Agent(
    name="Triage agent",
    instructions="Handoff to the appropriate agent based on the language of the request.",
    handoffs=[spanish_agent, english_agent],
    tools=[get_weather],
)


draw_graph(triage_agent)
```

Generates the following image:

<img width="614" alt="Screenshot 2025-03-13 at 18 36 23"
src="https://github.com/user-attachments/assets/d01fe502-6886-4efb-aaf8-c92e4524b0fe"
/>
2025-03-25 19:22:58 -04:00

149 lines
3.9 KiB
YAML

site_name: OpenAI Agents SDK
theme:
name: material
features:
# Allows copying code blocks
- content.code.copy
# Allows selecting code blocks
- content.code.select
# Shows the current path in the sidebar
- navigation.path
# Shows sections in the sidebar
- navigation.sections
# Shows sections expanded by default
- navigation.expand
# Enables annotations in code blocks
- content.code.annotate
palette:
primary: black
logo: assets/logo.svg
favicon: images/favicon-platform.svg
nav:
- Intro: index.md
- Quickstart: quickstart.md
- Examples: examples.md
- Documentation:
- agents.md
- running_agents.md
- results.md
- streaming.md
- tools.md
- mcp.md
- handoffs.md
- tracing.md
- context.md
- guardrails.md
- multi_agent.md
- models.md
- config.md
- visualization.md
- Voice agents:
- voice/quickstart.md
- voice/pipeline.md
- voice/tracing.md
- API Reference:
- Agents:
- ref/index.md
- ref/agent.md
- ref/run.md
- ref/tool.md
- ref/result.md
- ref/stream_events.md
- ref/handoffs.md
- ref/lifecycle.md
- ref/items.md
- ref/run_context.md
- ref/usage.md
- ref/exceptions.md
- ref/guardrail.md
- ref/model_settings.md
- ref/agent_output.md
- ref/function_schema.md
- ref/models/interface.md
- ref/models/openai_chatcompletions.md
- ref/models/openai_responses.md
- ref/mcp/server.md
- ref/mcp/util.md
- Tracing:
- ref/tracing/index.md
- ref/tracing/create.md
- ref/tracing/traces.md
- ref/tracing/spans.md
- ref/tracing/processor_interface.md
- ref/tracing/processors.md
- ref/tracing/scope.md
- ref/tracing/setup.md
- ref/tracing/span_data.md
- ref/tracing/util.md
- Voice:
- ref/voice/pipeline.md
- ref/voice/workflow.md
- ref/voice/input.md
- ref/voice/result.md
- ref/voice/pipeline_config.md
- ref/voice/events.md
- ref/voice/exceptions.md
- ref/voice/model.md
- ref/voice/utils.md
- ref/voice/models/openai_provider.md
- ref/voice/models/openai_stt.md
- ref/voice/models/openai_tts.md
- Extensions:
- ref/extensions/handoff_filters.md
- ref/extensions/handoff_prompt.md
plugins:
- search
- mkdocstrings:
handlers:
python:
paths: ["src/agents"]
selection:
docstring_style: google
options:
# Shows links to other members in signatures
signature_crossrefs: true
# Orders members by source order, rather than alphabetical
members_order: source
# Puts the signature on a separate line from the member name
separate_signature: true
# Shows type annotations in signatures
show_signature_annotations: true
# Makes the font sizes nicer
heading_level: 3
# Show inherited members
inherited_members: true
extra:
# Remove material generation message in footer
generator: false
markdown_extensions:
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format
- admonition
- pymdownx.details
- attr_list
- md_in_html
- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences
validation:
omitted_files: warn
absolute_links: warn
unrecognized_links: warn
anchors: warn
extra_css:
- stylesheets/extra.css
watch:
- "src/agents"