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.
- π Document embedding and storage
- π Semantic search for relevant documents
- π€ AI-powered question answering
- π Easy integration with OpenAI and ChromaDB
- Clone the repository
- Install dependencies:
pip install -r requirements.txt - 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'"start the api with the following command:
uvicorn app.main:app --host 0.0.0.0 --port 8000- 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())- 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())- 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())- 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/chat.py is a simple example of how to use the chat completions route.
This project is licensed under the MIT License
Contributions are welcome! Please feel free to submit a PR.
