Skip to content

Commit 5c238d1

Browse files
author
tung-ideapad
committed
.
1 parent 7e27e2b commit 5c238d1

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

src/index.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,24 +2157,24 @@ document.addEventListener('alpine:init', () => { Alpine.data('mainApp', () => ({
21572157
return;
21582158
}
21592159

2160-
let systemPrompt = '';
2160+
let systemPrompt = 'Strictly direct concise straight answer, no foreword or quote. ';
21612161
let userPrompt = '';
21622162

21632163
if (promptType === 'improve') {
2164-
systemPrompt = 'You are a helpful assistant that improves text. You will correct grammar, spelling, and make the text more fluent and clear.';
2164+
systemPrompt += 'You are a helpful assistant that improves text. You will correct grammar, spelling, and make the text more fluent and clear.';
21652165
userPrompt = `Improve the following text:\n\n---\n${content}`;
21662166
} else if (promptType === 'summarize') {
2167-
systemPrompt = 'You are a helpful assistant that summarizes text.';
2167+
systemPrompt += 'You are a helpful assistant that summarizes text.';
21682168
userPrompt = `Summarize the following text:\n\n---\n${content}`;
21692169
} else if (promptType === 'extractTags') {
2170-
systemPrompt = 'You are a helpful assistant that extracts tags from text. Return a comma-separated list of tags. Consider the existing tags and the content, and return a new list of tags that is relevant to the content.';
2171-
userPrompt = `Extract tags (maximum 7 tags, each tag is mostly single concise meaningful word) from the following text, considering the existing tags. **Only response in plain string comma-separated text**.\n\nExisting tags: ${this.noteEditorTags}\n\nContent:\n---\n${content}`;
2170+
systemPrompt += 'You are a helpful assistant that extracts tags from text. Return a comma-separated list of tags. Consider the existing tags and the content, and return a new list of tags that is relevant to the content.';
2171+
userPrompt = `Extract tags (maximum 7 tags, each tag is mostly single concise meaningful word) from the following text, considering the existing tags. **Only response in plain string lowercase comma-separated text**.\n\nExisting tags: [${this.noteEditorTags}]\n\nContent:\n---\n${content}`;
21722172
} else {
21732173
this.showToast({ variant: 'error', title: 'Invalid AI Action', description: 'The requested AI action is not supported.' });
21742174
return;
21752175
}
21762176

2177-
userPrompt = prompt(systemPrompt, userPrompt);
2177+
// userPrompt = prompt(systemPrompt, userPrompt);
21782178

21792179
document.body.style.cursor = 'wait';
21802180
try {
@@ -2185,26 +2185,30 @@ document.addEventListener('alpine:init', () => { Alpine.data('mainApp', () => ({
21852185
'Authorization': `Bearer ${this.aiApiKey}`
21862186
},
21872187
body: JSON.stringify({
2188-
model: this.aiModel || 'gemini-2.5-flash',
2188+
model: this.aiModel || 'gemini-flash-lite-latest',
21892189
messages: [
21902190
{ role: 'system', content: systemPrompt },
21912191
{ role: 'user', content: userPrompt }
21922192
],
21932193
// reasoning_effort: 'low',
21942194
stream: false,
2195+
21952196
extra_body: {
21962197
google: {
2198+
generation_config: {
2199+
temperature: 0.2,
2200+
},
21972201
thinking_config: {
21982202
thinking_budget: 0,
2199-
}
2203+
},
22002204
}
22012205
}
22022206
})
22032207
});
22042208

22052209
if (!response.ok) {
22062210
const errorData = await response.json();
2207-
throw new Error(errorData.error.message || 'AI API request failed');
2211+
throw new Error(errorData?.error?.message || errorData?.error || 'AI API request failed');
22082212
}
22092213

22102214
const data = await response.json();

0 commit comments

Comments
 (0)