Repository navigation
OpenAI agents support - #898
Conversation
… without a change to type deserialization of agent responses
|
|
||
|
|
||
| @contextmanager | ||
| def set_open_ai_agent_temporal_overrides(**kwargs): |
There was a problem hiding this comment.
If possible, let's just take typed, listed keyword args for type safety and self-documentability for any args we know about.
There was a problem hiding this comment.
I think you are right, but it will take some time. Given the urgency concerns, let's leave that for another version.
There was a problem hiding this comment.
I also agree that it would be good to do this. The SDK does already have many overloads repeating large sets of arguments; would be good to do this in a future PR.
| **kwargs: Additional arguments to pass to the TemporalOpenAIRunner constructor. | ||
| These arguments are forwarded to workflow.execute_activity_method when | ||
| executing model calls. Common options include: | ||
| - start_to_close_timeout: Maximum time for the activity to complete |
There was a problem hiding this comment.
nit: let's name this something like model_call_start_to_close_timeout so it's clear what these apply to.
There was a problem hiding this comment.
That would get a bit unwieldy applying to all the different kwargs, I think we'd be better off documenting them as a set
There was a problem hiding this comment.
The name is too ambiguous as-is. We definitely need to do something here, soon. Johann and I were brainstorming approaches.
| search_results = await self._perform_searches(search_plan) | ||
| report = await self._write_report(query, search_results) | ||
|
|
||
| print("\n\n=====REPORT=====\n\n") |
There was a problem hiding this comment.
use workflow.logger.info() instead of print, to avoid redudant prints upon replay.
There was a problem hiding this comment.
I think the effort is more to generalize taking a class like this into temporal. While it is true that the prints might not show up if you are running the workflow on a worker elsewhere, I'm hesitant to pull in a temporal dependency in this file just for logging. The print isn't really important since the result is what matters
* Added openai_agents. * added tools and trace interceptor. * Lint error fixes * Lint error fixes * Missing docstrings added. * Fixed tool serialization. * Initial test implementation * Intercept test calls to LLM * Move to optional dependency * Linting * Fixing build errors * Fixing build errors * Fixing typo * Fake API key for test, skip below 3.11 * Tools test * Move activity to a method to allow model customization without monkey patch * Change overrides to context manager * Research workflow test * Customer service and agents as tools tests. These will currently fail without a change to type deserialization of agent responses * Fix up some imports * Remove unneeded print * Doc string improvement * Execute inside sandbox * 3.9 lint error * Add activity configuration to openai overrides and activity_as_tool * Update docstrings * Updating tests * Add experimental warnings * Remove runtime warnings * Test required import for build error * Fix import * Update open_ai_data_converter.py * Remove required import * Simplify custom data converter * Replace rebuild * Add passthrough type namespaces to data converter * Check activity count in customer_service test * cleanup dataconverter imports + doc build errors * add documentation * Fix model rebuild * update for OpenAI Agents SDK release 0.0.19 * lint fixes * fixed and elaborated on README * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Spencer Judge <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Spencer Judge <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Dan Davison <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Dan Davison <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Dan Davison <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Dan Davison <[email protected]> * readme updates * Addressing PR feedback, mostly some new test validation * PR cleanup from feedback * Remove change from irrelevant file * PR cleanup * Add custom message for tool output failure * Remove commented code and unneeded sandbox statement --------- Co-authored-by: Maxim Fateev <[email protected]> Co-authored-by: Johann Schleier-Smith <[email protected]> Co-authored-by: Johann Schleier-Smith <[email protected]> Co-authored-by: Spencer Judge <[email protected]> Co-authored-by: Dan Davison <[email protected]>
* Added openai_agents. * added tools and trace interceptor. * Lint error fixes * Lint error fixes * Missing docstrings added. * Fixed tool serialization. * Initial test implementation * Intercept test calls to LLM * Move to optional dependency * Linting * Fixing build errors * Fixing build errors * Fixing typo * Fake API key for test, skip below 3.11 * Tools test * Move activity to a method to allow model customization without monkey patch * Change overrides to context manager * Research workflow test * Customer service and agents as tools tests. These will currently fail without a change to type deserialization of agent responses * Fix up some imports * Remove unneeded print * Doc string improvement * Execute inside sandbox * 3.9 lint error * Add activity configuration to openai overrides and activity_as_tool * Update docstrings * Updating tests * Add experimental warnings * Remove runtime warnings * Test required import for build error * Fix import * Update open_ai_data_converter.py * Remove required import * Simplify custom data converter * Replace rebuild * Add passthrough type namespaces to data converter * Check activity count in customer_service test * cleanup dataconverter imports + doc build errors * add documentation * Fix model rebuild * update for OpenAI Agents SDK release 0.0.19 * lint fixes * fixed and elaborated on README * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Spencer Judge <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Spencer Judge <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Dan Davison <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Dan Davison <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Dan Davison <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Dan Davison <[email protected]> * readme updates * Addressing PR feedback, mostly some new test validation * PR cleanup from feedback * Remove change from irrelevant file * PR cleanup * Add custom message for tool output failure * Remove commented code and unneeded sandbox statement --------- Co-authored-by: Maxim Fateev <[email protected]> Co-authored-by: Johann Schleier-Smith <[email protected]> Co-authored-by: Johann Schleier-Smith <[email protected]> Co-authored-by: Spencer Judge <[email protected]> Co-authored-by: Dan Davison <[email protected]> Migrated-From: temporalio/sdk-python@53d9ace
* Added openai_agents. * added tools and trace interceptor. * Lint error fixes * Lint error fixes * Missing docstrings added. * Fixed tool serialization. * Initial test implementation * Intercept test calls to LLM * Move to optional dependency * Linting * Fixing build errors * Fixing build errors * Fixing typo * Fake API key for test, skip below 3.11 * Tools test * Move activity to a method to allow model customization without monkey patch * Change overrides to context manager * Research workflow test * Customer service and agents as tools tests. These will currently fail without a change to type deserialization of agent responses * Fix up some imports * Remove unneeded print * Doc string improvement * Execute inside sandbox * 3.9 lint error * Add activity configuration to openai overrides and activity_as_tool * Update docstrings * Updating tests * Add experimental warnings * Remove runtime warnings * Test required import for build error * Fix import * Update open_ai_data_converter.py * Remove required import * Simplify custom data converter * Replace rebuild * Add passthrough type namespaces to data converter * Check activity count in customer_service test * cleanup dataconverter imports + doc build errors * add documentation * Fix model rebuild * update for OpenAI Agents SDK release 0.0.19 * lint fixes * fixed and elaborated on README * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Spencer Judge <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Spencer Judge <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Dan Davison <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Dan Davison <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Dan Davison <[email protected]> * Update temporalio/contrib/openai_agents/README.md Co-authored-by: Dan Davison <[email protected]> * readme updates * Addressing PR feedback, mostly some new test validation * PR cleanup from feedback * Remove change from irrelevant file * PR cleanup * Add custom message for tool output failure * Remove commented code and unneeded sandbox statement --------- Co-authored-by: Maxim Fateev <[email protected]> Co-authored-by: Johann Schleier-Smith <[email protected]> Co-authored-by: Johann Schleier-Smith <[email protected]> Co-authored-by: Spencer Judge <[email protected]> Co-authored-by: Dan Davison <[email protected]> Migrated-From: temporalio/sdk-python@53d9ace
What was changed
Added an experimental
contribmodule to provide compatibility with the OpenAI Agents SDK.Why?
To facilitate durable execution for applications built with the OpenAI Agents SDK
Checklist
Closes
How was this tested:
Tests provided in
tests/contrib/test_openai.pyAny docs updates needed?
README provided. Further updates to the documentation are on hold while this code remains experimental.