Skip to content

mathis-lambert/api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Repository

Welcome to the api repository! This repository hosts the core API infrastructure for my web services, built using Python 3.13 and FastAPI. The API is designed to serve essential utilities and functionalities across all my web services, accessible under the domain api.mathislambert.fr.

Projet structure

Diagram GitDiagram

🌟 Features

  • FastAPI: A modern, fast (high-performance) web framework for building APIs with Python 3.13 based on standard Python type hints.
  • MongoDB: A NoSQL database used for storing application data, offering flexibility and scalability.
  • Qdrant: A vector database used for implementing Retrieval-Augmented Generation (RAG) features, enhancing information retrieval capabilities.
  • LLM Integration: OpenAI-compatible chat completions proxied to OpenRouter.
  • Versioning: A systematic versioning approach with endpoints like /v1, /v2, etc., to manage API changes and ensure backward compatibility.

🚀 Getting Started

Prerequisites

  • Python 3.13
  • MongoDB instance
  • Qdrant instance
  • OpenRouter API key

Installation

  1. Clone the Repository:

    git clone https://github.com/your-username/api.git self_api
    cd self_api
  2. Set Up a Virtual Environment:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install Dependencies:

    pip install -r requirements.txt
  4. Configure Environment Variables: Create a .env file in the root directory and add the following variables:

    MONGODB_URI=your_mongodb_connection_string
    QDRANT_URI=your_qdrant_connection_string
    OPENROUTER_API_KEY=your_openrouter_api_key
    OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
    OPENROUTER_SITE_URL=https://your-site.example
    OPENROUTER_APP_NAME=your-app-name
    

Running the API

Start the FastAPI server using:

uvicorn main:app --host 0.0.0.0 --port 3001 --reload

The API will be accessible at http://127.0.0.1:3001.

🛣️ API Endpoints

Versioning

  • Base URL: https://api.mathislambert.fr
  • Versioning Structure: /v1, /v2, etc.

Example Endpoints

  • Health Check:

    • GET /v1/health: Check the status of the API.
  • LLM Routes:

    • POST /v1/chat/completions: OpenAI-compatible chat completions proxied to OpenRouter (metadata-only logging to MongoDB).
    • POST /v1/responses: OpenAI-compatible responses proxied to OpenRouter (metadata-only logging to MongoDB).
  • Data Routes:

    • GET /v1/data: Retrieve data from MongoDB.
    • POST /v1/data: Insert data into MongoDB.
  • RAG Features:

    • POST /v1/rag/query: Query the Qdrant database for enhanced information retrieval using RAG.

🤝 Contributing

Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request. Let's build something amazing together!

📜 License

This project is licensed under the MIT License. Feel free to explore, modify, and share!

📞 Contact

Have questions or want to chat? Feel free to reach out!


Happy coding! 💻✨

About

This repository hosts the core API infrastructure for my web services, built with Python and FastAPI. It serves essential utilities and functionalities across all my web services, accessible under api.mathislambert.fr. The goal is to provide a robust and scalable backend for various web applications.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors