Commit Graph

352 Commits

Author SHA1 Message Date
Víctor Mayoral Vilches 0877dfda81 Address issues with litellm and agents SDK
Squeezed in some additional features such as:
- updated get_version()
- various examples for streaming and non-streaming testing

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-04-02 14:03:00 +02:00
Víctor Mayoral Vilches 7cda5445a4 Fix issue with instructions
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-04-02 07:28:27 +02:00
Víctor Mayoral Vilches 69abd9e1d1 OLLAMA models working
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-31 21:13:15 +02:00
Víctor Mayoral Vilches d1fd6623e5 Merge remote-tracking branch 'origin/main' into cai 2025-03-31 13:21:34 +02:00
Eric Peter e891dfc314 Databricks MLflow tracing integration (#401) 2025-03-30 23:53:09 -04:00
Víctor Mayoral Vilches aef3f5e73c Streaming now working for OLLAMA models, but not the rest. Figure it out
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-30 09:21:25 +02:00
Víctor Mayoral Vilches cff20480b7 Made local models work by switching into litellm python APIs
Still some issues with stream versions which needs further
investigation

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-29 20:17:42 +01:00
Víctor Mayoral Vilches 944128583c CLI responding, but only to proprietary models
Need to investigate why self-hosted models via OLLAMA fail API-wise

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-28 09:48:16 +01:00
Víctor Mayoral Vilches f0b93aec91 Fix paths in docs
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-28 08:35:25 +01:00
Víctor Mayoral Vilches d2d2ce535d Address error while streaming
[Error occurred during streaming: 1 validation error for ResponseUsage
input_tokens_details
  Input should be a valid dictionary or instance of InputTokensDetails [type=model_type, input_value=InputTokensDetails(prompt...ens=17, cached_tokens=0), input_type=InputTokensDetails]
    For further information visit https://errors.pydantic.dev/2.10/v/model_type]
Location: Traceback (most recent call last):
  File /Users/alias/Alias/research/openai-agents-python/src/cai/cli.py, line 209, in process_streamed_response
    async for event in result.stream_events():
  File /Users/alias/Alias/research/openai-agents-python/src/cai/sdk/agents/result.py, line 186, in stream_events
    raise self._stored_exception
  File /Users/alias/Alias/research/openai-agents-python/src/cai/sdk/agents/run.py, line 539, in _run_streamed_impl
    turn_result = await cls._run_single_turn_streamed(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File /Users/alias/Alias/research/openai-agents-python/src/cai/sdk/agents/run.py, line 641, in _run_single_turn_streamed
    async for event in model.stream_response(
  File /Users/alias/Alias/research/openai-agents-python/src/cai/sdk/agents/models/openai_chatcompletions.py, line 421, in stream_response
    ResponseUsage(
  File /Users/alias/Alias/research/openai-agents-python/env/lib/python3.12/site-packages/pydantic/main.py, line 214, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ResponseUsage
input_tokens_details
  Input should be a valid dictionary or instance of InputTokensDetails [type=model_type, input_value=InputTokensDetails(prompt...ens=17, cached_tokens=0), input_type=InputTokensDetails]
    For further information visit https://errors.pydantic.dev/2.10/v/model_type

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-28 08:35:11 +01:00
Víctor Mayoral Vilches f18e659ec8 Fix docs
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-28 07:55:41 +01:00
Ali Waleed 4c40fec70f Add Langtrace to `tracing.md` (#371) 2025-03-27 21:33:49 -04:00
Víctor Mayoral Vilches 1a22013bda Advanced aligning agents but various missing bits:
- agents can't translate directly it seems, see current error
- in addition, it appears streaming mode leads to other problems

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-27 19:36:58 +01:00
Martin Jagusch a7a814d30d Remove duplicate dependency definition of pynput (#367)
`pynput` is in the pyproject.toml file twice, as you can see on line 54.

The uv.lock file doesn't change.
2025-03-27 13:40:06 -04:00
amri369 1683606b6f Hotfix mcp example (#365)
Small typo in uv command fixed
2025-03-27 13:05:30 -04:00
Víctor Mayoral Vilches 326c3274fc Add blue team agent
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-27 15:14:35 +01:00
Víctor Mayoral Vilches 887c2fb319 Add tools, prompts and agents
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-27 15:06:12 +01:00
Víctor Mayoral Vilches ac4797cec6 Re-structure under sdk/agents, get CLI mockup
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-27 14:31:38 +01:00
Steven Heidel d1e94324e8 Expose the "store" parameter through ModelSettings (#357)
Closes https://github.com/openai/openai-agents-python/issues/173

This will also set stored completions to True by default, encouraging a
best practice.
2025-03-26 19:01:28 -04:00
Rohan Mehta 5ff0baddc3 Raise error on more invalid function schemas (#356)
Towards #345

## Summary:
Using a `dict` or `Mapping` isn't strict-mode compliant. But we were
checking for the literal `True` whereas the value can also be an array,
for example. Fix that.

## Test Plan:

Unit tests
2025-03-26 15:52:19 -04:00
Rohan Mehta 1c8e9a55db Tracing screenshot for MCP docs (#355) 2025-03-26 10:56:34 -07:00
Víctor Mayoral Vilches 21048444c6 Minor changes for alignment
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-26 18:55:21 +01:00
Rohan Mehta aeda40c10f MCP example for SSE (#354)
Simple example with a local SSE server.
2025-03-26 12:56:35 -04:00
Rohan Mehta fe42548cce v0.0.7 (#353)
Upgrade version to prepare for a new release.
2025-03-26 09:06:24 -07:00
pakrym-oai 0fa5849839 Mark handoff span as errored when multiple handoffs are requested (#344)
Also includes the set of requested agents in the error data.
<img width="968" alt="image"
src="https://github.com/user-attachments/assets/0c5c2e81-08f7-445c-bbb0-3e169ef744a5"
/>
2025-03-26 10:44:59 -04:00
Víctor Mayoral Vilches adb358baae Update docs to integrate CAI, minor refinements
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-26 12:41:45 +01:00
Rohan Mehta 013d8ae9d2 Adding Git MCP server example (#343)
- Adding new example showing a single agent interacting with local MCP
server for git
2025-03-25 19:54:59 -04:00
Rohan Mehta b870b90471 [5/n] MCP tracing (#342)
## Summary:

Adds tracing and tests for tracing.
- Tools are added to the agents
- Theres a span for the mcp tools lookup
- Functions have MCP data

## Test Plan:

Unit tests
.
2025-03-25 19:54:28 -04:00
Dmitry Pimenov d53411ba6a added readme, fixed typo 2025-03-25 16:52:52 -07:00
Dmitry Pimenov 3587502c69 fixing lint issues 2025-03-25 16:34:00 -07:00
Dmitry Pimenov 788b4faba6 adding Git MCP server example 2025-03-25 16:30:50 -07:00
Rohan Mehta 6cb8b1ceaa [5/n] MCP tracing
## Summary:

Adds tracing and tests for tracing.
- Tools are added to the agents
- Theres a span for the mcp tools lookup
- Functions have MCP data

## Test Plan:

Unit tests
.
2025-03-25 19:28:48 -04:00
Rohan Mehta 4c93a5d9b1 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
Rohan Mehta 4bb8f385b8 fix(examples): make sure audio playback finishes (#340)
Previously the stream was closing as soon as all the audio was added but
didn't wait for it to be finished. Additionally the audio might seem
chopped off if there is no additional silence so this PR also adds one
second of silence before exiting the program.
2025-03-25 15:22:55 -04:00
Dominik Kundel d639ebdf91 fix(examples): make sure audio playback finishes 2025-03-25 12:11:33 -07:00
Martín Bravo 58967dcf14 Remove Jupyter Notebook files from .gitignore 2025-03-25 19:31:32 +01:00
Martín Bravo 3f439484fd linting 2025-03-25 19:18:57 +01:00
Martín Bravo c6e8f4c0ff Fix type ignore comment for agent check in get_all_edges function 2025-03-25 19:17:35 +01:00
Martín Bravo dc3093bab3 Refactor visualization functions to improve formatting and streamline edge generation 2025-03-25 19:12:40 +01:00
Martín Bravo b5f6544f6f Add start and end nodes to graph visualization and update edge generation 2025-03-25 19:11:43 +01:00
Martín Bravo cf993012f5 Add Jupyter Notebook files to .gitignore 2025-03-25 19:03:39 +01:00
Martín Bravo d9a4f96ecb Refactor get_all_edges function to remove unused parent parameter 2025-03-25 19:02:21 +01:00
Martín Bravo 650d151314 Add visualization.md to navigation in mkdocs.yml 2025-03-25 18:56:01 +01:00
Martín Bravo c988fd4aaf Add graphviz as a dependency and update import statements 2025-03-25 18:46:23 +01:00
Rohan Mehta bde8969892 Update pyproject.toml 2025-03-25 13:37:01 -04:00
Rohan Mehta db13026c0e Update visualization.md 2025-03-25 13:34:45 -04:00
Rohan Mehta 10dcb40226 Make the reset behavior on tool use configurable (#335)
## Summary:

#263 added this behavior. The goal was to prevent infinite loops when
tool choice was set. The key change I'm making is:
1. Making it configurable on the agent.
2. Doing bookkeeping in the Runner to track this, to prevent mutating
agents.
3. Not resetting the global tool choice in RunConfig.

## Test Plan:
Unit tests.
.
2025-03-25 13:30:32 -04:00
Martín Bravo 8ba7b0932f Update installation instructions for visualization dependency to use 'viz' 2025-03-25 18:29:55 +01:00
Rohan Mehta 944b730da9 Make the reset behavior on tool use configurable
## Summary:

#263 added this behavior. The goal was to prevent infinite loops when tool choice was set. The key change I'm making is:
1. Making it configurable on the agent.
2. Doing bookkeeping in the Runner to track this, to prevent mutating agents.
3. Not resetting the global tool choice in RunConfig.

## Test Plan:
Unit tests.
.
2025-03-25 13:29:32 -04:00
Rohan Mehta 0856c328d3 [4/n] Add docs for MCP (#338)
Just adding docs.

(Repeat of #324)
2025-03-25 13:27:15 -04:00