Spaces:
Runtime error
Runtime error
Add README
Browse files
README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Search Engine Tool Agent
|
| 2 |
+
|
| 3 |
+
A conversational AI chatbot built with **Streamlit** and **LangChain** that can search the web, Wikipedia, and Arxiv to answer your questions.
|
| 4 |
+
|
| 5 |
+
## Features
|
| 6 |
+
|
| 7 |
+
- **Multi-tool agent** powered by LangChain's ReAct architecture
|
| 8 |
+
- **DuckDuckGo Search** for general web queries
|
| 9 |
+
- **Wikipedia** for encyclopedic knowledge
|
| 10 |
+
- **Arxiv** for scientific papers and research
|
| 11 |
+
- **Chat interface** with conversation history
|
| 12 |
+
- **Transparent reasoning** — expandable steps show the agent's thinking process and tool calls
|
| 13 |
+
|
| 14 |
+
## Tech Stack
|
| 15 |
+
|
| 16 |
+
- **Streamlit** — Web UI and chat interface
|
| 17 |
+
- **LangChain / LangGraph** — Agent orchestration and tool management
|
| 18 |
+
- **OpenAI GPT** — Language model (easily swappable with Groq/Ollama)
|
| 19 |
+
- **LangSmith** — Optional tracing and monitoring
|
| 20 |
+
|
| 21 |
+
## Setup
|
| 22 |
+
|
| 23 |
+
### 1. Clone the repository
|
| 24 |
+
|
| 25 |
+
```bash
|
| 26 |
+
git clone https://github.com/ftn03/SearchEngineToolAgent.git
|
| 27 |
+
cd SearchEngineToolAgent
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
### 2. Install dependencies
|
| 31 |
+
|
| 32 |
+
```bash
|
| 33 |
+
pip install -r requirements.txt
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
### 3. Configure environment variables
|
| 37 |
+
|
| 38 |
+
Copy the example file and fill in your API keys:
|
| 39 |
+
|
| 40 |
+
```bash
|
| 41 |
+
cp .env.example .env
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
Required keys:
|
| 45 |
+
|
| 46 |
+
| Variable | Description |
|
| 47 |
+
|---|---|
|
| 48 |
+
| `OPENAI_API_KEY` | OpenAI API key (for GPT models) |
|
| 49 |
+
| `GROQ_API_KEY` | Groq API key (optional, for Llama/Qwen models) |
|
| 50 |
+
| `LANGCHAIN_API_KEY` | LangSmith API key (optional, for tracing) |
|
| 51 |
+
| `LANGCHAIN_PROJECT` | LangSmith project name (optional) |
|
| 52 |
+
|
| 53 |
+
### 4. Run the app
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
streamlit run app.py
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
The app will open at `http://localhost:8501`.
|
| 60 |
+
|
| 61 |
+
## How It Works
|
| 62 |
+
|
| 63 |
+
1. The user asks a question in the chat input
|
| 64 |
+
2. The LangChain agent decides which tool(s) to use
|
| 65 |
+
3. Each step is displayed with expandable details (reasoning, tool calls, tool results)
|
| 66 |
+
4. The final answer is displayed in the chat and saved to conversation history
|
| 67 |
+
|
| 68 |
+
## Switching LLM Providers
|
| 69 |
+
|
| 70 |
+
Edit `app.py` to swap the model. Examples:
|
| 71 |
+
|
| 72 |
+
```python
|
| 73 |
+
# OpenAI
|
| 74 |
+
llm = ChatOpenAI(model="gpt-5-nano-2025-08-07", streaming=True)
|
| 75 |
+
|
| 76 |
+
# Groq (Llama)
|
| 77 |
+
llm = ChatGroq(model="llama-3.3-70b-versatile", streaming=True)
|
| 78 |
+
```
|