UNPKG

@bobmatnyc/ai-code-review

Version:

A TypeScript-based tool for automated code reviews using AI models from Google Gemini, Anthropic Claude, and OpenRouter

56 lines (55 loc) 2.3 kB
/** * @fileoverview Anthropic API client for making API requests. * * This module handles the direct interactions with the Anthropic API, * including making requests, handling responses, and managing retries. * It provides a clean interface for other components to interact with * the Anthropic API without dealing with the HTTP details. */ /** * Interface for responses from the Anthropic API */ export interface AnthropicResponse { content: Array<{ text: string; }>; } /** * Fetches from the Anthropic API with retry logic * @param url API endpoint URL * @param options Request options * @param retries Number of retries to attempt * @returns Promise resolving to the response */ export declare function fetchWithRetry(url: string, options: RequestInit, retries?: number): Promise<Response>; /** * Makes a simple test request to validate API access * @param apiKey The Anthropic API key * @param modelName The model name to use * @returns Promise resolving to a boolean indicating success */ export declare function testAnthropicApiAccess(apiKey: string, modelName: string): Promise<boolean>; /** * Makes a request to the Anthropic API for message completion * @param apiKey The Anthropic API key * @param modelName The model name to use * @param systemPrompt The system prompt * @param userPrompt The user prompt * @param temperature The temperature parameter * @param tools Optional tools for tool calling * @returns Promise resolving to the response data */ export declare function makeAnthropicRequest(apiKey: string, modelName: string, systemPrompt: string, userPrompt: string, temperature?: number, tools?: Record<string, unknown>[]): Promise<AnthropicResponse>; /** * Makes a request to the Anthropic API with a full conversation history * @param apiKey The Anthropic API key * @param modelName The model name to use * @param messages The full conversation history * @param temperature The temperature parameter * @returns Promise resolving to the response data * @throws Error if the API request fails or returns invalid data */ export declare function makeAnthropicConversationRequest(apiKey: string, modelName: string, messages: Array<{ role: string; content: unknown; }>, temperature?: number): Promise<AnthropicResponse>;