koishi-plugin-chatluna-plugin-common
Version:
plugin service for agent mode of chatluna
73 lines (72 loc) • 2.27 kB
TypeScript
import { StructuredTool, ToolParams } from '@langchain/core/tools';
import { Context } from 'koishi';
import { ChatLunaPlugin } from 'koishi-plugin-chatluna/services/chat';
import { Config } from '..';
import z from 'zod';
export declare function apply(ctx: Context, config: Config, plugin: ChatLunaPlugin): Promise<void>;
export interface Headers {
[key: string]: string;
}
export interface RequestTool extends ToolParams {
headers: Headers;
maxOutputLength: number;
headerConfigs: {
matcher: string;
headers: Record<string, string>;
}[];
}
export declare class RequestsGetTool extends StructuredTool implements RequestTool {
private _plugin;
headers: Headers;
name: string;
description: string;
schema: z.ZodObject<{
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
url?: string;
}, {
url?: string;
}>;
maxOutputLength: number;
headerConfigs: {
matcher: string;
headers: Record<string, string>;
}[];
constructor(_plugin: ChatLunaPlugin, headers?: Headers, { maxOutputLength, headerConfigs, ...rest }?: {
maxOutputLength?: number;
headerConfigs?: {
matcher: string;
headers: Record<string, string>;
}[];
} & ToolParams);
_call(input: z.infer<typeof this.schema>): Promise<string>;
}
export declare class RequestsPostTool extends StructuredTool implements RequestTool {
private _plugin;
headers: Headers;
name: string;
description: string;
schema: z.ZodObject<{
url: z.ZodString;
data: z.ZodRecord<z.ZodString, z.ZodAny>;
}, "strip", z.ZodTypeAny, {
data?: Record<string, any>;
url?: string;
}, {
data?: Record<string, any>;
url?: string;
}>;
maxOutputLength: number;
headerConfigs: {
matcher: string;
headers: Record<string, string>;
}[];
constructor(_plugin: ChatLunaPlugin, headers?: Headers, { maxOutputLength, headerConfigs, ...rest }?: {
maxOutputLength?: number;
headerConfigs?: {
matcher: string;
headers: Record<string, string>;
}[];
} & ToolParams);
_call(input: z.infer<typeof this.schema>): Promise<string>;
}