langchain-gemini-api
is an AI-powered conversation API that integrates Google's Gemini API, designed to facilitate
advanced text and image-based interactions. This project combines the capabilities of modern deep learning models with
FastAPI for high performance and scalability, Langchain for sophisticated conversational workflows, and Redis for
ephemeral conversation storage.
- Asynchronous API: Utilizing FastAPI for enhanced performance and scalability.
- Langchain Integration: Advanced conversational workflows using multiple AI models.
- Google Gemini API: Incorporating Gemini, Gemini Pro, and Gemini Pro Vision for superior conversation understanding and generation.
- Ephemeral Conversation Storage: Implementing Redis for data privacy and efficient memory usage.
- User-Friendly Interface: Simplified API endpoints for easy integration.
- Get a Google Gemini AI API key here and add it to Secrets in your Repl with the key GOOGLE_API_KEY.
- Python 3.9 or higher
- FastAPI
- Uvicorn
- Redis
- Access to Google Gemini API
- Install Redis:
Windows users can download Redis from here
sudo apt update sudo apt install redis-server
- Test Redis:
If Redis is running, it will return
redis-cli ping
PONG
.
- Clone the repository:
git clone https://github.com/shamspias/langchain-gemini-api.git
- Create a virtual environment:
for Windows:
python3 -m venv venv
python -m venv venv
- Activate the virtual environment:
source venv/bin/activate
- Navigate to the project directory and install dependencies:
cd langchain-gemini-api pip install -r requirements.txt
- Create a
.env
file in the project directory and add the following:GEMINI_API_KEY=<your_google_gemini_api_key> # e.g. "1234567890" REDIS_URL=redis://localhost:6379/0 # default Redis URL MY_API_KEY=<your_api_key_to_access_your_backend_api> # e.g. "1234567890" SYSTEM_INSTRUCTION=<your_system_instruction_for_gemini> # e.g. "Your are Sam and an AI assistant...etc"
- Start fastapi server:
uvicorn app.main:app --reload
The API will be available at http://localhost:8000.
- /conversations/<conversation_id>: Endpoint for text and image based conversations.
- /delete/<conversation_id>: Endpoint to delete conversation data.
- /docs: Swagger UI for API documentation.
- /redoc: ReDoc UI for API documentation.
- Google Gemini API team
- Langchain contributors
- FastAPI community
With telegram bot use this one: https://t.me/rim_nova_bot
This is the telegram bot repo: Gemini-Telegram-Bot
- Coming soon