Skip to content

Commit ed790eb

Browse files
committed
automatically adapt different models' context length
1 parent 912412f commit ed790eb

File tree

12 files changed

+31
-17
lines changed

12 files changed

+31
-17
lines changed

src/content-script/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ async function prepareForRightClickMenu() {
232232
const menuItem = menuConfig[data.itemId]
233233
if (!menuItem.genPrompt) return
234234
else prompt = await menuItem.genPrompt()
235-
if (prompt) prompt = cropText(`Reply in ${await getPreferredLanguage()}.\n` + prompt)
235+
if (prompt) prompt = await cropText(`Reply in ${await getPreferredLanguage()}.\n` + prompt)
236236
}
237237

238238
const position = data.useMenuPosition

src/content-script/site-adapters/bilibili/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default {
5050
else subtitleContent += subtitles[i].content + ','
5151
}
5252

53-
return cropText(
53+
return await cropText(
5454
`用尽量简练的语言,联系视频标题,对视频进行内容摘要,同时仍要保留重要细节,视频标题为:"${title}",字幕内容为:\n${subtitleContent}`,
5555
)
5656
} catch (e) {

src/content-script/site-adapters/github/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default {
4040
const patchData = await getPatchData(patchUrl)
4141
if (!patchData) return
4242

43-
return cropText(
43+
return await cropText(
4444
`Analyze the contents of a git commit,provide a suitable commit message,and summarize the contents of the commit.` +
4545
`The patch contents of this commit are as follows:\n${patchData}`,
4646
)

src/content-script/site-adapters/gitlab/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default {
2222
const patchData = await getPatchData(patchUrl)
2323
if (!patchData) return
2424

25-
return cropText(
25+
return await cropText(
2626
`Analyze the contents of a git commit,provide a suitable commit message,and summarize the contents of the commit.` +
2727
`The patch contents of this commit are as follows:\n${patchData}`,
2828
)

src/content-script/site-adapters/juejin/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
for (let i = 1; i <= comments.length && i <= 4; i++) {
2121
comment += `answer${i}: ${comment[i - 1].textContent}|`
2222
}
23-
return cropText(
23+
return await cropText(
2424
`以下是一篇文章,标题是:"${title}",作者是:"${author}",内容是:\n"${description}".各个评论如下:\n${comment}.请以如下格式输出你的回答:
2525
{文章摘要和文章作者}
2626
======

src/content-script/site-adapters/quora/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default {
1414
answers += `answer${i}:${texts[i].textContent}|`
1515
}
1616

17-
return cropText(
17+
return await cropText(
1818
`Below is the content from a question and answer platform,giving the corresponding summary and your opinion on it.` +
1919
`The question is:'${title}',` +
2020
`Some answers are as follows:\n${answers}`,

src/content-script/site-adapters/reddit/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313
answers += `answer${i}:${texts[i].textContent}|`
1414
}
1515

16-
return cropText(
16+
return await cropText(
1717
`Below is the content from a social forum,giving the corresponding summary and your opinion on it.` +
1818
`The title is:'${title}',and the further description of the title is:'${description}'.` +
1919
`Some answers are as follows:\n${answers}`,

src/content-script/site-adapters/stackoverflow/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313
answer += `answer${i}: ${answers[i - 1].textContent}|`
1414
}
1515

16-
return cropText(
16+
return await cropText(
1717
`Below is the content from a developer Q&A platform. Analyze answers and provide a brief solution that can solve the question first,` +
1818
`then give an overview of all answers. The question is: "${title}", and the further description of the question is: "${description}".` +
1919
`The answers are as follows:\n${answer}`,

src/content-script/site-adapters/weixin/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default {
1919
sidebar.style.background = 'transparent'
2020
}
2121

22-
return cropText(
22+
return await cropText(
2323
`以下是一篇文章,标题是:"${title}",文章来源是:"${author}公众号",内容是:\n"${description}".请以如下格式输出你的回答:
2424
{文章来源和文章摘要}
2525
======

src/content-script/site-adapters/youtube/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default {
5252

5353
subtitleContent = replaceHtmlEntities(subtitleContent)
5454

55-
return cropText(
55+
return await cropText(
5656
`Provide a structured summary of the following video in markdown format, focusing on key takeaways and crucial information, and ensuring to include the video title. The summary should be easy to read and concise, yet comprehensive.` +
5757
`The video title is "${title}". The subtitle content is as follows:\n${subtitleContent}`,
5858
)

0 commit comments

Comments
 (0)