Skip to content

Commit 5f7ed6a

Browse files
Merge pull request BrainBlend-AI#121 from duf59/documentation/web-search-example-improvements
Documentation/web search example improvements
2 parents df96141 + 89a2cee commit 5f7ed6a

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

atomic-examples/web-search-agent/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ To run the Web Search Agent:
4343
OPENAI_API_KEY=your_openai_api_key
4444
SEARXNG_BASE_URL=your_searxng_instance_url
4545
```
46-
Replace `your_openai_api_key` with your actual OpenAI API key and `your_searxng_instance_url` with the URL of your SearxNG instance.
46+
Replace `your_openai_api_key` with your actual OpenAI API key and `your_searxng_instance_url` with the URL of your SearxNG instance.
47+
If you do not have a SearxNG instance, see the instructions below to set up one locally with docker.
48+
4749

4850
5. Run the Web Search Agent:
4951
```
@@ -58,6 +60,30 @@ To run the Web Search Agent:
5860
4. The Question Answering Agent analyzes the search results and formulates a detailed answer.
5961
5. The main script presents the answer, along with references and follow-up questions.
6062

63+
## SearxNG Setup with docker
64+
65+
From the [official instructions](https://docs.searxng.org/admin/installation-docker.html):
66+
67+
```shell
68+
mkdir my-instance
69+
cd my-instance
70+
export PORT=8080
71+
docker pull searxng/searxng
72+
docker run --rm \
73+
-d -p ${PORT}:8080 \
74+
-v "${PWD}/searxng:/etc/searxng" \
75+
-e "BASE_URL=http://localhost:$PORT/" \
76+
-e "INSTANCE_NAME=my-instance" \
77+
searxng/searxng
78+
```
79+
80+
Set the `SEARXNG_BASE_URL` environment variable to `http://localhost:8080/` in your `.env` file.
81+
82+
83+
Note: for the agent to communicate with SearxNG, the instance must enable the JSON engine, which is disabled by default.
84+
Edit `searxng/settings.yml` and add `- json` in the `search.formats` section, then restart the container.
85+
86+
6187
## Customization
6288

6389
You can customize the Web Search Agent by modifying the following:

atomic-examples/web-search-agent/web_search_agent/agents/query_agent.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator
66

77
from web_search_agent.tools.searxng_search import SearxNGSearchTool
8+
import dotenv
9+
10+
dotenv.load_dotenv()
811

912

1013
class QueryAgentInputSchema(BaseIOSchema):

atomic-examples/web-search-agent/web_search_agent/main.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from rich.console import Console
44
from rich.markdown import Markdown
55

6-
from atomic_agents.agents.base_agent import BaseAgent, BaseAgentConfig
76
from atomic_agents.lib.components.agent_memory import AgentMemory
87
from atomic_agents.lib.components.system_prompt_generator import SystemPromptContextProviderBase
98

@@ -16,8 +15,6 @@
1615
from web_search_agent.agents.query_agent import QueryAgentInputSchema, query_agent
1716
from web_search_agent.agents.question_answering_agent import question_answering_agent, QuestionAnsweringAgentInputSchema
1817

19-
import openai
20-
import instructor
2118

2219
load_dotenv()
2320

@@ -30,15 +27,6 @@
3027
# Initialize the SearxNGSearchTool
3128
search_tool = SearxNGSearchTool(config=SearxNGSearchToolConfig(base_url=os.getenv("SEARXNG_BASE_URL"), max_results=5))
3229

33-
# Initialize the BaseAgent
34-
agent = BaseAgent(
35-
config=BaseAgentConfig(
36-
client=instructor.from_openai(openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY"))),
37-
model="gpt-4o-mini",
38-
memory=memory,
39-
)
40-
)
41-
4230
# Example usage
4331
instruction = "Tell me about the Atomic Agents AI agent framework."
4432
num_queries = 3

0 commit comments

Comments
 (0)