-
Notifications
You must be signed in to change notification settings - Fork 330
Transit the implementation of DeepResearchAgent #2334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
joshuayao
wants to merge
2
commits into
opea-project:main
Choose a base branch
from
joshuayao:deep_research_new
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,75 @@ | ||
| # Copyright (C) 2025 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import os | ||
| from datetime import datetime | ||
| from typing import Any | ||
|
|
||
| from langchain_openai import ChatOpenAI | ||
|
|
||
|
|
||
| def create_deepagents_research_agent() -> Any: | ||
| from deepagents import create_deep_agent | ||
| from research_agents.deepagents.prompts import ( | ||
| RESEARCH_WORKFLOW_INSTRUCTIONS, | ||
| RESEARCHER_INSTRUCTIONS, | ||
| SUBAGENT_DELEGATION_INSTRUCTIONS, | ||
| ) | ||
| from research_agents.deepagents.tools import tavily_search, think_tool | ||
|
|
||
| # Limits | ||
| max_concurrent_research_units = os.environ.get("MAX_CONCURRENT_RESEARCH_UNITS", 3) | ||
| max_researcher_iterations = os.environ.get("MAX_RESEARCHER_ITERATIONS", 3) | ||
|
|
||
| # Custom instructions (if any) | ||
| instructions_researcher = os.environ.get("RESEARCHER_INSTRUCTIONS", RESEARCHER_INSTRUCTIONS) | ||
| instructions_research_workflow = os.environ.get("RESEARCH_WORKFLOW_INSTRUCTIONS", RESEARCH_WORKFLOW_INSTRUCTIONS) | ||
| instructions_subagent_delegation = os.environ.get( | ||
| "SUBAGENT_DELEGATION_INSTRUCTIONS", SUBAGENT_DELEGATION_INSTRUCTIONS | ||
| ) | ||
|
|
||
| # Combine orchestrator instructions (RESEARCHER_INSTRUCTIONS only for sub-agents) | ||
| INSTRUCTIONS = ( | ||
| instructions_research_workflow | ||
| + "\n\n" | ||
| + "=" * 80 | ||
| + "\n\n" | ||
| + instructions_subagent_delegation.format( | ||
| max_concurrent_research_units=max_concurrent_research_units, | ||
| max_researcher_iterations=max_researcher_iterations, | ||
| ) | ||
| ) | ||
|
|
||
| # Get current date | ||
| current_date = datetime.now().strftime("%Y-%m-%d") | ||
|
|
||
| # Research agent definition | ||
| research_sub_agent = { | ||
| "name": "research-agent", | ||
| "description": "Delegate research to the sub-agent researcher. Only give this researcher one topic at a time.", | ||
| "system_prompt": instructions_researcher.format(date=current_date), | ||
| "tools": [tavily_search, think_tool], | ||
| } | ||
|
|
||
| # LLM serving endpoint | ||
| model = ChatOpenAI( | ||
| openai_api_base=os.environ.get("OPENAI_BASE_URL", "http://0.0.0.0:8000/v1/"), | ||
| openai_api_key=os.environ.get("OPENAI_API_KEY", "empty-api-key"), | ||
| model_name=os.environ.get("LLM_MODEL_ID", "meta-llama/Llama-3.3-70B-Instruct"), | ||
| temperature=0.0, | ||
| ) | ||
|
|
||
| # Create the agent | ||
| return create_deep_agent( | ||
| model=model, | ||
| tools=[tavily_search, think_tool], | ||
| system_prompt=INSTRUCTIONS, | ||
| subagents=[research_sub_agent], | ||
| ) | ||
|
|
||
|
|
||
| def create_agent(impl="DeepAgents") -> Any: | ||
| if impl == "DeepAgents": | ||
| return create_deepagents_research_agent() | ||
| else: | ||
| raise ValueError(f"Unknown agent implementation: {impl}") | ||
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,8 @@ | ||
| deepagents | ||
| httpx | ||
| langchain_openai | ||
| langchain-tavily | ||
| langgraph-cli[inmem] | ||
| markdownify | ||
| rich | ||
| tavily-python |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.