Spaces:
Running
Running
File size: 5,985 Bytes
43ce912 2d3b132 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
---
title: Gpt Oss News Agent
emoji: π
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 5.42.0
app_file: app.py
pinned: false
short_description: AI-powered news research assistant with real-time search
---
# π° AI News Research Assistant
An intelligent AI-powered news research assistant built with Gradio that provides real-time news search, article fetching, and comprehensive summaries using GPT-OSS models.
## β¨ Features
- **Real-time News Search**: Access current headlines from Google News RSS feeds
- **Topic-specific Research**: Search for news on specific subjects, companies, or events
- **Site-restricted Search**: Limit searches to specific news domains
- **Article Content Extraction**: Download and analyze full article content when needed
- **AI-powered Summaries**: Get intelligent news summaries with proper citations
- **Multiple Model Support**: Choose between GPT-OSS 120B and 20B models
- **Modern Web Interface**: Clean, responsive Gradio-based chat interface
- **Langfuse Integration**: Built-in observability and tracing for interactions
## π Quick Start
### Prerequisites
- Python 3.8+
- API keys for:
- Hugging Face (HF_TOKEN)
- Serper API (SERPER_API_KEY)
- Langfuse (optional, for observability)
### Installation
1. **Clone the repository**
```bash
git clone <your-repo-url>
cd agent_gradio_app
```
2. **Install dependencies**
```bash
pip install -r requirements.txt
```
3. **Set up environment variables**
```bash
# Create .env file
echo "HF_TOKEN=your_huggingface_token" > .env
echo "SERPER_API_KEY=your_serper_api_key" >> .env
echo "LANGFUSE_PUBLIC_KEY=your_langfuse_public_key" >> .env
echo "LANGFUSE_SECRET_KEY=your_langfuse_secret_key" >> .env
```
4. **Run the application**
```bash
python agent_gradio_chat.py
```
5. **Open your browser**
Navigate to `http://localhost:7860`
## π§ Configuration
### Available Models
- **GPT-OSS 120B**: Larger, more capable model for complex reasoning tasks
- **GPT-OSS 20B**: Faster, more efficient model for quick responses
### Environment Variables
| Variable | Description | Required |
|----------|-------------|----------|
| `HF_TOKEN` | Hugging Face API token | Yes |
| `SERPER_API_KEY` | Serper API key for web search | Yes |
| `LANGFUSE_PUBLIC_KEY` | Langfuse public key for observability | No |
| `LANGFUSE_SECRET_KEY` | Langfuse secret key for observability | No |
## π‘ Usage Examples
### General News Requests
- "What are the top news stories today?"
- "What's happening in the world right now?"
- "Show me the latest headlines"
### Topic-specific Research
- "What's the latest on artificial intelligence?"
- "Tell me about recent developments in climate change"
- "What's happening with Tesla stock?"
### Site-specific Searches
- "What's the latest climate change news on the BBC?"
- "Show me recent AI articles from MIT Technology Review"
- "What's new on Ars Technica about cybersecurity?"
## π οΈ How It Works
The application uses a sophisticated agent loop that:
1. **Analyzes User Queries**: Understands the type of news request
2. **Selects Appropriate Tools**: Chooses from available search and fetch tools
3. **Executes Searches**: Performs targeted news searches using various APIs
4. **Extracts Content**: Downloads and processes article content when needed
5. **Synthesizes Information**: Provides comprehensive summaries with citations
6. **Tracks Interactions**: Logs all interactions for observability
### Available Tools
- **`fetch_google_news_rss`**: Get top headlines from Google News
- **`serper_news_search`**: Search for specific topics in Google News
- **`serper_site_search`**: Restrict searches to specific domains
- **`fetch_article`**: Download and extract article content
## π Project Structure
```
agent_gradio_app/
βββ agent_gradio_chat.py # Main application file
βββ requirements.txt # Python dependencies
βββ config.json # Configuration file
βββ .env # Environment variables (create this)
βββ README.md # This file
βββ run_app.sh # Convenience script to run the app
```
## π API Dependencies
- **Hugging Face**: Model inference and hosting
- **Serper API**: Web search capabilities
- **Trafilatura**: Article content extraction
- **Langfuse**: Observability and tracing
## π Deployment
### Local Development
```bash
python agent_gradio_chat.py
```
### Production Deployment
```bash
# Using the convenience script
chmod +x run_app.sh
./run_app.sh
# Or directly with custom settings
python agent_gradio_chat.py --server-name 0.0.0.0 --server-port 7860
```
### Docker (Optional)
```dockerfile
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 7860
CMD ["python", "agent_gradio_chat.py"]
```
## π§ͺ Testing
Test the application with various news queries:
```bash
# Test basic functionality
python -c "
from agent_gradio_chat import run_agent
response = run_agent('What are the top news stories today?')
print(response)
"
```
## π€ Contributing
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## π License
This project is licensed under the MIT License - see the LICENSE file for details.
## π Acknowledgments
- [Gradio](https://gradio.app/) for the web interface framework
- [Hugging Face](https://huggingface.co/) for model hosting and inference
- [OpenAI](https://openai.com/) for the GPT-OSS models
- [Serper](https://serper.dev/) for web search capabilities
## π Support
For issues, questions, or contributions:
- Open an issue on GitHub
- Check the documentation
- Review the code comments for implementation details
---
**Happy news researching! ππ°** |