niddijoris's picture
Update README.md
ebd14db verified
metadata
license: afl-3.0
title: RAG
sdk: docker
emoji: πŸ“š
colorFrom: green
colorTo: yellow

TechFlow Customer Support Agent πŸ€–

A robust, RAG-based AI agent designed to assist users by answering questions from local PDF documentation and seamlessly creating GitHub support tickets when answers are unavailable.

πŸš€ Live Demo

Try it on Hugging Face Spaces

🌟 Features

  • RAG (Retrieval-Augmented Generation): Answers user queries using a local knowledge base created from PDF documents.
  • Smart Search & Synthesis:
    • Typo Tolerance: Handles misspellings (e.g., "solutiun") and infers user intent.
    • Relevance Filtering: Automatically discards search results with a similarity score below 0.7 to prevent hallucinated answers from irrelevant text.
    • Comprehensive Summarization: Synthesizes answers from multiple document chunks.
  • Strict Citations: Every answer includes mandatory source citations with filenames and page numbers (e.g., **Source:** manual.pdf (Page 12)).
  • Automated Ticket System:
    • Condition-Based: Offers to create a ticket only when the agent explicitly "could not find the answer".
    • GitHub Integration: Directly creates issues in a specified GitHub repository.
    • Project Organization: Automatically applies labels and prefixes titles based on the configured PROJECT_FOLDER.
  • Auto-Ingestion: Automatically checks and updates the vector database from the data/ directory when the application starts.

πŸ› οΈ Prerequisites

  • Python 3.9+
  • OpenAI API Key
  • GitHub Personal Access Token (with repo scope)

πŸš€ Installation & Setup

  1. Clone the Repository

    git clone <your-repo-url>
    cd <project-directory>
    
  2. Install Dependencies

    pip install -r requirements.txt
    
  3. Configure Environment Create a .env file in the root directory (copy from .env.example):

    cp .env.example .env
    

    Update .env with your credentials:

    OPENAI_API_KEY=sk-...
    GITHUB_TOKEN=ghp_...
    REPO_NAME=your_username/your_repo_name
    PROJECT_FOLDER=if_ur_project_has_folder_name_put_it_here  # Used for ticket labels/titles
    
  4. Add Knowledge Base Place your PDF documents into the data/ folder.

    • The system will automatically ingest them when you run the app.

πŸ’» Usage

Start the Streamlit application:

streamlit run app.py

How it works:

  1. Ask a Question: Type your query in the chat.
  2. Get an Answer: The agent searches the PDFs.
    • If a high-confidence answer is found (Score > 0.7), it answers with citations.
    • If relevant info is NOT found, it replies "I could not find the answer".
  3. Raise a Ticket: If the answer was not found, a form appears allowing you to create a GitHub issue immediately.
  • app.py: Main Streamlit application entry point.
  • agent.py: Core logic for the AI agent, RAG search, and TicketSystem.
  • ingest.py: Script handles loading PDFs, chunking, and FAISS vector storage.
  • data/: Directory for source PDF files.
  • vector_db/: Directory where the FAISS index is saved locally.Image
Image Image Image