import { PromptTemplate } from '@langchain/core/prompts'; import { IterableReadableStream } from '@langchain/core/utils/stream'; import { ChainValues } from '@langchain/core/utils/types'; import { IContextToken } from './IContextToken'; import { BaseChatModel } from '@langchain/core/language_models/chat_models'; import z4, { Schema } from 'zod/v4'; import { z } from 'zod'; // Import regular zod for zodSchema // General tool interfaces for AI models interface IAIToolParameterBase { type: string; description?: string; enum?: string[]; required?: boolean; } interface IAIToolParameterObject extends IAIToolParameterBase { type: 'object'; properties: Record; } interface IAIToolParameterArray extends IAIToolParameterBase { type: 'array'; items: IAIToolParameter; } interface IAIToolParameterPrimitive extends IAIToolParameterBase { type: 'string' | 'number' | 'boolean' | 'integer'; } type IAIToolParameter = IAIToolParameterObject | IAIToolParameterArray | IAIToolParameterPrimitive; interface IAIToolSchema { type: 'object'; properties: Record; required?: string[]; } interface IToolCall { id: string; index: number; type: string; function: { name: string; arguments: string | Record }; } interface IAITool { name: string; description: string; input_schema?: IAIToolSchema; zodSchema?: z.ZodTypeAny; // Support for regular Zod schemas blockStream?: boolean; } interface IPromptHyperParameters { temperature: number, max_tokens: number, [key: string]: number } interface IRWSHistoryMessage { content: string, creator: string } interface ILLMChunk { content: string status: string } interface IPromptParams { hyperParameters?: IPromptHyperParameters; input: CompoundInput[]; modelId: string; modelType: string; } type InputType = 'text' | 'image'; interface IPromptEnchantment { enhancementId: string, enhancementName: string, enhancementParams: any, input: CompoundInput } // Forward reference to RWSPrompt to avoid circular dependencies type RWSPrompt = import('../models/prompts/_prompt').default; type IPromptSender = (prompt: RWSPrompt) => Promise; interface IAIRequestOptions { contextToken?: IContextToken | null, intruderPrompt?: string | null, ensureJson?: boolean, debugVars?: any, schema?: z4.core.$ZodType | Schema, tools?: IAITool[] } interface IRWSPromptRequestExecutor { promptRequest: (prompt: RWSPrompt, aiOptions?: IAIRequestOptions) => Promise } interface IRWSSinglePromptRequestExecutor { singlePromptRequest: (prompt: RWSPrompt, aiOptions?: IAIRequestOptions) => Promise } interface IRWSPromptStreamExecutor { promptStream: (prompt: RWSPrompt, read: (chunk: ILLMChunk) => void, end: () => void, aiOptions?: IAIRequestOptions) => Promise } type ToolHandler = (...args: any) => Promise; interface IRWSPromptJSON { input: CompoundInput[]; enhancedInput: IPromptEnchantment[]; sentInput: CompoundInput[]; originalInput: CompoundInput[]; output: string | object; modelId: string; modelType: string; multiTemplate: PromptTemplate; embed?: { id: string }; hyperParameters: IPromptHyperParameters; created_at: string; var_storage: any; } type ChainStreamType = AsyncGenerator>; interface CompoundInputContent{ text?: string, type: InputType, source?: { media_type: string, data: string } } interface CompoundInput { role?: 'user' | 'assistant' | 'system', content: CompoundInputContent | CompoundInputContent[], } export { IPromptSender, IPromptEnchantment, IPromptParams, IPromptHyperParameters, IRWSPromptRequestExecutor, IRWSPromptStreamExecutor, IRWSSinglePromptRequestExecutor, IRWSPromptJSON, ChainStreamType, ILLMChunk, IAIRequestOptions, IAITool, IAIToolSchema, IAIToolParameter, IAIToolParameterBase, IAIToolParameterObject, IAIToolParameterArray, IAIToolParameterPrimitive, IRWSHistoryMessage, InputType, CompoundInput, CompoundInputContent, IToolCall, ToolHandler };