oracle-ai-developer-hub

Doc Chatbot | RAG-based QA with Oracle Autonomous Vector Database (VecDB SDK)

Overview

This app showcases a Retrieval-Augmented Generation (RAG) QA chatbot that allows you to upload documents, process them, and interactively ask questions. It is built using Oracle’s VecDB Python SDK. The app supports multiple LLM and embedding backends, including Ollama and OpenAI-compatible APIs.

Oracle VecDB acts as the retrieval backbone of the workflow: document chunks are embedded, stored as dense vectors together with metadata, and queried at runtime using top-k similarity search. The retrieved chunk context is then passed into the configured chat model to generate grounded answers.


What you can do with this app

High-level document ingestion and retrieval flow using Oracle VecDB.

Doc Chatbot Demo

Architecture Flow

  1. Users upload PDF or TXT documents through the Streamlit interface.
  2. The application extracts raw text from each file and splits it into smaller chunks.
  3. An embedding model generates vector representations for every chunk.
  4. The chunk embeddings and metadata are uploaded into an Oracle VecDB dense vector table.
  5. When the user asks a question, the question is embedded using the configured embedding backend.
  6. The app retrieves the top-k most relevant chunks from Oracle VecDB.
  7. The retrieved chunks are passed as context to the configured chat model.
  8. The model generates a final answer grounded in the uploaded document content.

Why Oracle AI Database in this sample

This sample highlights Oracle AI Database as the vector retrieval layer of the application. Oracle VecDB is used to store chunk embeddings as dense vectors, manage the vector table lifecycle, and perform top-k similarity retrieval at query time. The retrieved database context is then passed into the selected chat model to produce grounded answers.

Oracle AI Database-centered retrieval architecture for document-grounded question answering.


Features


Prerequisites


Installation

  1. Clone this repository

    git clone <repo-url>
    cd doc_chatbot
    
  2. (Recommended) Create and activate a virtual environment

    python3 -m venv venv
    source venv/bin/activate
    
  3. Install dependencies

    pip install -r requirements.txt
    

Usage

  1. Run the application

    streamlit run app/main.py
    

    The app will open at http://localhost:8501

  2. Configure the sidebar

    • Vector Store (Oracle VecDB):
      • ORDS VecDB Base URL: e.g. https://<host>/ords/vector3/_/db-api/stable/vecdb
      • Database Username: your vector user
      • Password: your password
      • Click “Test Connection”
    • Language Model: Choose your preferred chat model (OpenAI-compatible API or Ollama)
    • Embedding Model: Select embedding generation method (Sentence-Transformers, OpenAI-compatible API, or Ollama)

Application setup, document upload, and chunk processing configuration.

  1. Upload Documents and Start Chatting
    • Document Upload: Process and chunk your documents
    • Database Upload: Store processed document vectors in Oracle VecDB (a vector table will be created and populated)
    • Main Chat Interface: Ask questions about your documents
    • Vector Table Name: Enter the target table name before processing the uploaded chunks
    • Processing Parameters: Configure chunk size and overlap size before vectorization
    • Clicking Process Documents extracts text from the uploaded files, splits the content into chunks, generates embeddings, recreates the target Oracle VecDB table, attempts to create a vector index, and uploads chunk vectors together with metadata.

Interactive question answering over uploaded documents using context retrieved from Oracle VecDB.


How it works (VecDB Integration)

See the implementation in app/main.py.


Stored Vector Payload

Each processed chunk is uploaded into Oracle VecDB as a dense vector record with:

This payload structure enables Oracle VecDB to support both semantic retrieval and metadata-aware context reconstruction for the final answer generation step.


File Structure

doc_chatbot/
├── app/
│   ├── main_vecdb.py
│   └── utility/
│       ├── document_processor.py
│       └── model.py
├── images/
│   ├── chat.png
│   ├── diagram.png
│   ├── diagram2.png
│   └── upload.png
├── README.md
├── requirements.txt
└── venv/               # optional, if you created one

Configuration

Vector Database (Oracle VecDB via ORDS)

Language Model

Embedding Model


Current Limitations


Troubleshooting