A Streamlit-based chat application that interfaces with IBM's watsonx.ai foundation models, featuring document-based knowledge retrieval (RAG) capabilities.
- 💬 Interactive chat interface with watsonx.ai models
- 📚 Document management with RAG (Retrieval-Augmented Generation)
- 🔧 Adjustable model parameters (temperature, tokens, etc.)
- 📊 Token usage tracking
- 📁 Support for multiple document formats (PDF, CSV, TXT, DOCX)
- 🔐 Secure credential management
- IBM Cloud Account with watsonx.ai access
- API Key and Project ID from IBM Cloud
- Python 3.8 or higher
- pip package manager
- Clone the repository:
git clone https://github.com/aseelert/watsonx-chatwithdocs
cd watsonx-chatwithdocs- Create a virtual environment (recommended):
python -m venv venv312
source venv/bin/activate # On Windows: venv\Scripts\activate- Install required packages:
pip install -r requirements.txt- Launch the application:
streamlit run Home.py- Navigate to the "Credentials" page
- Enter your watsonx.ai credentials:
- API Key
- Project ID
- Select your closest region
- Verify the connection
Simple chat interface with RAG enabled.

- Navigate to the "Chat" page
- Adjust model parameters in the sidebar:
- Temperature (0.0 - 1.0)
- Max Tokens (100 - 4096)
- Top P (0 or 1)
- Top K (0 - 100)
- Repetition Penalty (1 or 2)
- Go to the "Document Management" page
- Upload documents (PDF, CSV, TXT, DOCX)
- Enable "Use Document Knowledge" in Chat to use RAG
watsonx-chatwithdocs/
├── Home.py # Main application entry
├── pages/
│ ├── 01_Chat.py # Chat interface
│ ├── 02_Documents.py # Document handling
│ └── 03_Credentials.py # Credential management
├── utils/
│ ├── watsonx_helpers.py # watsonx.ai integration
│ ├── chroma_helpers.py # Vector database management
│ └── credentials_helpers.py # Credential handling
└── requirements.txt # Python dependencies
- streamlit
- langchain
- chromadb
- ibm-watsonx-ai
- python-dotenv
- sentence-transformers
- unstructured
- pypdf
- python-docx
- Credentials are stored locally in a SQLite database
- API keys are stored securely and not exposed in the UI
- Choose the closest region for optimal performance
-
If ChromaDB fails to initialize:
- Ensure write permissions in the application directory
- Check if required models are downloaded
-
If watsonx.ai connection fails:
- Verify API key and Project ID
- Check region selection
- Ensure IBM Cloud account has necessary permissions
Feel free to submit issues and enhancement requests!
MIT License

