Skip to content

Commit c0a6216

Browse files
committed
update: development
1 parent b52dc74 commit c0a6216

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/services/ai/GeminiAPI.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ export class GeminiAPI {
2121
try {
2222
const formattedPrompt = this.formatPrompt(prompt, currentContent, editorType, systemPrompt);
2323

24+
const contents = examples
25+
? [
26+
...examples.map((ex) => ({ role: ex.role, parts: [{ text: ex.content }] })),
27+
{ role: "user", parts: [{ text: formattedPrompt }] },
28+
]
29+
: [{ role: "user", parts: [{ text: formattedPrompt }] }];
30+
2431
const response = await fetch(
2532
`https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=${this.apiKey}`,
2633
{
2734
method: "POST",
28-
headers: {
29-
"Content-Type": "application/json",
30-
},
35+
headers: { "Content-Type": "application/json" },
3136
body: JSON.stringify({
32-
contents: [
33-
{
34-
role: "user",
35-
parts: [{ text: formattedPrompt }],
36-
},
37-
],
37+
contents,
3838
generationConfig: {
3939
temperature: 0.7,
4040
maxOutputTokens: 2000,

0 commit comments

Comments
 (0)