@unified-llm/core
Version:
Unified LLM interface.
73 lines (72 loc) • 2.55 kB
TypeScript
import BaseProvider from './providers/base-provider';
import { Tool } from './types/unified-api';
import { LLMClientConfig as StoredLLMClientConfig } from './database/schema';
export interface LLMClientRuntimeConfig {
id?: string;
provider: 'openai' | 'anthropic' | 'google' | 'deepseek' | 'azure';
apiKey: string;
model?: string;
tools?: Tool[];
generationConfig?: {
temperature?: number;
max_tokens?: number;
top_p?: number;
frequency_penalty?: number;
presence_penalty?: number;
stop_sequences?: string[];
response_format?: any;
};
systemPrompt?: string;
instructions?: string;
}
export type LLMClientConfig = StoredLLMClientConfig;
export declare class LLMClient {
private baseProvider;
private tools?;
private id?;
private systemPrompt?;
constructor(config: LLMClientRuntimeConfig);
static create(provider: 'openai' | 'anthropic' | 'google' | 'deepseek', apiKey: string, model: string): BaseProvider;
private generateToolDefinitions;
private executeFunction;
chat(request: any): Promise<import("./types/unified-api").UnifiedChatResponse>;
stream(request: any): AsyncGenerator<import("./types/unified-api").UnifiedChatResponse, void, any>;
private generateMessageId;
/**
* 保存されたアシスタント設定からLLMClientインスタンスを作成
*/
static fromSaved(id: string, apiKey?: string): Promise<LLMClient>;
/**
* LLMクライアント設定を保存
*/
static save(config: LLMClientConfig): Promise<string>;
/**
* 保存されたアシスタントの一覧を取得
*/
static list(options?: {
provider?: 'openai' | 'anthropic' | 'google' | 'deepseek';
tags?: string[];
includeInactive?: boolean;
}): Promise<LLMClientConfig[]>;
/**
* 保存されたアシスタント設定を取得
*/
static getConfig(id: string): Promise<LLMClientConfig | null>;
/**
* アシスタント設定を更新
*/
static update(id: string, updates: Partial<LLMClientConfig>): Promise<boolean>;
/**
* アシスタントを削除(論理削除)
*/
static delete(id: string): Promise<boolean>;
/**
* アシスタントを物理削除
*/
static hardDelete(id: string): Promise<boolean>;
/**
* 現在のアシスタント設定を保存
*/
saveConfiguration(name: string, description?: string): Promise<string>;
}
export default LLMClient;