UNPKG

@bobmatnyc/ai-code-review

Version:

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

42 lines (41 loc) 1.76 kB
/** * @fileoverview Common response processing and error handling for AI API clients. * * This module provides shared functionality for processing API responses, * extracting structured data, handling errors, and standardizing output formats * across different AI providers. */ import { ReviewResult, ReviewType } from '../../types/review'; import { StructuredReview } from '../../types/structuredReview'; import { ApiError } from '../../utils/apiErrorHandler'; /** * Process API response content and extract structured data if possible * @param content The API response content * @returns Structured data object or null if not valid JSON */ export declare function extractStructuredData(content: string): StructuredReview | undefined; /** * Create a standardized review result object * @param content The review content * @param prompt The original prompt (for cost calculation) * @param modelName The full model name * @param filePath The file path or identifier * @param reviewType The review type * @returns Standardized review result */ export declare function createStandardReviewResult(content: string, prompt: string, modelName: string, filePath: string, reviewType: ReviewType): ReviewResult; /** * Handle API errors with standardized logging and wrapping * @param error The original error * @param operation Description of the operation that failed * @param modelName The model being used * @param context Additional context for debugging * @returns Wrapped ApiError */ export declare function handleApiError(error: unknown, operation: string, modelName: string, context?: { endpoint?: string; statusCode?: number; requestId?: string; filePath?: string; additionalInfo?: Record<string, any>; }): ApiError;