Spaces:
Running
Running
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! ππ°** |