selvedge
Version:
A type-safe, declarative DSL for building robust, composable LLM prompts and programs in TypeScript. Selvedge simplifies prompt engineering, structured output, and multi-model orchestration.
66 lines • 2.03 kB
TypeScript
/**
* Mock LLM provider for testing
*/
import { ModelDefinition, ModelAdapter, ApiClientConfig } from '../../types';
/**
* Mock-specific configuration options
*/
export interface MockConfig extends ApiClientConfig {
/** Predefined responses for testing */
responses?: {
/** Default response for completions */
completion?: string;
/** Default response for chat */
chat?: string | ((messages: any[]) => string);
/** Response map for specific prompts */
promptMap?: Record<string, string>;
};
/** Deliberately fail requests for testing error handling */
shouldFail?: boolean;
/** Delay responses to simulate network latency (ms) */
responseDelay?: number;
}
/**
* Adapter for mock models - useful for testing
*/
export declare class MockModelAdapter implements ModelAdapter {
private modelDef;
private config;
/**
* Create a new Mock adapter
*
* @param modelDef - The model definition
*/
constructor(modelDef: ModelDefinition);
/**
* Helper to simulate network delay
*/
private delay;
/**
* Set the mock responses for testing
*
* @param responses - Object containing completion and chat responses
*/
setResponses(responses: {
completion?: string;
chat?: string | ((messages: any[]) => string);
promptMap?: Record<string, string>;
}): void;
/**
* Send a completion request to mock provider
*
* @param prompt - The prompt text
* @param options - Additional options for the request
* @returns The completion text
*/
complete(prompt: string, options?: Record<string, any>): Promise<string>;
/**
* Send a chat request to mock provider
*
* @param messages - Array of chat messages
* @param options - Additional options for the request
* @returns The chat response
*/
chat(messages: any[], options?: Record<string, any>): Promise<string>;
}
//# sourceMappingURL=mock.d.ts.map