Skip to content

Remove unused output token instructions (#138) #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions src/agent/structured-output/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ abstract class BaseProcessor {
}
}

export interface CodeSummaryOutput {
name: string
path: string
export interface SummaryOutput {
summary: string
usage: string
}
Expand Down Expand Up @@ -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<CodeSummaryOutput | null> {
async generate(code: string, repoInfo: RepoInfo): Promise<SummaryOutput | null> {
const extension = repoInfo.path.split('.').pop()
if (!extension) {
console.warn('No extension found in the file path')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<FolderSummaryOutput | null> {
async generate(folder: string[], repoInfo: RepoInfo): Promise<SummaryOutput | null> {

const prompt = await this.promptGenerator.generate(
{
Expand Down
39 changes: 1 addition & 38 deletions src/agent/structured-output/schema-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
7 changes: 3 additions & 4 deletions src/service/insert-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading