-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for o3 models & update litellm (#130)
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Add support for O3 models, update `litellm`, and enhance `OpenAI` class for O-series models with new example and tests. > > - **Behavior**: > - Add `update_completion_params()` in `base.py` to allow subclasses to modify completion parameters. > - Modify `execute()` in `base.py` to use `update_completion_params()`. > - Add `is_o_series_model` and override `update_completion_params()` in `openai.py` to handle O-series models. > - **Examples**: > - Add `adaptive_article_o3.py` to demonstrate adaptive orchestrator with O3 models. > - **Dependencies**: > - Update `litellm` version to `1.59.12` in `pyproject.toml`. > - **Tests**: > - Add `api_key` to `test_flow.py` and `test_ollama.py` to ensure correct API usage. > - Update `test_flow.py` to handle new parameter updates in `OpenAI` class. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=dynamiq-ai%2Fdynamiq&utm_source=github&utm_medium=referral)<sup> for 6b675d5. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN --> --------- Co-authored-by: Vitalii Duk <[email protected]>
- Loading branch information
1 parent
da8ff61
commit 49d1f4c
Showing
7 changed files
with
195 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from dynamiq.connections import E2B as E2BConnection | ||
from dynamiq.connections import Exa, ZenRows | ||
from dynamiq.nodes.agents.orchestrators.adaptive import AdaptiveOrchestrator | ||
from dynamiq.nodes.agents.orchestrators.adaptive_manager import AdaptiveAgentManager | ||
from dynamiq.nodes.agents.react import ReActAgent | ||
from dynamiq.nodes.agents.simple import SimpleAgent | ||
from dynamiq.nodes.tools.e2b_sandbox import E2BInterpreterTool | ||
from dynamiq.nodes.tools.exa_search import ExaTool | ||
from dynamiq.nodes.tools.zenrows import ZenRowsTool | ||
from dynamiq.nodes.types import InferenceMode | ||
from examples.llm_setup import setup_llm | ||
|
||
INPUT_TASK = ( | ||
"Let's find data on optimizing " | ||
"SEO campaigns in 2025, analyze it, " | ||
"and provide predictions with calculations " | ||
"on how to improve and implement these strategies." | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
python_tool = E2BInterpreterTool( | ||
name="Code Executor", | ||
connection=E2BConnection(), | ||
) | ||
|
||
zenrows_tool = ZenRowsTool( | ||
connection=ZenRows(), | ||
name="Web Scraper", | ||
) | ||
|
||
exa_tool = ExaTool( | ||
connection=Exa(), | ||
name="Search Engine", | ||
) | ||
|
||
llm = setup_llm(model_provider="gpt", model_name="o3-mini", max_tokens=100000) | ||
|
||
agent_coding = ReActAgent( | ||
name="Coding Agent", | ||
llm=llm, | ||
tools=[python_tool], | ||
max_loops=13, | ||
inference_mode=InferenceMode.XML, | ||
) | ||
|
||
agent_web = ReActAgent( | ||
name="Web Agent", | ||
llm=llm, | ||
tools=[zenrows_tool, exa_tool], | ||
max_loops=13, | ||
inference_mode=InferenceMode.XML, | ||
) | ||
|
||
agent_reflection = SimpleAgent( | ||
name="Reflection Agent (Reviewer, Critic)", | ||
llm=llm, | ||
role=( | ||
"Analyze and review the accuracy of any results, " | ||
"including tasks, code, or data. " | ||
"Offer feedback and suggestions for improvement." | ||
), | ||
) | ||
|
||
agent_manager = AdaptiveAgentManager( | ||
llm=llm, | ||
) | ||
|
||
orchestrator = AdaptiveOrchestrator( | ||
name="Adaptive Orchestrator", | ||
agents=[agent_coding, agent_web, agent_reflection], | ||
manager=agent_manager, | ||
) | ||
|
||
result = orchestrator.run( | ||
input_data={ | ||
"input": INPUT_TASK, | ||
}, | ||
config=None, | ||
) | ||
|
||
output_content = result.output.get("content") | ||
print("RESULT") | ||
print(output_content) |
Oops, something went wrong.
49d1f4c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage Report •