Skip to content

Small fix in isItemTooBig #5154

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 4 commits into from
Apr 25, 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
9 changes: 3 additions & 6 deletions core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,19 +739,16 @@ export class Core {

private async isItemTooBig(item: ContextItemWithId) {
const { config } = await this.configHandler.loadConfig();

if (!config) {
return false;
}

const llm = (await this.configHandler.loadConfig()).config
?.selectedModelByRole.chat;


const llm = config?.selectedModelByRole.chat;
if (!llm) {
throw new Error("No chat model selected");
}

const tokens = countTokens(item.content);
const tokens = countTokens(item.content, llm.model);

if (tokens > llm.contextLength - llm.completionOptions!.maxTokens!) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion gui/src/components/mainInput/AtMentionDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ const AtMentionDropdown = forwardRef((props: AtMentionDropdownProps, ref) => {
modal: true,
detail:
fileSize > 0
? `'${item.title}' is ${formatFileSize(fileSize)} which exceeds the allowed context length and connot be processed by the model`
? `'${item.title}' is ${formatFileSize(fileSize)} which exceeds the allowed context length and cannot be processed by the model`
: `'${item.title}' could not be loaded. Please check if the file exists and has the correct permissions.`,
},
);
Expand Down
Loading