This project implements a Retrieval-Augmented Generation (RAG) search system using Azure AI services and Streamlit. It creates a chatbot interface that allows users to ask questions and receive answers based on a knowledge base stored in Azure Cognitive Search.
- Persona-based responses
- Azure Cognitive Search integration
- Conversation history
- Streamlit-based user interface
- Python 3.7+
- Azure account with access to Azure Cognitive Search
- OpenAI API key (for GPT model access)
-
Clone this repository:
git clone https://github.com/your-username/rag-search-azure-ai.git cd rag-search-azure-ai
-
Install the required packages:
pip install -r requirements.txt
-
Set up your Azure Cognitive Search service and index.
-
Create a
secrets.toml
file in the.streamlit
directory with the following content:[default] searchservice = "your-search-service-name" searchkey = "your-search-service-admin-api-key" index = "your-index-name" tlm_manager = "TLM Manager persona description" psd_manager = "PSD Manager persona description"
Run the Streamlit app:
streamlit run app.py
Navigate to the provided URL in your web browser to interact with the chatbot.
app.py
: Main Streamlit applicationgpt_return_st.py
: Contains functions for creating prompts and generating answers (not provided in the given code snippet).streamlit/secrets.toml
: Configuration file for API keys and other secrets
- The user selects a persona from the dropdown menu.
- The user enters a question in the text input field.
- The system queries Azure Cognitive Search to retrieve relevant documents.
- The retrieved content is used to create a prompt for the GPT model.
- The GPT model generates an answer based on the prompt and selected persona.
- The answer is displayed to the user, along with references to the source documents.
- The conversation history is updated and displayed in the sidebar.
- To add new personas, update the
PERSONAS
dictionary inapp.py
. - To modify the search behavior, adjust the parameters in the
search_client.search()
call. - To change the UI layout or styling, modify the Streamlit components and custom CSS in
app.py
.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.