|
--- |
|
title: LLM-Enhanced Internet Search Agent |
|
emoji: π΅π»ββοΈ |
|
colorFrom: indigo |
|
colorTo: indigo |
|
sdk: gradio |
|
sdk_version: 5.25.2 |
|
app_file: app.py |
|
pinned: false |
|
hf_oauth: true |
|
|
|
hf_oauth_expiration_minutes: 480 |
|
--- |
|
|
|
# LLM-Enhanced Internet Search Agent |
|
|
|
This agent uses a two-step approach to answer questions: |
|
|
|
1. **Question Breakdown**: The agent first uses an LLM (GPT-3.5) to break down complex questions into 2-3 key search queries |
|
2. **Targeted Search**: Each search query is sent to Wikipedia's API to retrieve relevant information |
|
3. **Answer Synthesis**: The agent then uses the LLM to synthesize a comprehensive answer based on all search results |
|
|
|
## Features |
|
|
|
- **Smart Query Generation**: Transforms natural language questions into optimized search queries |
|
- **Parallel Search Processing**: Searches for multiple key aspects of the question simultaneously |
|
- **Knowledge Synthesis**: Combines information from multiple sources into a cohesive answer |
|
- **Fallback Mechanisms**: Graceful handling of errors at each step of the process |
|
|
|
## Setup Requirements |
|
|
|
1. Clone this repository |
|
2. Install required packages: `pip install -r requirements.txt` |
|
3. Set your OpenAI API key as an environment variable: `OPENAI_API_KEY=your-api-key` |
|
|
|
## How It Works |
|
|
|
1. User submits a question |
|
2. LLM breaks down the question into key search terms |
|
3. Search terms are used to query Wikipedia API |
|
4. Results from multiple searches are collected |
|
5. LLM synthesizes the information into a comprehensive answer |
|
6. Answer is returned to the user |
|
|
|
This approach is more effective than direct internet searches because: |
|
- It identifies the most relevant aspects of complex questions |
|
- It can break multi-part questions into their components |
|
- It leverages the LLM's understanding of natural language |
|
- It provides more targeted and accurate search results |
|
|
|
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference |