Skip to content

Commit c2d6a4b

Browse files
committed
a new option has been added to the general settings to disable cropText, ensuring the full input tokens are always passed. This can improve summarization on sites like YouTube, but note that you should only disable cropText when using a model with a sufficiently long context.
1 parent 4d038dc commit c2d6a4b

File tree

6 files changed

+20
-3
lines changed

6 files changed

+20
-3
lines changed

src/_locales/en/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,6 @@
159159
"Gemini (Web)": "Gemini (Web)",
160160
"Type": "Type",
161161
"Mode": "Mode",
162-
"Custom": "Custom"
162+
"Custom": "Custom",
163+
"Crop Text to ensure the input tokens do not exceed the model's limit": "Crop Text to ensure the input tokens do not exceed the model's limit"
163164
}

src/_locales/zh-hans/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,6 @@
164164
"ChatGLM (GLM-4-Air, 128k)": "ChatGLM (GLM4Air, 性价比, 128k)",
165165
"ChatGLM (GLM-4-0520, 128k)": "ChatGLM (GLM4-0520, 最智能, 128k)",
166166
"ChatGLM (Emohaa)": "ChatGLM (Emohaa, 专业情绪咨询)",
167-
"ChatGLM (CharGLM-3)": "ChatGLM (CharGLM-3, 角色扮演)"
167+
"ChatGLM (CharGLM-3)": "ChatGLM (CharGLM-3, 角色扮演)",
168+
"Crop Text to ensure the input tokens do not exceed the model's limit": "裁剪文本以确保输入token不超过模型限制"
168169
}

src/_locales/zh-hant/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,6 @@
159159
"Gemini (Web)": "Gemini (網頁版)",
160160
"Type": "類型",
161161
"Mode": "模式",
162-
"Custom": "自訂"
162+
"Custom": "自訂",
163+
"Crop Text to ensure the input tokens do not exceed the model's limit": "裁剪文本以確保輸入token不超過模型限制"
163164
}

src/config/index.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ export const defaultConfig = {
370370
customClaudeApiUrl: 'https://api.anthropic.com',
371371
disableWebModeHistory: true,
372372
hideContextMenu: false,
373+
cropText: true,
373374
siteRegex: 'match nothing',
374375
useSiteRegexOnly: false,
375376
inputQuery: '',

src/popup/sections/GeneralPart.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,17 @@ export function GeneralPart({ config, updateConfig, setTabIndex }) {
585585
/>
586586
{t('Focus to input box after answering')}
587587
</label>
588+
<label>
589+
<input
590+
type="checkbox"
591+
checked={config.cropText}
592+
onChange={(e) => {
593+
const checked = e.target.checked
594+
updateConfig({ cropText: checked })
595+
}}
596+
/>
597+
{t("Crop Text to ensure the input tokens do not exceed the model's limit")}
598+
</label>
588599
<br />
589600
<div style={{ display: 'flex', gap: '10px' }}>
590601
<button

src/utils/crop-text.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export async function cropText(
3636
tiktoken = true,
3737
) {
3838
const userConfig = await getUserConfig()
39+
if (!userConfig.cropText) return text
40+
3941
const k = modelNameToDesc(
4042
userConfig.apiMode ? apiModeToModelName(userConfig.apiMode) : userConfig.modelName,
4143
null,

0 commit comments

Comments
 (0)