Skip to content

Commit 46f2b1d

Browse files
Merge pull request #866 from ChatGPTBox-dev/codex/強化內建-prompt-使用技巧
2 parents 705e961 + 021a7d5 commit 46f2b1d

File tree

14 files changed

+112
-55
lines changed

14 files changed

+112
-55
lines changed

src/content-script/menu-tools/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const config = {
1313
summarizePage: {
1414
label: 'Summarize Page',
1515
genPrompt: async () => {
16-
return `The following is the text content of a web page, analyze the core content and summarize:\n${getCoreContentText()}`
16+
return `You are an expert summarizer. Carefully analyze the following web page content and provide a concise summary focusing on the key points:\n${getCoreContentText()}`
1717
},
1818
},
1919
openConversationPage: {

src/content-script/selection-tools/index.mjs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ const createGenPrompt =
2727
}
2828

2929
let fullMessage = isTranslation
30-
? `Translate the following into ${preferredLanguage} and only show me the translated content`
30+
? `You are a professional translator. Translate the following text into ${preferredLanguage}, preserving meaning, tone, and formatting. Only provide the translated result.`
3131
: message
3232
if (enableBidirectional) {
33-
fullMessage += `. If it is already in ${preferredLanguage}, translate it into English and only show me the translated content`
33+
fullMessage += ` If the text is already in ${preferredLanguage}, translate it into English instead following the same requirements. Only provide the translated result.`
3434
}
3535
const prefix = includeLanguagePrefix ? `Reply in ${preferredLanguage}.` : ''
3636
return `${prefix}${fullMessage}:\n'''\n${selection}\n'''`
@@ -41,7 +41,8 @@ export const config = {
4141
icon: <ChatText />,
4242
label: 'Explain',
4343
genPrompt: createGenPrompt({
44-
message: 'Explain the following',
44+
message:
45+
'You are an expert teacher. Explain the following content in simple terms and highlight the key points',
4546
includeLanguagePrefix: true,
4647
}),
4748
},
@@ -80,7 +81,8 @@ export const config = {
8081
icon: <CardHeading />,
8182
label: 'Summary',
8283
genPrompt: createGenPrompt({
83-
message: 'Summarize the following as concisely as possible',
84+
message:
85+
'You are a professional summarizer. Summarize the following content in a few sentences, focusing on the key points',
8486
includeLanguagePrefix: true,
8587
}),
8688
},
@@ -89,38 +91,41 @@ export const config = {
8991
label: 'Polish',
9092
genPrompt: createGenPrompt({
9193
message:
92-
'Check the following content for possible diction and grammar problems, and polish it carefully',
94+
'Act as a skilled editor. Correct grammar and word choice in the following text, improve readability and flow while preserving the original meaning, and return only the polished version',
9395
}),
9496
},
9597
sentiment: {
9698
icon: <EmojiSmile />,
9799
label: 'Sentiment Analysis',
98100
genPrompt: createGenPrompt({
99101
message:
100-
'Analyze the sentiments expressed in the following content and make a brief summary of the sentiments',
102+
'You are an expert in sentiment analysis. Analyze the following content and provide a brief summary of the overall emotional tone, labeling it with a short descriptive word or phrase',
101103
includeLanguagePrefix: true,
102104
}),
103105
},
104106
divide: {
105107
icon: <CardList />,
106108
label: 'Divide Paragraphs',
107109
genPrompt: createGenPrompt({
108-
message: 'Divide the following into paragraphs that are easy to read and understand',
110+
message:
111+
'You are a skilled editor. Divide the following text into clear, easy-to-read and easy-to-understand paragraphs',
109112
}),
110113
},
111114
code: {
112115
icon: <Braces />,
113116
label: 'Code Explain',
114117
genPrompt: createGenPrompt({
115-
message: 'Explain the following code',
118+
message:
119+
'You are a senior software engineer and system architect. Break down the following code step by step, explain how each part works and why it was designed that way, note any potential issues, and summarize the overall purpose',
116120
includeLanguagePrefix: true,
117121
}),
118122
},
119123
ask: {
120124
icon: <QuestionCircle />,
121125
label: 'Ask',
122126
genPrompt: createGenPrompt({
123-
message: 'Analyze the following content and express your opinion, or give your answer',
127+
message:
128+
'Analyze the following content carefully and provide a concise answer or opinion with a short explanation',
124129
includeLanguagePrefix: true,
125130
}),
126131
},

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ export default {
88
const abstract = document.querySelector('blockquote.abstract')?.textContent.trim()
99

1010
return await cropText(
11-
`Below is the paper abstract from a preprint site, summarize the key findings, methodology, and conclusions, especially highlight the contributions.` +
12-
`\n${title}\n${authors}\n${abstract}`,
11+
`You are a research assistant skilled in academic paper analysis. ` +
12+
`Based on the provided paper abstract from a preprint site, generate a structured summary. ` +
13+
`The summary should clearly outline: key findings, methodology, and conclusions. ` +
14+
`Pay special attention to highlighting the main contributions of the paper. ` +
15+
`Ensure the summary is concise and maintains an academic tone.\n` +
16+
`Title: ${title}\n` +
17+
`Authors: ${authors}\n` +
18+
`Abstract: ${abstract}`,
1319
)
1420
} catch (e) {
1521
console.log(e)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ export default {
5858
}
5959

6060
return await cropText(
61-
`用尽量简练的语言,联系视频标题,对视频进行内容摘要,同时仍要保留重要细节和标题信息,如果可能的话,使用markdown语法将视频内容总结为结构化信息,视频标题为:"${title}",字幕内容为:\n${subtitleContent}`,
61+
`You are an expert video summarizer. Create a comprehensive summary of the following Bilibili video in markdown format, ` +
62+
`highlighting key takeaways, crucial information, and main topics. Include the video title.\n` +
63+
`Video Title: "${title}"\n` +
64+
`Subtitle content:\n${subtitleContent}`,
6265
)
6366
} catch (e) {
6467
console.log(e)

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ export default {
1111
const title = document.querySelector('main article h1')?.textContent
1212
if (title) {
1313
return await cropText(
14-
`以下是一篇文章,请给出文章的结论和3到5个要点.标题是:"${title}",作者是:"${author}",内容是:\n"${description}".
15-
`,
14+
`You are an expert content summarizer. Please carefully read the following article. ` +
15+
`Provide a conclusion and 3 to 5 main points, presented as a markdown list. ` +
16+
`The summary should be concise, clear, and accurately reflect the core content.\n` +
17+
`Title: "${title}"\n` +
18+
`Author: "${author}"\n` +
19+
`Content:\n"${description}"`,
1620
)
1721
} else {
1822
return await cropText(
19-
`以下是一篇长推文,请给出文章的结论和3到5个要点.作者是:"${author}",内容是:\n"${description}".
20-
`,
23+
`You are an expert content summarizer. Please carefully read the following long tweet. ` +
24+
`Provide a conclusion and 3 to 5 main points, presented as a markdown list. ` +
25+
`The summary should be concise, clear, and accurately reflect the core content.\n` +
26+
`Author: "${author}"\n` +
27+
`Content:\n"${description}"`,
2128
)
2229
}
2330
}

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,16 @@ function createChatGPtSummaryPrompt(issueData, isIssue = true) {
8989

9090
if (isIssue) {
9191
prompt =
92-
'Please summarize the following GitHub issue thread.\nWhat is the main issue and key points discussed in this thread?\n\n'
92+
`You are an expert in analyzing GitHub discussions. ` +
93+
`Please provide a concise summary of the following GitHub issue thread. ` +
94+
`Identify the main problem reported, key points discussed by participants, proposed solutions (if any), and the current status or next steps. ` +
95+
`Present the summary in a structured markdown format.\n\n`
9396
} else {
9497
prompt =
95-
'Please summarize the following GitHub pull request thread.\nWhat is the main issue this pull request is trying to solve?\n\n'
98+
`You are an expert in analyzing GitHub discussions and code reviews. ` +
99+
`Please provide a concise summary of the following GitHub pull request thread. ` +
100+
`Identify the main problem this pull request aims to solve, the proposed changes, key discussion points from the review, and the overall status of the PR (e.g., approved, needs changes, merged). ` +
101+
`Present the summary in a structured markdown format.\n\n`
96102
}
97103

98104
prompt += '---\n\n'
@@ -153,8 +159,12 @@ export default {
153159
if (!patchData) return
154160

155161
return await cropText(
156-
`Analyze the contents of a git commit,provide a suitable commit message,and summarize the contents of the commit.` +
157-
`The patch contents of this commit are as follows:\n${patchData}`,
162+
`You are an expert in analyzing git commits and crafting clear, concise commit messages. ` +
163+
`Based on the following git patch, please perform two tasks:\n` +
164+
`1. Generate a suitable commit message. It should follow standard conventions: a short imperative subject line (max 50 chars), ` +
165+
`followed by a blank line and a more detailed body if necessary, explaining the "what" and "why" of the changes.\n` +
166+
`2. Provide a brief summary of the changes introduced in this commit, highlighting the main purpose and impact.\n\n` +
167+
`The patch contents are as follows:\n${patchData}`,
158168
)
159169
} catch (e) {
160170
console.log(e)

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,25 @@ export default {
2323
if (!fileData) return
2424

2525
return await cropText(
26-
`Analyze the following file content and explain it. Use markdown syntax to make your answer more readable, such as code blocks, bold, list:` +
27-
`\n\`\`\`\n${fileData}\n\`\`\``,
26+
`You are a senior software engineer and code reviewer. ` +
27+
`Analyze the following file content thoroughly. ` +
28+
`Explain its purpose, main functionalities, and how different parts of the code contribute to its overall behavior. ` +
29+
`Identify any potential issues, areas for improvement, or notable design patterns. ` +
30+
`Use markdown syntax (e.g., code blocks, bolding, lists) to structure your explanation for better readability.\n\n` +
31+
`File content:\n\`\`\`\n${fileData}\n\`\`\``,
2832
)
2933
} else {
3034
const patchUrl = await getPatchUrl()
3135
const patchData = await getPatchData(patchUrl)
3236
if (!patchData) return
3337

3438
return await cropText(
35-
`Analyze the contents of a git commit,provide a suitable commit message,and summarize the contents of the commit.` +
36-
`The patch contents of this commit are as follows:\n${patchData}`,
39+
`You are an expert in analyzing git commits and crafting clear, concise commit messages. ` +
40+
`Based on the following git patch, please perform two tasks:\n` +
41+
`1. Generate a suitable commit message. It should follow standard conventions: a short imperative subject line (max 50 chars), ` +
42+
`followed by a blank line and a more detailed body if necessary, explaining the "what" and "why" of the changes.\n` +
43+
`2. Provide a brief summary of the changes introduced in this commit, highlighting the main purpose and impact.\n\n` +
44+
`The patch contents are as follows:\n${patchData}`,
3745
)
3846
}
3947
} catch (e) {

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ export default {
2121
comment += `answer${i}: ${comment[i - 1].textContent}|`
2222
}
2323
return await cropText(
24-
`以下是一篇文章,标题是:"${title}",作者是:"${author}",内容是:\n"${description}".各个评论如下:\n${comment}.请以如下格式输出你的回答:
25-
{文章摘要和文章作者}
26-
======
27-
{文章总结和对文章的看法}
28-
======
29-
{对评论的总结}
30-
`,
24+
`You are an expert content analyst and summarizer. ` +
25+
`Please analyze the following Juejin article and its comments. Provide a summary of the article (including author), your opinion on it, and a summary of the comments.\n` +
26+
`Article Title: "${title}"\n` +
27+
`Author: "${author}"\n` +
28+
`Content:\n"${description}"\n\n` +
29+
`Selected comments:\n${comment}`,
3130
)
3231
}
3332
} catch (e) {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ export default {
1515
}
1616

1717
return await cropText(
18-
`Below is the content from a question and answer platform,giving the corresponding summary and your opinion on it.` +
19-
`The question is:'${title}',` +
20-
`Some answers are as follows:\n${answers}`,
18+
`You are an insightful analyst of Q&A discussions. ` +
19+
`Below is content from a Q&A platform. Please provide a summary of the discussion and your opinion on it.\n` +
20+
`Question: '${title}'\n` +
21+
`Answers:\n${answers}`,
2122
)
2223
} catch (e) {
2324
console.log(e)

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ export default {
1414
}
1515

1616
return await cropText(
17-
`Below is the content from a social forum,giving the corresponding summary and your opinion on it.` +
18-
`The title is:'${title}',and the further description of the title is:'${description}'.` +
19-
`Some answers are as follows:\n${answers}`,
17+
`You are an expert in analyzing online forum discussions. ` +
18+
`Below is content from a social forum (Reddit). Please provide a summary of the discussion and your opinion on it.\n` +
19+
`Title: '${title}'\n` +
20+
`Description: '${description}'\n` +
21+
`Comments:\n${answers}`,
2022
)
2123
} catch (e) {
2224
console.log(e)

0 commit comments

Comments
 (0)