Skip to main content

Uniform access layer for LLMs

Project description

aisuite

Code style: black

Simple, unified interface to multiple Generative AI providers.

aisuite is an tool designed for researchers who need to evaluate and compare the responses of multiple LLMs through a standardized interface. Based on the OpenAI interface standard, aisuite makes it easy to interact with the most popular LLMs and compare the results of their chat based functionality, with support for more interfaces coming in the near future.

Currently supported providers are - OpenAI, Anthropic, Azure, Google, AWS, Groq, Mistral, HuggingFace and Ollama. Internally, aisuite uses either the HTTP endpoint or the SDK for making calls to the provider.

Installation

This installs just the base package without installing any provider's SDK.

pip install aisuite

This installs anthropic along with anthropic

pip install aisuite[anthropic]

This installs all the provider specific libraries

pip install aisuite[all]

Set up

This library provides a thin wrapper around python client libraries to interact with various Generative AI providers allowing creators to seamlessly swap out or test responses from a number of LLMs without changing their code.

To get started you will need the API Keys for the providers you intend to use. You also need to install the provider specific library to use either separately or when installing aisuite.

The API Keys are expected to be in the host ENV and can be set manually or by using a tool such as python-dotenv or direnv.

For example if you wanted to use Antrophic's Claude 3.5 Sonnet in addition to OpenAI's ChatGPT 4o you would first need to set the API keys:

export ANTHROPIC_API_KEY="your-anthropic-api-key"
export OPENAI_API_KEY="your-openai-api-key"

In your python code:

import aisuite as ai
client = ai.Client()

models = ["openai:gpt-4o", "anthropic:claude-3-5-sonnet-20240620"]

messages = [
    {"role": "system", "content": "Respond in Pirate English."},
    {"role": "user", "content": "Tell me a joke."},
]

for model in models:
    response = client.chat.completions.create(
        model=model,
        messages=messages,
        temperature=0.75
    )
    print(response.choices[0].message.content)

Note that the model name in the create() call needs to be replaced with <provider>:<model-name> aisuite will call the appropriate provider with the right parameters based on the provider value. The current list of supported providers can be found by executing aisuite.ProviderNames.values()

For more examples, check out the examples directory where you will find several notebooks that you can run to experiment with the interface.

License

aisuite is released under the MIT License. You are free to use, modify, and distribute the code for both commercial and non-commercial purposes.

Contributing

If you would like to contribute, please read our Contributing Guide

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

aisuite-0.1.4.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aisuite-0.1.4-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file aisuite-0.1.4.tar.gz.

File metadata

  • Download URL: aisuite-0.1.4.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for aisuite-0.1.4.tar.gz
Algorithm Hash digest
SHA256 9c8a6b64e8dcd21c909374718f5f4e1128bbb19bed46fa9bb705e5413e9af9c3
MD5 9bcf3a426eb40a0485acbab3d9ec7e37
BLAKE2b-256 f87cbc61635c93efb71861dd26b0a76b3a0dd5647565bbef6d28486c43390b84

See more details on using hashes here.

File details

Details for the file aisuite-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: aisuite-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for aisuite-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3ab3641dcaacc0f7a67b02d6183563cf787f2a0aede4f11b12ec72da1bbed76e
MD5 d91a4bdb251c1857b5adc6bb4bf3f17f
BLAKE2b-256 c9eb64deb10965762b2d42dde88c35d7d476be4bc3c2474ed024324650c34e6f

See more details on using hashes here.

Supported by

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