Skip to main content

Gai/Gen is the Universal Multi-Modal Wrapper Library for LLM. The library is designed to provide a simplified and unified interface for seamless switching between multi-modal open source language models on a local machine and OpenAI APIs.

Project description

Gai/Gen: Universal LLM Wrapper

This is a Universal Multi-Modal Wrapper Library for LLM inferencing.

This is a Universal Multi-Modal Wrapper Library for LLM inferencing. The library provides a simplified and unified interface for seamless switching between multi-modal open source language models on a local machine and OpenAI APIs, adhering closely to the OpenAI API specs.

This is intended for Developers who are targetting the use of multi-modal LLMs for both OpenAI API and local machine models.

As the main focus is on 7 billion parameters and below open source models, running on commodity hardware, the library is designed to be a singleton wrapper. Only one model is loaded and cached into memory at any one time.

The wrappers are organised under the gen folder according to 4 categories:

  • ttt: Text-to-Text
  • tts: Text-to-Speech
  • stt: Speech-to-Text
  • itt: Image-to-Text

Setting Up

pip install gai-aio

or

git clone https://www.github.com/kakkoii1337/gai-aio

Configuration

  • Create the default application directory ~/gai and the default models directory ~/gai/models.

  • Copy gai.json from this repository into ~/gai. This file contains the names and paths of the models and their respective loaders.

API Key

  • All API keys should be stored in a .env file in the root directory of the project. For example,

    OPENAI_API_KEY=<--replace-with-your-api-key-->
    ANTHROPIC_API_KEY=<--replace-with-your-api-key-->
    

Requirements

Credits

This library is made possible by the generosity and hardwork of the following open source projects. You are highly encouraged to check out the original source and documentations.

TTT

ITT

  • Liu HaoTian for the LLaVa Model and Library

TTS

STT

  • OpenAI for Open Sourcing Whisper v3

Quick Start

1. Setup OpenAI API Key.

Save your OpenAI API key in a .env file in the root directory of your project.

OPENAI_API_KEY=<--replace-with-your-api-key-->

2. Run GPT4.

Run Text-to-Text generation using OpenAI by loading gpt-4 wrapper.

from gai.gen import Gaigen
gen = Gaigen.GetInstance().load('gpt-4')

response = gen.create(messages=[{'role':'USER','content':'Tell me a one paragraph short story.'},{'role':'ASSISTANT','content':''}])
print(response)

3. Install Mistral7B.

Open ~/gai/gai.json and refer to model_path:

  • under mistral-8k, refer to model-path for the repo name.
  • Go to huggingface
  • Download the repo Mistral-7B-Instruct-v0.1-GPTQ into the ~/gai/models folder.

4. Run Mistral7B.

Run Text-to-Text generation using Mistral7B by replacing gpt-4 with mistral-8k.

from gai.gen import Gaigen
gen = Gaigen.GetInstance().load('mistral-8k')

response = gen.create(messages=[{'role':'USER','content':'Tell me a one paragraph short story.'},{'role':'ASSISTANT','content':''}])
print(response)

Examples

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gai-aio-0.9.tar.gz (26.5 kB view details)

Uploaded Source

File details

Details for the file gai-aio-0.9.tar.gz.

File metadata

  • Download URL: gai-aio-0.9.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for gai-aio-0.9.tar.gz
Algorithm Hash digest
SHA256 22f2070b6ab979b6a1efc90e1b570e73a326565a5d485c99ae9b20fc66fe167e
MD5 39ccb6cf9747b56ea0a0b3712a803831
BLAKE2b-256 dc9090b8e36f5c6b2a1154de5a81fe778d86f00a6540783b5248a886ed0c8805

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page