import { Awaitable, Computed, Context, Dict, Schema, Service, Session } from 'koishi'; import { ChatInterface } from 'koishi-plugin-chatluna/llm-core/chat/app'; import { Cache } from '../cache'; import { ChatChain } from '../chains/chain'; import { ChatLunaLLMChainWrapper } from 'koishi-plugin-chatluna/llm-core/chain/base'; import { type ChatLunaAgent, type CreateChatLunaAgentOptions } from 'koishi-plugin-chatluna/llm-core/agent'; import { BasePlatformClient } from 'koishi-plugin-chatluna/llm-core/platform/client'; import { ClientConfig, ClientConfigPool } from 'koishi-plugin-chatluna/llm-core/platform/config'; import { ChatLunaChatModel } from 'koishi-plugin-chatluna/llm-core/platform/model'; import { ChatLunaReranker } from 'koishi-plugin-chatluna/llm-core/platform/rerank'; import { PlatformService, ToolMaskArg, ToolMaskResolver } from 'koishi-plugin-chatluna/llm-core/platform/service'; import { ChatLunaTool, CreateChatLunaLLMChainParams, CreateVectorStoreFunction, PlatformClientNames } from 'koishi-plugin-chatluna/llm-core/platform/types'; import { PresetService } from 'koishi-plugin-chatluna/preset'; import { ChatInvocationInput, ChatInvocationResult, ConversationRecord, Message } from '../types'; import { MessageTransformer } from './message_transform'; import { ChatCallbackProviderInput, ChatCallbacksProvider } from './types'; import { ConversationService } from './conversation'; import { type ChatOptions, ConversationRuntime } from './conversation_runtime'; import { ChatRuntime } from '../llm-core/chat/runtime'; import * as fetchType from 'undici/types/fetch'; import { ClientOptions, WebSocket } from 'ws'; import { ClientRequestArgs } from 'http'; import { Config } from '../config'; import { DefaultRenderer, Renderer } from 'koishi-plugin-chatluna'; import { ChatLunaPromptRenderService } from './prompt_renderer'; import { ComputedRef } from '@vue/reactivity'; import { Embeddings } from '@langchain/core/embeddings'; import { ChatLunaContextManagerService } from 'koishi-plugin-chatluna/llm-core/prompt'; export type { ChatInvocationContext, ChatInvocationInput, ChatInvocationResult, ChatInvocationRouting } from '../types'; export declare class ChatLunaService extends Service { readonly ctx: Context; private _plugins; private readonly _chain; private readonly _keysCache; private readonly _preset; private readonly _platformService; private readonly _messageTransformer; private readonly _renderer; private readonly _promptRenderer; private readonly _contextManager; private readonly _conversation; private readonly _conversationRuntime; private readonly _chatRuntime; private readonly _callbackProviders; config: Config; currentConfig: Config; constructor(ctx: Context, config: Config); installPlugin(plugin: ChatLunaPlugin): Promise; awaitLoadPlatform(plugin: ChatLunaPlugin | string, timeout?: number): Promise; uninstallPlugin(plugin: ChatLunaPlugin | string): void; registerToolMaskResolver(name: string, resolver: ToolMaskResolver): () => void; resolveToolMask(arg: ToolMaskArg): Promise; getPlugin(platformName: string): ChatLunaPlugin; invoke(input: ChatInvocationInput): Promise; chat(session: Session, conversation: ConversationRecord, message: Message, options?: ChatOptions): Promise; registerCallbacksProvider(provider: ChatCallbacksProvider): () => void; resolveCallbacks(input: ChatCallbackProviderInput): Promise; clearCache(conversation: ConversationRecord): Promise; createChatInterface(conversation: ConversationRecord): Promise; createChatModel(platform: string, modelName: string): Promise>; createChatModel(fullModelName: string): Promise>; createEmbeddings(platformName: string, modelName: string): Promise>; createEmbeddings(fullModelName: string): Promise>; createReranker(platformName: string, modelName: string): Promise>; createReranker(fullModelName: string): Promise>; createAgent(options: CreateChatLunaAgentOptions): Promise; get platform(): PlatformService; get cache(): Cache<"chatluna/keys", string>; get preset(): PresetService; get chatChain(): ChatChain; get messageTransformer(): MessageTransformer; get renderer(): DefaultRenderer; get promptRenderer(): ChatLunaPromptRenderService; get contextManager(): ChatLunaContextManagerService; get conversation(): ConversationService; get conversationRuntime(): ConversationRuntime; get chatRuntime(): ChatRuntime; protected stop(): Promise; private _createTempDir; private _dedupeConstraintNames; private _defineDatabase; static inject: string[]; } export declare class ChatLunaPlugin { protected ctx: Context; readonly config: T; platformName: PlatformClientNames; private _supportModels; readonly platformConfigPool: ClientConfigPool; private _platformService; constructor(ctx: Context, config: T, platformName: PlatformClientNames, createConfigPool?: boolean); parseConfig(f: (config: T) => R[]): void; private createRunnableConfig; initClient(): Promise; get supportedModels(): readonly string[]; registerToService(): void; registerClient(func: () => BasePlatformClient, platformName?: string): void; registerVectorStore(name: string, func: CreateVectorStoreFunction): void; registerTool(name: string, tool: ChatLunaTool): void; registerChatChainProvider(name: string, description: Dict, func: (params: CreateChatLunaLLMChainParams) => ChatLunaLLMChainWrapper): void; registerRenderer(name: string, renderer: (ctx: Context, config: Config) => Renderer): void; fetch(info: fetchType.RequestInfo, init?: fetchType.RequestInit, proxy?: string): Promise; ws(url: string, options?: ClientOptions | ClientRequestArgs): WebSocket; } export declare namespace ChatLunaPlugin { interface Config { chatConcurrentMaxSize?: number; chatTimeLimit?: Computed>; timeout?: number; configMode: string; maxRetries: number; proxyMode: string; proxyAddress: string; } const Config: Schema; } export * from './prompt_renderer'; export * from './types'; export * from './message_transform'; export * from '../llm-core/prompt/context_manager';