This chatbot leverages OpenAI's language models (GPT-4o-mini) alongside Azure Cognitive Search, Bing Web Search, and weather APIs to provide comprehensive answers. It combines internal document search, real-time web data, and weather information to address user queries.
-
Multi-Source Information Retrieval:
- Azure Cognitive Search: Searches internal documents using hybrid semantic/vector search.
- Bing Web Search: Fetches recent web results (past week) for up-to-date information.
- Weather API: Provides current temperature data based on coordinates.
-
Agentic Workflow:
- Automatically selects the appropriate tool (document/web/weather search) based on user input.
- Uses OpenAI's model to generate responses augmented by tool outputs.
-
Streamlit Interface:
- Simple web UI for user interaction with a trace sidebar showing tool execution details.
-
Environment Variables (required in
.env
):OPENAI_API_KEY=your_openai_key AZURE_OPENAI_API_KEY=your_azure_openai_key AZURE_OPENAI_ENDPOINT=your_azure_endpoint AZURE_SEARCH_SERVICE_ENDPOINT=your_azure_search_endpoint AZURE_SEARCH_INDEX=your_search_index AZURE_SEARCH_API_KEY=your_azure_search_key AZURE_SEARCH_SEMANTIC_SEARCH_CONFIG=your_semantic_config BING_ENDPOINT=your_bing_endpoint BING_KEY=your_bing_key
-
Python Packages:
pip install openai azure-search-documents streamlit python-dotenv requests
-
User Input:
- Submit a query via the Streamlit interface.
-
Tool Selection:
- GPT-4o-mini determines which tool(s) to use (document search, web search, or weather lookup).
-
Data Retrieval:
- Document Search: Generates embeddings for semantic/vector search in Azure.
- Web Search: Queries Bing for recent results.
- Weather: Fetches temperature data from Open-Meteo.
-
Response Generation:
- Combines tool outputs with language model capabilities to form a natural language answer.
- Internal Knowledge: "What's the company's 2023 revenue?" (uses Azure document search)
- Current Events: "Latest news on climate change?" (uses Bing web search)
- Weather: "What's the temperature in Paris?" (requires user-provided coordinates)
- Weather tool requires manual latitude/longitude input (not geocoded from location names).
- No error handling for invalid API credentials or network issues.
- Bing search results limited to 10 items and 1-week freshness.
streamlit run your_script_name.py
Access the interface at http://localhost:8501
. Type queries in the message box and click "Send".