天气与新闻助理
使用Azure OpenAI、MCP服务器和Streamlit回答有关当前天气和最新新闻的问题。
设置
创建 .env:
DIAL_API_KEY=your_key_here
AZURE_ENDPOINT=https://ai-proxy.lab.epam.com
API_VERSION=2023-08-01-preview
MODEL=gpt-4o安装依赖项:
pip install mcp[cli] streamlit requests python-dotenv openai运行:
PYTHONPATH=src streamlit run src/clients/assistant/main.py码头工人
docker build -t weather-news-assistant .
docker run --network host --env-file .env weather-news-assistant打开http://localhost:8501
建筑
Streamlit UI
│
▼
Orchestrator ──► Azure OpenAI (tool selection + weather narration)
│
├──► MCP stdio ──► servers/weather ──► Open-Meteo API
└──► MCP stdio ──► servers/news ──► Google News RSS项目结构
src/
├── servers/
│ ├── weather/main.py # MCP server — Open-Meteo API
│ ├── news/main.py # MCP server — Google News RSS
│ ├── orchestrator.py # Agent — LLM tool calling via MCP
│ └── prompts.py # System prompt
└── clients/
└── assistant/
└── main.py # Streamlit UI工具
| 工具 | 说明 |
|---|---|
get_current_weather(city) | 当前温度、条件、风 |
get_weather_forecast(city, days) | 每日预报长达7天 |
get_latest_news(category) | 按类别分列的标题 |
search_news(query) | 关键词新闻搜索 |
备注
- 需要EPAM VPN才能访问Azure OpenAI
- 天气和新闻不需要API密钥
