aisuite - Andrew Ng releases open-source Python library, enabling a single interface to call multiple large models.
aisuite is an open-source Python library released by Andrew Ng, designed to provide a unified interface for calling multiple large language model (LLM) services. It supports services including OpenAI, Anthropic, and Azure...
What is AiSuite?
aisuite is an open-source Python library released by Andrew Ng, designed to provide a unified interface for calling multiple large language model (LLM) services. It supports 11 model platforms, including OpenAI, Anthropic, and Azure, allowing developers to easily switch between and test models from different providers. Through aisuite, users can easily obtain API keys and set environment variables to access and call different language models. This simplifies the management and testing of multiple models, promoting the application and development of artificial intelligence technology.
main functions of aisuite
- Unified Interface Designaisuite provides a unified interface that allows developers to call models from different Large Language Model (LLM) platforms in the same way.
- Supports multiple model platformsaisuite supports multiple model platforms, including OpenAI, Anthropic, Azure, Google, AWS, Groq, Mistral, HuggingFace, and Ollama.
- Simplify model switchingUsers can select models from different providers simply by changing a single string, greatly simplifying the process of model switching and comparative testing.
- Easy to install and configureThe installation process of aisuite is simple. Users only need to prepare a Python environment and the required API key, and the framework can be installed through simple commands.
- Focus primarily on chat functionalityCurrently, aisuite is primarily focused on enhancing chat functionality, with plans to expand into more use cases in the future.
- Scalabilityaisuite plans to add more functional modules, such as function calls, to further enrich its usability.
- Use HTTP endpoint or SDK callTo ensure stability, aisuite uses HTTP endpoints or SDKs to make calls with the provider.
aisuite project address
- Github repository:https://github.com/andrewyng/aisuite/pulse
How to use aisuite
- Install aisuiteYou can install aisuite using the pip command.
- Install only the basic package, without involving any vendor's SDK, using the command.
pip install aisuite. - Requires support from specific providers, such as Anthropic, and can be accessed using commands.
pip install 'aisuite (anthropic)'. - To install all vendor-specific libraries, use the command.
pip install 'aisuite (all)'.
- Install only the basic package, without involving any vendor's SDK, using the command.
- Get API KeyAfter installation, you need to obtain an API key for the selected provider and configure it through environment variables.
- Develop a Python clientAfter configuring the API key, you can use a standard Python client to request features such as chat completion. For example, below is sample Python client code using aisuite to generate chat completion responses:
import aisuite as ai client = ai.Client() models = ["openai:gpt-4o", "anthropic:claude-3-5-sonnet-20241022"] 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)
Application scenarios of aisuite
- Chat completion functionCurrently, aisuite mainly focuses on chat completion functionality, allowing developers to generate chat replies by calling different models through a unified interface.
- Model comparison testaisuite supports quick switching between different models by simply changing a string, such as from "openai:gpt-4o" to "anthropic:claude-3-5-sonnet-20241022", making model comparison testing simple.
- Personalized recommendations and servicesaisuite can provide users with personalized recommendations and services by analyzing user behavior and preferences, such as product recommendations on e-commerce platforms and social recommendations on social media.
- Building a chat UIWhen used with tools such as Streamlit, aisuite can be used to build simple chat UI interfaces, further expanding its application in the field of user interaction.