项目文件夹

0
rohit-rptless 3ae441039d
Lint / build_and_test (3.10) (push) Has been cancelled
Lint / build_and_test (3.11) (push) Has been cancelled
Lint / build_and_test (3.12) (push) Has been cancelled
Lint / lint (push) Has been cancelled
Port google_interface to google_provider
Using the new Provider interface.
2024-09-12 15:10:10 -07:00
2024-09-01 10:22:07 -05:00
2024-08-26 22:37:01 -05:00
2024-09-01 10:22:07 -05:00
2024-08-23 21:35:10 -05:00
2024-09-01 10:22:07 -05:00
2024-09-01 10:22:07 -05:00

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.

Installation

pip install aisuite

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 and install the provider specific library to use.

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"

Install the respective client libraries:

pip install openai anthropic

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)

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

The current list of supported providers can be found in the aisuite.providers package.

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