ai-fetcher
Version:
A Node.js package that provides integration with popular language models. It is designed to facilitate easy and efficient ai-fetching tasks for your application.
25 lines (24 loc) • 1.29 kB
TypeScript
import type { ClaudeMessage, ClaudeModel, ClaudeResult } from "../types.js";
export declare class Claude {
private api;
private headers;
readonly endpoint: string;
readonly model: ClaudeModel;
/**
* Constructs a new instance of Claude class
* @param claudeKey: string - The user's Claude authentication key
* @param model: ClaudeModel - Should be one of the model string provided by Claude
*/
constructor(claudeKey: string, model?: ClaudeModel);
/**
* Generates a response from Claude.
* @param system: string - The system prompt or context that guides the model's behavior.
* @param messages: ClaudeMessage[] - An array of ClaudeMessages representing the conversation history.
* @param temperature (Optional): number - A number between 0 and 1 that controls the randomness of the output. Defaults to 0.
* @param max_tokens (Optional): number - A number represents the maximum output tokens (words or word fragments). Defaults to 1000.
*
* @returns A promise that resolves to a ClaudeResult containing the generated text result.
* @throws An error if the API request fails.
*/
generate(system: string, messages: ClaudeMessage[], temperature?: number, max_tokens?: number): Promise<ClaudeResult>;
}