AxBalancer
Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L62
Balancer that rotates through services.
Type Parameters
| Type Parameter | Default type |
|---|---|
TServices extends readonly AxAIService<any, any, any>[] | readonly AxAIService[] |
TModelKey | ExtractAllModelKeys<TServices> |
Implements
AxAIService<unknown,unknown,TModelKey>
Constructors
Constructor
new AxBalancer<TServices, TModelKey>(services: TServices, options?: AxBalancerOptions<TModelKey>): AxBalancer<TServices, TModelKey>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L83
Parameters
| Parameter | Type |
|---|---|
services | TServices |
options? | AxBalancerOptions<TModelKey> |
Returns
AxBalancer<TServices, TModelKey>
Methods
chat()
chat(req: Readonly<AxChatRequest<TModelKey>>, options?: Readonly<AxAIServiceOptions>): Promise<
| AxChatResponse
| ReadableStream<AxChatResponse>>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L393
Parameters
| Parameter | Type |
|---|---|
req | Readonly<AxChatRequest<TModelKey>> |
options? | Readonly<AxAIServiceOptions> |
Returns
Promise<
| AxChatResponse
| ReadableStream<AxChatResponse>>
Implementation of
embed()
embed(req: Readonly<AxEmbedRequest<TModelKey>>, options?: Readonly<AxAIServiceOptions>): Promise<AxEmbedResponse>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L532
Parameters
| Parameter | Type |
|---|---|
req | Readonly<AxEmbedRequest<TModelKey>> |
options? | Readonly<AxAIServiceOptions> |
Returns
Promise<AxEmbedResponse>
Implementation of
getEstimatedCost()
getEstimatedCost(modelUsage?: AxModelUsage): number;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L347
Parameters
| Parameter | Type |
|---|---|
modelUsage? | AxModelUsage |
Returns
number
Implementation of
getFeatures()
getFeatures(model?: string): AxAIFeatures;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L203
Parameters
| Parameter | Type |
|---|---|
model? | string |
Returns
Implementation of
getId()
getId(): string;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L199
Returns
string
Implementation of
getLastUsedChatModel()
getLastUsedChatModel(): unknown;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L116
Returns
unknown
Implementation of
AxAIService.getLastUsedChatModel
getLastUsedEmbedModel()
getLastUsedEmbedModel(): unknown;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L119
Returns
unknown
Implementation of
AxAIService.getLastUsedEmbedModel
getLastUsedModelConfig()
getLastUsedModelConfig(): undefined | AxModelConfig;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L122
Returns
undefined | AxModelConfig
Implementation of
AxAIService.getLastUsedModelConfig
getLogger()
getLogger(): AxLoggerFunction;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L619
Returns
Implementation of
getMetrics()
getMetrics(): AxAIServiceMetrics;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L260
Returns
Implementation of
getModelList()
getModelList():
| undefined
| AxAIModelList<TModelKey>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L160
Returns
| undefined
| AxAIModelList<TModelKey>
Implementation of
getName()
getName(): string;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L195
Returns
string
Implementation of
getOptions()
getOptions(): Readonly<AxAIServiceOptions>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L615
Returns
Readonly<AxAIServiceOptions>
Implementation of
setOptions()
setOptions(options: Readonly<AxAIServiceOptions>): void;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L605
Parameters
| Parameter | Type |
|---|---|
options | Readonly<AxAIServiceOptions> |
Returns
void
Implementation of
speak()
speak(req: Readonly<AxSpeechRequest<TModelKey>>, options?: Readonly<AxAIServiceOptions>): Promise<AxChatAudioOutput>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L598
Parameters
| Parameter | Type |
|---|---|
req | Readonly<AxSpeechRequest<TModelKey>> |
options? | Readonly<AxAIServiceOptions> |
Returns
Promise<AxChatAudioOutput>
Implementation of
transcribe()
transcribe(req: Readonly<AxTranscriptionRequest<TModelKey>>, options?: Readonly<AxAIServiceOptions>): Promise<AxTranscriptionResponse>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L591
Parameters
| Parameter | Type |
|---|---|
req | Readonly<AxTranscriptionRequest<TModelKey>> |
options? | Readonly<AxAIServiceOptions> |
Returns
Promise<AxTranscriptionResponse>
Implementation of
create()
static create<TServices>(services: TServices, options?: AxBalancerOptions<ExtractAllModelKeys<TServices>>): AxBalancer<TServices, ExtractAllModelKeys<TServices>>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L110
Static factory method for type-safe balancer creation with automatic model key inference.
Type Parameters
| Type Parameter |
|---|
TServices extends readonly AxAIService<any, any, any>[] |
Parameters
| Parameter | Type |
|---|---|
services | TServices |
options? | AxBalancerOptions<ExtractAllModelKeys<TServices>> |
Returns
AxBalancer<TServices, ExtractAllModelKeys<TServices>>
inputOrderComparator()
static inputOrderComparator(): number;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L129
Service comparator that respects the input order of services.
Returns
number
metricComparator()
static metricComparator<TModelKey>(a: AxAIService<unknown, unknown, TModelKey>, b: AxAIService<unknown, unknown, TModelKey>): number;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/ai/balance.ts#L150
Service comparator that sorts services by cost.
Type Parameters
| Type Parameter | Default type |
|---|---|
TModelKey | string |
Parameters
| Parameter | Type |
|---|---|
a | AxAIService<unknown, unknown, TModelKey> |
b | AxAIService<unknown, unknown, TModelKey> |
Returns
number