gpt-oss-news-agent / README.md
fdaudens's picture
fdaudens HF Staff
readme
43ce912
---
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! πŸš€πŸ“°**