Multi LLM Configuration
Developers can define configurations for multiple AI language models and specify strategies to optimize their usage. This documentation explains the properties and strategies available for configuring multiple LLMs in the AI Agent State.
Multi LLM Configuration Properties
The multi LLM configuration allows developers to specify multiple AI language models and define strategies for using them. Below are the key properties that can be defined, along with examples for each:
Strategy
The strategy
property defines how multiple AI language models should be used. It includes the mode of operation and the status codes that trigger the strategy.
Name:
strategy
Type:
object
Description: The strategy to use when multiple AI language models are employed. This can include strategies such as fallback mechanisms, load balancing, and other techniques to ensure robust and reliable AI performance.
Properties:
Mode: Defines the mode for handling the request. It can be
single
,fallback
, orloadbalance
.OnStatusCodes: An array of status codes that trigger the strategy.
Example:
Targets
The targets
property specifies the list of AI language models to use. Each target includes details about the provider, API key, and optional configuration parameters.
Name:
targets
Type:
array
Description: The list of AI language models to use.
Properties:
Provider: The name of the provider offering the AI language model services.
API Key: The API key used to authenticate and access the AI language model services provided by the chosen provider.
Weight: (Optional) The weight of the provider, used for load balancing.
Strategy: (Optional) The strategy to use for the target.
Targets: (Optional) The list of LLM provider configurations for the target.
Example:
Supported Strategies
Single Mode
In single
mode, the AI agent uses a single AI language model for handling requests. This is the simplest strategy and does not involve any fallback or load balancing.
Example:
Fallback Mode
In fallback
mode, the AI agent attempts to use the primary AI language model. If it encounters specified status codes (e.g., errors or rate limits), it automatically switches to the next model in the list.
Example:
Loadbalance Mode
In loadbalance
mode, the AI agent distributes requests across multiple AI language models based on their defined weights. This ensures efficient utilization of resources and prevents any single model from becoming a bottleneck.
Example:
Usage Example
To use a multi LLM configuration in your AI Agent State, you can define the configuration in the state definition. Here is an example of how to configure an AI Agent State using multiple LLMs with a fallback strategy:
Last updated