prp-e / Maux-RAG-API

a complete RAG-Ready fast api app for your Rag Systems

Home Page:https://ai.maux.space/

Repository from Github https://github.comprp-e/Maux-RAG-APIRepository from Github https://github.comprp-e/Maux-RAG-API

Maux-API Banner

πŸš€ MAUX INC RAG API

Welcome to the MAUX INC RAG API! This powerful API enables you to create a Retrieval-Augmented Generation (RAG) system using OpenAI's chat completions and embeddings, along with ChromaDB for efficient document storage and retrieval.

🌟 Features

  • πŸ“š Document embedding and storage
  • πŸ” Semantic search for relevant documents
  • πŸ€– AI-powered question answering
  • πŸ”— Easy integration with OpenAI and ChromaDB

πŸ› οΈ Installation

  1. Clone the repository
  2. Install dependencies:
pip install -r requirements.txt 
  1. Set up your environment variables in a .env file
OPENAI_API_KEY=your_openai_api_key
CHROMA_PERSIST_DIRECTORY=./chroma_db
OPENAI_EMBEDDING_MODEL=text-embedding-3-small
CHAT_MODEL=gpt-4o-mini
RAG_SEARCH_LIMIT=3
SYSTEM_PROMPT="You are a helpful assistant. Use the provided context to answer the user's question. If the context is not relevant, just say 'I don't know'"

πŸš€ Usage

start the api with the following command:

uvicorn app.main:app --host 0.0.0.0 --port 8000

πŸ›£οΈ Routes

  1. initialize the collection in the vector database Before using the API, you need to initialize the collection:
import requests

BASE_URL = "http://localhost:8000/v1"

response = requests.post(f"{BASE_URL}/vector_db/initialize_collection")
print(response.json())
  1. Add Documents to the collection
import requests

BASE_URL = "http://localhost:8000/v1"

response = requests.post(f"{BASE_URL}/vector_db/add_document", json={
    "text": "MAUX INC is a leading AI platform for innovative solutions.",
    "metadata": {"source": "company_info"}
})
print(response.json())
  1. Search Documents Search for similar documents:
import requests

BASE_URL = "http://localhost:8000/v1"

response = requests.post(f"{BASE_URL}/vector_db/search_documents", json={
    "text": "Ω…Ψ§Ϊ©Ψ³ Ϊ†ΫŒΩ‡ΨŸ"
})
print(response.json())
  1. Chat Completions
import requests

BASE_URL = "http://localhost:8000/v1"

response = requests.post(f"{BASE_URL}/chat/completions", json={"prompt": "Ω…Ψ§Ϊ©Ψ³ Ϊ†ΫŒΩ‡ΨŸ"})
response_data = response.json()
    
# Extract and print only the content
content = response_data['choices'][0]['message']['content']
print(content)

πŸ“š Examples

examples/chat.py is a simple example of how to use the chat completions route.

πŸ“š License

This project is licensed under the MIT License

πŸ“š Contributing

Contributions are welcome! Please feel free to submit a PR.

About

a complete RAG-Ready fast api app for your Rag Systems

https://ai.maux.space/


Languages

Language:Python 100.0%