File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -103,15 +103,21 @@ server.tool(
103103 let isResponseTruncated = false ;
104104
105105 for ( const file of response . files ) {
106- const snippets = file . chunks . map ( chunk => {
107- const content = base64Decode ( chunk . content ) ;
108- return `\`\`\`\n${ content } \n\`\`\``
109- } ) . join ( '\n' ) ;
110106 const numMatches = file . chunks . reduce (
111107 ( acc , chunk ) => acc + chunk . matchRanges . length ,
112108 0 ,
113109 ) ;
114- const text = `file: ${ file . url } \nnum_matches: ${ numMatches } \nrepository: ${ file . repository } \nlanguage: ${ file . language } \n${ includeCodeSnippets ? `snippets:\n${ snippets } ` : '' } ` ;
110+ let text = `file: ${ file . url } \nnum_matches: ${ numMatches } \nrepository: ${ file . repository } \nlanguage: ${ file . language } ` ;
111+
112+ if ( includeCodeSnippets ) {
113+ const snippets = file . chunks . map ( chunk => {
114+ const content = base64Decode ( chunk . content ) ;
115+ return `\`\`\`\n${ content } \n\`\`\``
116+ } ) . join ( '\n' ) ;
117+ text += `\n\n${ snippets } ` ;
118+ }
119+
120+
115121 // Rough estimate of the number of tokens in the text
116122 // @see : https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them
117123 const tokens = text . length / 4 ;
You can’t perform that action at this time.
0 commit comments