UNPKG

@bobmatnyc/ai-code-review

Version:

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

69 lines (68 loc) 2.36 kB
/** * @fileoverview LangChain prompt strategy implementation. * * This module implements a prompt strategy using LangChain for enhanced prompt * management, templating, and chain capabilities. */ import { ReviewOptions } from '../../types/review'; import { PromptStrategy } from './PromptStrategy'; import { PromptManager } from '../PromptManager'; import { PromptCache } from '../cache/PromptCache'; import { FewShotPromptTemplate } from '@langchain/core/prompts'; /** * LangChain-based prompt strategy implementation */ export declare class LangChainPromptStrategy extends PromptStrategy { /** * Create a new LangChain prompt strategy * @param promptManager Prompt manager instance * @param promptCache Prompt cache instance */ constructor(promptManager: PromptManager, promptCache: PromptCache); /** * Format a prompt using LangChain * @param prompt Raw prompt * @param options Review options * @returns Formatted prompt */ formatPrompt(prompt: string, options: ReviewOptions): Promise<string>; /** * Create a few-shot prompt template * @param prefix The prefix text for the prompt * @param examples The few-shot examples to include * @param suffix The suffix text for the prompt * @param options Review options * @returns FewShotPromptTemplate */ createFewShotTemplate(prefix: string, examples: Array<Record<string, string>>, suffix: string, _options: ReviewOptions): FewShotPromptTemplate; /** * Create a template string for examples * @param variables The variables in the example * @returns Example template string */ private createExampleTemplateString; /** * Create input values from review options * @param options Review options * @param inputVariables Input variables from the template * @returns Input values */ private createInputValuesFromOptions; /** * Basic prompt formatting fallback * @param prompt Raw prompt * @param options Review options * @returns Formatted prompt */ private basicFormatPrompt; /** * Get the name of the strategy * @returns Strategy name */ getName(): string; /** * Get the description of the strategy * @returns Strategy description */ getDescription(): string; }