Skip to content

Commit dc02868

Browse files
Copilotna-trium-144
andcommitted
Extract model and contents parameters into reusable params variable
Co-authored-by: na-trium-144 <[email protected]>
1 parent c998b49 commit dc02868

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

app/actions/gemini.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
import { GoogleGenAI } from "@google/genai";
44

55
export async function generateContent(prompt: string) {
6+
const params = {
7+
model: "gemini-2.5-flash",
8+
contents: prompt,
9+
};
10+
611
const ai = new GoogleGenAI({ apiKey: process.env.API_KEY! });
712

813
try {
9-
return await ai.models.generateContent({
10-
model: "gemini-2.5-flash",
11-
contents: prompt,
12-
});
14+
return await ai.models.generateContent(params);
1315
} catch (e: unknown) {
1416
if (String(e).includes("User location is not supported")) {
1517
// For the new API, we can use httpOptions to set a custom baseUrl
@@ -19,10 +21,7 @@ export async function generateContent(prompt: string) {
1921
baseUrl: "https://gemini-proxy.utcode.net",
2022
},
2123
});
22-
return await aiWithProxy.models.generateContent({
23-
model: "gemini-2.5-flash",
24-
contents: prompt,
25-
});
24+
return await aiWithProxy.models.generateContent(params);
2625
} else {
2726
throw e;
2827
}

0 commit comments

Comments
 (0)