Skip to content

Commit f13cd21

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 836c0be commit f13cd21

File tree

9 files changed

+39
-36
lines changed

9 files changed

+39
-36
lines changed

DeepResearchAgent/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Deep Research Agents are a new class of autonomous AI systems designed to perfor
66

77
In this application, we leverage the deep research agent implementation of [langchain-ai/deepagents](https://github.com/langchain-ai/deepagents), and deploy it on the Intel platform with opea microserice.
88

9-
109
## Setup Deployment Environment
1110

1211
```shell

DeepResearchAgent/agent_factory.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
14
import os
25
from datetime import datetime
36
from typing import Any
7+
48
from langchain_openai import ChatOpenAI
59

610

711
def create_deepagents_research_agent() -> Any:
812
from deepagents import create_deep_agent
913
from research_agents.deepagents.prompts import (
10-
RESEARCHER_INSTRUCTIONS,
1114
RESEARCH_WORKFLOW_INSTRUCTIONS,
15+
RESEARCHER_INSTRUCTIONS,
1216
SUBAGENT_DELEGATION_INSTRUCTIONS,
1317
)
1418
from research_agents.deepagents.tools import tavily_search, think_tool
@@ -18,9 +22,11 @@ def create_deepagents_research_agent() -> Any:
1822
max_researcher_iterations = os.environ.get("MAX_RESEARCHER_ITERATIONS", 3)
1923

2024
# Custom instructions (if any)
21-
instructions_researcher=os.environ.get("RESEARCHER_INSTRUCTIONS", RESEARCHER_INSTRUCTIONS)
22-
instructions_research_workflow=os.environ.get("RESEARCH_WORKFLOW_INSTRUCTIONS", RESEARCH_WORKFLOW_INSTRUCTIONS)
23-
instructions_subagent_delegation=os.environ.get("SUBAGENT_DELEGATION_INSTRUCTIONS", SUBAGENT_DELEGATION_INSTRUCTIONS)
25+
instructions_researcher = os.environ.get("RESEARCHER_INSTRUCTIONS", RESEARCHER_INSTRUCTIONS)
26+
instructions_research_workflow = os.environ.get("RESEARCH_WORKFLOW_INSTRUCTIONS", RESEARCH_WORKFLOW_INSTRUCTIONS)
27+
instructions_subagent_delegation = os.environ.get(
28+
"SUBAGENT_DELEGATION_INSTRUCTIONS", SUBAGENT_DELEGATION_INSTRUCTIONS
29+
)
2430

2531
# Combine orchestrator instructions (RESEARCHER_INSTRUCTIONS only for sub-agents)
2632
INSTRUCTIONS = (
@@ -33,7 +39,7 @@ def create_deepagents_research_agent() -> Any:
3339
max_researcher_iterations=max_researcher_iterations,
3440
)
3541
)
36-
42+
3743
# Get current date
3844
current_date = datetime.now().strftime("%Y-%m-%d")
3945

@@ -50,17 +56,18 @@ def create_deepagents_research_agent() -> Any:
5056
openai_api_base=os.environ.get("OPENAI_BASE_URL", "http://0.0.0.0:8000/v1/"),
5157
openai_api_key=os.environ.get("OPENAI_API_KEY", "empty-api-key"),
5258
model_name=os.environ.get("LLM_MODEL_ID", "meta-llama/Llama-3.3-70B-Instruct"),
53-
temperature=0.0
59+
temperature=0.0,
5460
)
55-
61+
5662
# Create the agent
5763
return create_deep_agent(
5864
model=model,
5965
tools=[tavily_search, think_tool],
6066
system_prompt=INSTRUCTIONS,
6167
subagents=[research_sub_agent],
6268
)
63-
69+
70+
6471
def create_agent(impl="DeepAgents") -> Any:
6572
if impl == "DeepAgents":
6673
return create_deepagents_research_agent()

DeepResearchAgent/docker_compose/intel/hpu/gaudi/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ services:
5656
MAX_RESEARCHER_ITERATIONS: ${MAX_RESEARCHER_ITERATIONS:-3}
5757
RESEARCHER_INSTRUCTIONS: ${RESEARCHER_INSTRUCTIONS:-""}
5858
RESEARCH_WORKFLOW_INSTRUCTIONS: ${RESEARCH_WORKFLOW_INSTRUCTIONS:-""}
59-
SUBAGENT_DELEGATION_INSTRUCTIONS: ${SUBAGENT_DELEGATION_INSTRUCTIONS:-""}
59+
SUBAGENT_DELEGATION_INSTRUCTIONS: ${SUBAGENT_DELEGATION_INSTRUCTIONS:-""}

DeepResearchAgent/docker_compose/intel/hpu/gaudi/set_env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,4 @@ export MAX_RESEARCHER_ITERATIONS="${MAX_RESEARCHER_ITERATIONS:-3}"
101101
# Custom instructions for agent behavior (leave empty for defaults)
102102
export RESEARCHER_INSTRUCTIONS="" # Instructions for individual researchers
103103
export RESEARCH_WORKFLOW_INSTRUCTIONS="" # Instructions for overall research workflow
104-
export SUBAGENT_DELEGATION_INSTRUCTIONS="" # Instructions for task delegation between agents
104+
export SUBAGENT_DELEGATION_INSTRUCTIONS="" # Instructions for task delegation between agents

DeepResearchAgent/research_agent.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Copyright (C) 2024 Intel Corporation
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import os
54
import logging
5+
import os
66
from typing import List, Union
7-
from comps import opea_microservices, register_microservice, CustomLogger
8-
from comps.cores.telemetry.opea_telemetry import opea_telemetry
9-
from pydantic import BaseModel
107

118
from agent_factory import create_agent
9+
from comps import CustomLogger, opea_microservices, register_microservice
10+
from comps.cores.telemetry.opea_telemetry import opea_telemetry
11+
from pydantic import BaseModel
1212
from research_agents.deepagents.utils import format_message
1313

1414
logger = CustomLogger(__name__)
@@ -30,10 +30,10 @@ class SimpleRequest(BaseModel):
3030
async def run(request: SimpleRequest):
3131

3232
logger.debug(f"Received question: {request.question}")
33-
33+
3434
logger.debug("Creating DeepAgents research agent...")
3535
agent = create_agent(impl="DeepAgents")
36-
36+
3737
logger.debug("Invoking agent with the provided question...")
3838
result = agent.invoke(
3939
{
@@ -43,12 +43,12 @@ async def run(request: SimpleRequest):
4343
"content": f"Question: {request.question}",
4444
}
4545
],
46-
},
46+
},
4747
)
4848
logger.debug("Agent invocation completed.")
4949
if os.getenv("LOGFLAG", "").lower() == "true":
5050
format_message(result["messages"])
51-
51+
5252
return {"answer": result["messages"][-1].content}
5353

5454

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Deep Research Agent of DeepAgents
2-
The code is from LangChain [DeepAgents](https://github.com/langchain-ai/deepagents-quickstarts/tree/main/deep_research).
2+
3+
The code is from LangChain [DeepAgents](https://github.com/langchain-ai/deepagents-quickstarts/tree/main/deep_research).

DeepResearchAgent/research_agents/deepagents/prompts.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
13
"""Prompt templates and tool descriptions for the research deepagent."""
24

35
RESEARCH_WORKFLOW_INSTRUCTIONS = """# Research Workflow
@@ -68,7 +70,7 @@
6870
6971
<Task>
7072
Your job is to use tools to gather information about the user's input topic.
71-
You can use any of the research tools provided to you to find resources that can help answer the research question.
73+
You can use any of the research tools provided to you to find resources that can help answer the research question.
7274
You can call these tools in series or in parallel, your research is conducted in a tool-calling loop.
7375
</Task>
7476
@@ -170,4 +172,4 @@
170172
## Research Limits
171173
- Stop after {max_researcher_iterations} delegation rounds if you haven't found adequate sources
172174
- Stop when you have sufficient information to answer comprehensively
173-
- Bias towards focused research over exhaustive exploration"""
175+
- Bias towards focused research over exhaustive exploration"""

DeepResearchAgent/research_agents/deepagents/tools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
13
"""Research Tools.
24
35
This module provides search and content processing utilities for the research agent,
@@ -39,9 +41,7 @@ def fetch_webpage_content(url: str, timeout: float = 10.0) -> str:
3941
def tavily_search(
4042
query: str,
4143
max_results: Annotated[int, InjectedToolArg] = 1,
42-
topic: Annotated[
43-
Literal["general", "news", "finance"], InjectedToolArg
44-
] = "general",
44+
topic: Annotated[Literal["general", "news", "finance"], InjectedToolArg] = "general",
4545
) -> str:
4646
"""Search the web for information on a given query.
4747

DeepResearchAgent/research_agents/deepagents/utils.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
13
"""Utility functions for displaying messages and prompts in Jupyter notebooks."""
24

35
import json
@@ -31,11 +33,7 @@ def format_message_content(message):
3133
parts.append(str(message.content))
3234

3335
# Handle tool calls attached to the message (OpenAI format) - only if not already processed
34-
if (
35-
not tool_calls_processed
36-
and hasattr(message, "tool_calls")
37-
and message.tool_calls
38-
):
36+
if not tool_calls_processed and hasattr(message, "tool_calls") and message.tool_calls:
3937
for tool_call in message.tool_calls:
4038
parts.append(f"\n🔧 Tool Call: {tool_call['name']}")
4139
parts.append(f" Args: {json.dumps(tool_call['args'], indent=2)}")
@@ -76,12 +74,8 @@ def show_prompt(prompt_text: str, title: str = "Prompt", border_style: str = "bl
7674
# Create a formatted display of the prompt
7775
formatted_text = Text(prompt_text)
7876
formatted_text.highlight_regex(r"<[^>]+>", style="bold blue") # Highlight XML tags
79-
formatted_text.highlight_regex(
80-
r"##[^#\n]+", style="bold magenta"
81-
) # Highlight headers
82-
formatted_text.highlight_regex(
83-
r"###[^#\n]+", style="bold cyan"
84-
) # Highlight sub-headers
77+
formatted_text.highlight_regex(r"##[^#\n]+", style="bold magenta") # Highlight headers
78+
formatted_text.highlight_regex(r"###[^#\n]+", style="bold cyan") # Highlight sub-headers
8579

8680
# Display in a panel for better presentation
8781
console.print(

0 commit comments

Comments
 (0)