Here is the formatted and organized version of your document for the AI Model Hub Service:
This project is a central hub service designed to route requests to various Large Language Models (LLMs) and manage associated data. It integrates a relational database (PostgreSQL) for metadata with a vector store (FAISS) for efficient similarity search.
The service consists of several main components that work together to process user requests and manage data:
API Server A FastAPI application that serves as the primary entry point for all client requests.
LLM Router / Orchestrator The core logic that determines which LLM handles a request, manages chat history, and orchestrates interactions with the databases.
Vector Database (FAISS + PostgreSQL) A two-part system for data storage:
The schema is designed to store conversations, documents, and the metadata necessary to link them together.
Stores individual conversations with a user.
id
, user_id
, title
, model_name
, created_at
, is_archived
Stores each message within a session.
id
, session_id
, sender
, content
, created_at
, model_response_time
, token_count
, metadata
Stores the original text and metadata of a document for RAG (Retrieval-Augmented Generation).
id
, title
, text
, source_url
, author
, status
, created_at
, user_id
Links a document to its vector representation in the FAISS index.
id
, document_id
, faiss_index
, session_id
, embedding_model
To ensure the database models work correctly, a set of tests is provided using an in-memory SQLite database.
Navigate to the project root.
Set up your environment and install dependencies:
pip install -e .[test]
This installs the project in editable mode along with the test dependencies defined in pyproject.toml
.
Run tests using Pytest:
pytest
Pytest will automatically discover and run all tests in the tests/
directory.
Let me know if you want this converted to Markdown, PDF, or documentation site format (e.g., Sphinx or MkDocs).