tinyagent-ts
Version:
Modern TypeScript framework for building AI agents with pluggable tools and ReAct reasoning
54 lines (53 loc) • 1.23 kB
TypeScript
/**
* Message structure for LLM communication
*/
export interface LLMMessage {
role: 'system' | 'user' | 'assistant';
content: string;
}
/**
* Configuration for model requests
*/
export interface ModelConfig {
model: string;
apiKey: string;
maxRetries?: number;
timeout?: number;
}
/**
* Response from LLM model
*/
export interface ModelResponse {
content: string;
usage?: {
promptTokens?: number;
completionTokens?: number;
totalTokens?: number;
};
}
/**
* Abstract interface for LLM model providers
*/
export interface ModelProvider {
/**
* Send messages to the model and get a response
*/
chat(messages: LLMMessage[], config: ModelConfig, abortSignal?: AbortSignal): Promise<ModelResponse>;
/**
* Get the provider name
*/
getName(): string;
}
/**
* Model error types
*/
export declare class ModelError extends Error {
readonly statusCode?: number | undefined;
constructor(message: string, statusCode?: number | undefined);
}
export declare class ModelTimeoutError extends ModelError {
constructor(message?: string);
}
export declare class ModelAbortError extends ModelError {
constructor(message?: string);
}