Coder Social home page Coder Social logo

shamspias / langchain-gemini-api Goto Github PK

View Code? Open in Web Editor NEW
28.0 3.0 6.0 2.91 MB

An innovative AI conversation API leveraging Google's Gemini for multimodal understanding. Combines FastAPI, Langchain, and Redis for robust, scalable, and privacy-conscious text and image-based interactions

Home Page: https://t.me/rim_nova_bot

Python 100.00%
gemini-api gemini-pro gemini-pro-api gemini-pro-vision langchain langchain-python fastapi google-generative-ai large-language-models python

langchain-gemini-api's Introduction

langchain-gemini-api

Overview

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.

Key Features

  • 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.

Getting Started

Prerequisites for Google Gemini API

Prerequisites for langchain-gemini-api

  • Python 3.9 or higher
  • FastAPI
  • Uvicorn
  • Redis
  • Access to Google Gemini API

Installation

Install Redis

  1. Install Redis:
    sudo apt update
    sudo apt install redis-server
    Windows users can download Redis from here
  2. Test Redis:
    redis-cli ping
    If Redis is running, it will return PONG.

Install Python Dependencies

  1. Clone the repository:
    git clone https://github.com/shamspias/langchain-gemini-api.git
  2. Create a virtual environment:
    python3 -m venv venv
    for Windows:
    python -m venv venv
  3. Activate the virtual environment:
     source venv/bin/activate
  4. Navigate to the project directory and install dependencies:
    cd langchain-gemini-api
    pip install -r requirements.txt

Configuration

  1. 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"

Running the API

  1. Start fastapi server:
uvicorn app.main:app --reload

The API will be available at http://localhost:8000.

API Endpoints

  • /conversations/<conversation_id>: Endpoint for text and image based conversations.
  • /delete/<conversation_id>: Endpoint to delete conversation data.

API Documentation

Acknowledgments

Demo

Conversation

With telegram bot use this one: https://t.me/rim_nova_bot

This is the telegram bot repo: Gemini-Telegram-Bot

Conversation Conversation Conversation

Video

  • Coming soon

langchain-gemini-api's People

Contributors

shamspias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.