jorel
Version:
A unified wrapper for working with LLMs from multiple providers, including streams, images, documents & automatic tool use.
27 lines (26 loc) • 1.32 kB
TypeScript
import { AnthropicBedrock } from "@anthropic-ai/bedrock-sdk";
import Anthropic from "@anthropic-ai/sdk";
import { LlmCoreProvider, LlmGenerationConfig, LlmMessage, LlmResponse, LlmStreamProviderResponseChunkEvent, LlmStreamResponseEvent } from "../../providers";
export interface AnthropicConfig {
apiKey?: string;
bedrock?: {
awsRegion?: string;
awsAccessKey?: string;
awsSecretKey?: string;
};
name?: string;
maxRetries?: number;
timeout?: number;
}
/** Provides access to OpenAI and other compatible services */
export declare class AnthropicProvider implements LlmCoreProvider {
static readonly defaultName = "anthropic";
readonly name: string;
readonly client: AnthropicBedrock | Anthropic;
constructor({ apiKey, bedrock, name, maxRetries, timeout }?: AnthropicConfig);
private parseAnthropicError;
generateResponse(model: string, messages: LlmMessage[], config?: LlmGenerationConfig): Promise<LlmResponse>;
generateResponseStream(model: string, messages: LlmMessage[], config?: LlmGenerationConfig): AsyncGenerator<LlmStreamProviderResponseChunkEvent | LlmStreamResponseEvent, void, unknown>;
getAvailableModels(): Promise<string[]>;
createEmbedding(model: string, text: string, abortSignal?: AbortSignal): Promise<number[]>;
}