diff --git a/src/agent/structured-output/index.ts b/src/agent/structured-output/index.ts index d309681..0dabb64 100644 --- a/src/agent/structured-output/index.ts +++ b/src/agent/structured-output/index.ts @@ -36,9 +36,7 @@ abstract class BaseProcessor { } } -export interface CodeSummaryOutput { - name: string - path: string +export interface SummaryOutput { summary: string usage: string } @@ -81,7 +79,7 @@ export class CodeProcessor extends BaseProcessor { * @param {RepoInfo} repoInfo - Information about the repository * @returns Processed and parsed JSON object defined in schema factory */ - async generate(code: string, repoInfo: RepoInfo): Promise { + async generate(code: string, repoInfo: RepoInfo): Promise { const extension = repoInfo.path.split('.').pop() if (!extension) { console.warn('No extension found in the file path') @@ -112,13 +110,6 @@ export class CodeProcessor extends BaseProcessor { } } -export interface FolderSummaryOutput { - name: string - usage: string - path: string - summary: string -} - /** * Processes folder-related prompts with specific schema and formatting * @example @@ -154,7 +145,7 @@ export class FolderProcessor extends BaseProcessor { * @param {RepoInfo} repoInfo - Information about the repository * @returns Processed and parsed JSON object defined in schema factory */ - async generate(folder: string[], repoInfo: RepoInfo): Promise { + async generate(folder: string[], repoInfo: RepoInfo): Promise { const prompt = await this.promptGenerator.generate( { diff --git a/src/agent/structured-output/schema-factory.ts b/src/agent/structured-output/schema-factory.ts index 51a8759..b40ba80 100644 --- a/src/agent/structured-output/schema-factory.ts +++ b/src/agent/structured-output/schema-factory.ts @@ -21,31 +21,12 @@ export function getSchema(schemaType: SchemaType): ZodSchema { /* File Schema Example Output: { - "name": "parser.ts", - "path": "src/utils/parser.ts", + "usage": "Parses raw input data and transforms it into a structured format.", "summary": "This file implements a parser for processing input data. The main entry point is the [`parseInput`](#L15-L30) function, which takes raw data and transforms it into a structured format. Error handling is managed within the [`handleParsingErrors`](#L45-L60) function to ensure robustness.", - "relevantCodeBlocks": [ - { - "name": "parseInput", - "description": "The primary function responsible for parsing the input data.", - "startLine": 15, - "endLine": 30 - }, - { - "name": "handleParsingErrors", - "description": "Centralized error handling logic for the parsing process.", - "startLine": 45, - "endLine": 60 - } - ] } */ case SchemaType.FILE: return z.object({ - name: z.string().describe('Name of the file.'), - path: z - .string() - .describe('Path to the file within the repository.'), usage: z .string() .describe( @@ -64,31 +45,13 @@ File Schema Example Output: /* Folder Schema Example Output: { - "name": "components", "usage": "Contains reusable React components for the application's user interface.", - "path": "src/components", "summary": "The `components` folder houses the application's building blocks for the user interface. It includes various reusable components like the [`Button`](src/components/Button.tsx) for user interactions and the [`Modal`](src/components/Modal.tsx) for displaying overlay content. The [`Card`](src/components/Card.tsx) component is used throughout the application to present information in a structured manner.", - "files": [ - { - "fileName": "Button.tsx", - "filePath": "src/components/Button.tsx" - }, - { - "fileName": "Modal.tsx", - "filePath": "src/components/Modal.tsx" - }, - { - "fileName": "Card.tsx", - "filePath": "src/components/Card.tsx" - }, - ], } */ case SchemaType.FOLDER: return z.object({ - name: z.string().describe('Name of the folder.'), usage: z.string().describe('What the folder is used for. Describe less than 10 words (ex. Server Lifecycle Management, API Utility Functions, etc.)'), - path: z.string().describe('Path to the folder.'), summary: z .string() .describe( diff --git a/src/service/insert-db.ts b/src/service/insert-db.ts index 859e863..33dc32c 100644 --- a/src/service/insert-db.ts +++ b/src/service/insert-db.ts @@ -4,9 +4,8 @@ import { Folder, FolderData } from '@/db/models/folder' import { File, FileData } from '@/db/models/file' import { fetchGithubRepoFile, fetchGithubRepoDetails, fetchGithubRepoTree, RepoTreeResult } from '@/github/fetchrepo' import { whitelistedFilter, whitelistedFile, blacklistedFilter, blacklistedFolder, blacklistedFiles, blacklistedFile } from '@/github/filterfile' -import { FolderProcessor, CodeProcessor } from '@/agent/structured-output/index' +import { FolderProcessor, CodeProcessor, SummaryOutput } from '@/agent/structured-output/index' import { LLMProvider } from '@/llm/llm-provider' -import { FolderSummaryOutput, CodeSummaryOutput } from '@/agent/structured-output/index' import { TokenProcessingConfig } from '@/service/config' interface RepoFileInfo { @@ -104,7 +103,7 @@ export class InsertRepoService { console.error(`No content for file ${file.file}`) return null } - let aiSummary: CodeSummaryOutput | null = null + let aiSummary: SummaryOutput | null = null let wordDeduction = 0 let reducedContent = file.content let retries = 0 @@ -171,7 +170,7 @@ export class InsertRepoService { return null } - let aiSummary: FolderSummaryOutput | null = null; + let aiSummary: SummaryOutput | null = null; let totalContentInStr = summaries.join('\n\n') let retries = 0 let summaryDeduction = 0