A Streamlit chatbot that answers questions from .docx documents using Azure OpenAI.
Drop Word documents into the docs/ folder and ask questions in a conversational chat interface. The AI answers strictly from your documents and maintains chat history across turns.
- loader.py reads all
.docxfiles fromdocs/, extracting text with section headings preserved - agent.py sends the full document text, conversation history, and your question to Azure OpenAI
- app.py provides the Streamlit chat UI with message history and a clear-chat button
- Python 3.12+
- An Azure OpenAI deployment (e.g.,
gpt-4.1-mini)
python -m venv .venv
.venv\Scripts\Activate.ps1 # Windows
pip install -r requirements.txtCreate .streamlit/secrets.toml with your Azure OpenAI credentials:
AZURE_OPENAI_API_KEY = "your-azure-api-key"
AZURE_OPENAI_ENDPOINT = "https://your-resource.openai.azure.com/"
AZURE_OPENAI_DEPLOYMENT = "your-deployment-name"
AZURE_OPENAI_API_VERSION = "2025-01-01-preview"streamlit run app.py- Place
.docxfiles in thedocs/folder - Start the app and ask questions in the chat input
- The AI will answer based only on the document contents
- Use the clear chat button to reset the conversation
app.py # Streamlit chat interface
agent.py # Azure OpenAI integration
loader.py # Word document text extraction
docs/ # Drop .docx files here
.streamlit/secrets.toml # Azure OpenAI credentials (not tracked in git)
requirements.txt # Python dependencies