import { Awaitable, Context, Dict, Session } from 'koishi'; import { BasePlatformClient } from 'koishi-plugin-chatluna/llm-core/platform/client'; import { ChatLunaChainInfo, ChatLunaTool, ChatLunaToolMeta, CreateChatLunaLLMChainParams, CreateClientFunction, CreateToolParams, CreateVectorStoreFunction, CreateVectorStoreParams, ModelInfo, ModelType, PlatformClientNames, PlatformModelInfo } from 'koishi-plugin-chatluna/llm-core/platform/types'; import { ChatLunaLLMChainWrapper } from '../chain/base'; import { ChatLunaSaveableVectorStore } from 'koishi-plugin-chatluna/llm-core/vectorstores'; import { StructuredTool } from '@langchain/core/tools'; import { ComputedRef } from '@vue/reactivity'; import { RunnableConfig } from '@langchain/core/runnables'; import { ToolMask } from '../agent'; import type { ConversationRecord } from '../../types'; export declare class PlatformService { private ctx; private _platformClients; private _createClientFunctions; private _tools; private _tmpTools; private _toolMaskResolvers; private _models; private _chatChains; private _vectorStore; private _tmpVectorStores; constructor(ctx: Context); registerClient(name: PlatformClientNames, createClientFunction: CreateClientFunction): () => void; registerTool(name: string, toolCreator: ChatLunaTool): () => void; unregisterTool(name: string): void; unregisterClient(platform: PlatformClientNames): void; unregisterVectorStore(name: string): void; registerVectorStore(name: string, vectorStoreRetrieverCreator: CreateVectorStoreFunction): () => void; registerChatChain(name: string, description: Dict, createChatChainFunction: (params: CreateChatLunaLLMChainParams) => ChatLunaLLMChainWrapper): () => void; unregisterChatChain(name: string): void; listPlatformModels(platform: PlatformClientNames, type: ModelType): ComputedRef; findModel(fullModelName: string): ComputedRef; findModel(platform: string, name: string): ComputedRef; getTools(): ComputedRef; getToolRegistry(): Record; getFilteredTools(mask: ToolMask): string[]; registerToolMaskResolver(name: string, resolver: ToolMaskResolver): () => void; resolveToolMask(arg: ToolMaskArg): Promise; static buildToolMask(rule: { mode?: 'inherit' | 'all' | 'allow' | 'deny'; allow?: string[]; deny?: string[]; }): ToolMask; listAllModels(type: ModelType): ComputedRef; get vectorStores(): ComputedRef; get chatChains(): ComputedRef; createVectorStore(name: string, params: CreateVectorStoreParams): Promise>; getClient(platform: string): Promise>>; refreshClient(client: BasePlatformClient, platform: string, config?: RunnableConfig): Promise; createClient(platform: string, config?: RunnableConfig): Promise>; getTool(name: string): { createTool(params: CreateToolParams): StructuredTool; selector: (history: import("@langchain/core/messages").BaseMessage[]) => boolean; authorization?: (session: Session) => boolean; description?: string; name?: string; id?: string; meta?: ChatLunaToolMeta; }; private _createTool; createChatChain(name: string, params: CreateChatLunaLLMChainParams): ChatLunaLLMChainWrapper; dispose(): void; } declare module 'koishi' { interface Events { 'chatluna/chat-chain-added': (service: PlatformService, chain: ChatLunaChainInfo) => void; 'chatluna/model-added': (service: PlatformService, platform: PlatformClientNames, client: BasePlatformClient | BasePlatformClient[]) => void; 'chatluna/embeddings-added': (service: PlatformService, platform: PlatformClientNames, client: BasePlatformClient | BasePlatformClient[]) => void; 'chatluna/vector-store-added': (service: PlatformService, name: string) => void; 'chatluna/chat-chain-removed': (service: PlatformService, chain: ChatLunaChainInfo) => void; 'chatluna/model-removed': (service: PlatformService, platform: PlatformClientNames, client: BasePlatformClient) => void; 'chatluna/vector-store-removed': (service: PlatformService, name: string) => void; 'chatluna/embeddings-removed': (service: PlatformService, platform: PlatformClientNames, client: BasePlatformClient | BasePlatformClient[]) => void; 'chatluna/reranker-added': (service: PlatformService, platform: PlatformClientNames, client: BasePlatformClient | BasePlatformClient[]) => void; 'chatluna/reranker-removed': (service: PlatformService, platform: PlatformClientNames, client: BasePlatformClient) => void; 'chatluna/tool-updated': (service: PlatformService) => void; } } export interface ToolMaskArg { session: Session; conversation?: ConversationRecord; bindingKey?: string; source?: string; } export type ToolMaskResolver = (arg: ToolMaskArg) => Awaitable;