企业虚拟助手

一个基于RAG架构的企业虚拟助手,专注于帮助台服务,通过检索增强生成技术确保回答的准确性和数据忠实度。

  • by adriano-allef
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 adriano-allef/Helpdesk-com-IA-usando-RAG-e-MCP

使用说明

🤖 Helpdesk AI: RAG & Agentic Workflow

🎯 About the Project

This project implements a Retrieval-Augmented Generation (RAG) architecture focused on solving the hallucination problem in LLMs for corporate use.

The goal is to create a Helpdesk Assistant that consults internal manuals and responds technically and accurately. If the solution is not in the database, the system uses an agent stream to automatically open a ticket in Trello via n8n, ensuring that the user is never without support.

The infrastructure was developed via code (FastAPIto ensure full control over data flow, security and API costs.

💡 What he doesSearch

  • Vetorial (pgvector): Perform semantic search in documents, finding the right context rather than just keywords.
  • Groundedness filter: Prompt configuration to ensure that AI responds only to what is in official documents.
  • Ticket Automation (n8n): If the AI doesn’t know the answer, it fires a webhook into the n8nwhich creates a card in Trello of the support team.
  • Chat history: Frontend memory management to keep conversation flowing.

🛠️ Technology Stack

  • Backend: Python + FastAPI + SQLAlchemy
  • Database: PostgreSQL with extension 'pgvector'
  • Artificial Intelligence: Google Gemini API (Embeddings e LLM)
  • Orchestration: n8n e Trello
  • APIFrontend: Streamlit

🧠 Technical Choices and Architecture

The system was structured with a focus on performance and safety. Below are the main points:

  1. Vector Performance (768 dimensions):
    I configured the output of the embeddings model to 768 Dimensions (instead of 3072). This reduces bank memory consumption and speeds up the search for similarity without losing accuracy in the context of helpdesk.
  2. Strict Groundedness: The prompt works in restricted mode. If the information does not exist in the manuals, the model informs the limit of your knowledge and suggests opening the ticket.
  3. Automation Triggers: When the AI does not find the answer, it inserts an invisible tag into the backend. The FastAPI intercepts this tag, clears the text for the user and fires a Asynchronous Webhook para o n8n.
  4. DevSecOps Security: Management of credentials via .env files injected into containers and use of the native n8n vault.
  5. Code Organization (Clean Architecture): Use of APIRouter to separate user, document and chat logic into independent modules.

🚀 How to Execute the Project

Prerequisites

  • Docker e Docker Compose instalados.
  • Google AI Studio API key. Step by Step
  1. Clone the repository:

    git clone https://github.com/adriano-allef/Helpdesk-com-IA-usando-RAG-e-MCP.gitcd Helpdesk-com-IA-usando-RAG-e-MCP
    
  2. Configure the environment variables:

    Create a file .env Raiz com:

    GEMINI_API_KEY=sua_chave_aqui
    POSTGRES_USER=admin
    POSTGRES_PASSWORD=senha_segura
    POSTGRES_DB=helpdesk_db
    
    1. Upgrade the infrastructure:
    docker compose up --build -d
    
    1. Inicie o Frontend:
    pip install -r requirements.txt
    streamlit run frontend.py
    

📡 Endpoints da API

Route Method Description
/users/ POST Registration of new users.
/documents/ POST Vectorization and storage of manuals
/documents/search POST Semantic search for similarity. (pgvector).
/chat/ POST Main RAG engine and trigger firing.

📂 Pasta Structure

app/
├── database/
│   └── database.py      # Conexão e sessão do banco de dados
├── models/
│   └── models.py        # Tabelas SQLAlchemy (ORM)
├── routers/
│   ├── chat.py          # Lógica RAG e Prompts
│   ├── documents.py     # Lógica de Embeddings
│   └── users.py         # Lógica de Usuários
├── schemas/
│   └── schemas.py       # Validação de dados (Pydantic)
├── main.py              # Ponto de entrada da API FastAPI
├── docker-compose.yml   # Orquestração dos contêineres (Docker)
├── Dockerfile           # Imagem do Backend
├── frontend.py          # Interface do usuário com Streamlit
├── requirements.txt     # Dependências do projeto
└── README.md            # Documentação (Você está aqui!)

🔮 Roadmap Completed

  • [x] Integration with vector bank (pgvector).
  • [x] Conversational memory on the frontend.
  • [x] Agentic Workflow: Disparo de Webhooks para n8n.
  • [x] Trello Integration: Automatic card creation.
  • [x] Visual Dashboard: Architecture timeline in Streamlit.