mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Make the ReadManyFiles tool share the "DEFAULT_MAX_LINES_TEXT_FILE=2000" limit across files.
The current implementation can return 2000 x N lines when reading N files, such a length can be either extremely slow or infeasible for LLMs to process.
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
|||||||
processSingleFileContent,
|
processSingleFileContent,
|
||||||
DEFAULT_ENCODING,
|
DEFAULT_ENCODING,
|
||||||
getSpecificMimeType,
|
getSpecificMimeType,
|
||||||
|
DEFAULT_MAX_LINES_TEXT_FILE,
|
||||||
} from '../utils/fileUtils.js';
|
} from '../utils/fileUtils.js';
|
||||||
import { PartListUnion } from '@google/genai';
|
import { PartListUnion } from '@google/genai';
|
||||||
import { Config, DEFAULT_FILE_FILTERING_OPTIONS } from '../config/config.js';
|
import { Config, DEFAULT_FILE_FILTERING_OPTIONS } from '../config/config.js';
|
||||||
@@ -360,6 +361,8 @@ ${finalExclusionPatternsForDescription
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sortedFiles = Array.from(filesToConsider).sort();
|
const sortedFiles = Array.from(filesToConsider).sort();
|
||||||
|
const file_line_limit =
|
||||||
|
DEFAULT_MAX_LINES_TEXT_FILE / Math.max(1, sortedFiles.length);
|
||||||
|
|
||||||
const fileProcessingPromises = sortedFiles.map(
|
const fileProcessingPromises = sortedFiles.map(
|
||||||
async (filePath): Promise<FileProcessingResult> => {
|
async (filePath): Promise<FileProcessingResult> => {
|
||||||
@@ -398,6 +401,8 @@ ${finalExclusionPatternsForDescription
|
|||||||
filePath,
|
filePath,
|
||||||
this.config.getTargetDir(),
|
this.config.getTargetDir(),
|
||||||
this.config.getFileSystemService(),
|
this.config.getFileSystemService(),
|
||||||
|
0,
|
||||||
|
file_line_limit,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fileReadResult.error) {
|
if (fileReadResult.error) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import mime from 'mime-types';
|
|||||||
import { FileSystemService } from '../services/fileSystemService.js';
|
import { FileSystemService } from '../services/fileSystemService.js';
|
||||||
|
|
||||||
// Constants for text file processing
|
// Constants for text file processing
|
||||||
const DEFAULT_MAX_LINES_TEXT_FILE = 2000;
|
export const DEFAULT_MAX_LINES_TEXT_FILE = 2000;
|
||||||
const MAX_LINE_LENGTH_TEXT_FILE = 2000;
|
const MAX_LINE_LENGTH_TEXT_FILE = 2000;
|
||||||
|
|
||||||
// Default values for encoding and separator format
|
// Default values for encoding and separator format
|
||||||
|
|||||||
Reference in New Issue
Block a user