-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompt.js
More file actions
151 lines (124 loc) · 5.36 KB
/
prompt.js
File metadata and controls
151 lines (124 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Cache for loaded prompts
let promptCache = {
youtube: null,
text: null,
preface: null,
youtubePreface: null
};
// Function to load markdown file content
async function loadMarkdownFile(filename) {
try {
const response = await fetch(chrome.runtime.getURL(filename));
if (!response.ok) {
throw new Error(`Failed to load ${filename}: ${response.status}`);
}
return await response.text();
} catch (error) {
console.error(`Error loading ${filename}:`, error);
return null;
}
}
// Load YouTube prompt from markdown file
async function getDefaultYouTubePrompt() {
if (promptCache.youtube) {
return promptCache.youtube;
}
const content = await loadMarkdownFile('youtube-prompt.md');
if (content) {
promptCache.youtube = content.trim();
return promptCache.youtube;
}
// Fallback to hardcoded prompt if file loading fails
return `Summarise the following transcript from a YouTube video. Present the summary in a clear, well-structured manner with proper formatting and spacing. Your response MUST use the following structure:
1. **Overall Summary** (2-3 paragraphs):
Write a clear introduction that:
- Begins with the video's title in quotes
- If the title is sensational/clickbaity, explicitly contrast the title's implications with the actual content
- Provide 2-3 well-spaced paragraphs that capture the main points
- Use proper paragraph breaks for readability
2. **Key Sections** (with timestamps):
Break down the content into sections, each with:
- An *italicized heading with timestamp* (e.g., *Introduction - 0:00*)
- A paragraph explaining that section's key points
- At least one line break between sections
3. **Required Formatting**:
Your summary MUST include:
- Multiple paragraphs with proper spacing
- **Bold** for important concepts and terms
- *Italic* for section headings and emphasis
- Line breaks between major sections
- Bullet points for lists (if applicable)
4. **Length and Structure**:
- For short videos (< 10 min): At least 2 sections
- For longer videos: 3-4 sections minimum
- Each section should be its own paragraph
- Avoid walls of text - use proper spacing
- No abbreviations with periods (write "US" not "U.S.")
Remember: The goal is to create an easily scannable, well-formatted summary that is both informative and pleasant to read.`;
}
// Load text prompt from markdown file
async function getDefaultTextPrompt() {
if (promptCache.text) {
return promptCache.text;
}
const content = await loadMarkdownFile('text-prompt.md');
if (content) {
promptCache.text = content.trim();
return promptCache.text;
}
// Fallback to hardcoded prompt if file loading fails
return `Summarise the following text in a clear, well-structured manner with proper formatting and spacing. Your response MUST use the following structure:
1. **Overall Summary** (2-3 paragraphs):
Write a clear introduction that:
- Begins with the text's title in quotes
- If the title is sensational, explicitly contrast the title's implications with the actual content
- Provide 2-3 well-spaced paragraphs that capture the main points
- Use proper paragraph breaks for readability
2. **Key Sections**:
Break down the content into logical sections, each with:
- An *italicized heading* that describes the section
- A paragraph explaining that section's key points
- At least one line break between sections
3. **Required Formatting**:
Your summary MUST include:
- Multiple paragraphs with proper spacing
- **Bold** for important concepts and terms
- *Italic* for section headings and emphasis
- Line breaks between major sections
- Bullet points for lists (if applicable)
4. **Length and Structure**:
- For short texts (< 1000 words): At least 2 sections
- For longer texts: 3-4 sections minimum
- Each section should be its own paragraph
- Avoid walls of text - use proper spacing
- No abbreviations with periods (write "US" not "U.S.")
Remember: The goal is to create an easily scannable, well-formatted summary that is both informative and pleasant to read.`;
}
// Load preface prompt from markdown file
async function getDefaultPrefacePrompt() {
if (promptCache.preface) {
return promptCache.preface;
}
const content = await loadMarkdownFile('preface-prompt.md');
if (content) {
promptCache.preface = content.trim();
return promptCache.preface;
}
// Fallback to hardcoded prompt if file loading fails
return "I have questions about this article. Please review the complete text provided below. The full article content is included here, so you don't need to access any external links right now.";
}
// Load YouTube preface prompt from markdown file
async function getDefaultYouTubePrefacePrompt() {
if (promptCache.youtubePreface) {
return promptCache.youtubePreface;
}
const content = await loadMarkdownFile('youtube-preface-prompt.md');
if (content) {
promptCache.youtubePreface = content.trim();
return promptCache.youtubePreface;
}
// Fallback to hardcoded prompt if file loading fails
return "I have questions about this YouTube video. Please review the text below.";
}
// Export functions to use in other files
export { getDefaultYouTubePrompt, getDefaultTextPrompt, getDefaultPrefacePrompt, getDefaultYouTubePrefacePrompt };