fix: gemini api

This commit is contained in:
Gabe
2025-10-07 21:10:51 +08:00
parent b2b5bef9f5
commit 4c2781b3b6
3 changed files with 15 additions and 10 deletions

View File

@@ -303,12 +303,19 @@ const genGemini = ({
const userMsg = { role: "user", parts: [{ text: userPrompt }] };
const body = {
system_instruction: {
parts: {
text: systemPrompt,
// system_instruction: {
// parts: {
// text: systemPrompt,
// },
// },
contents: [
{
role: "model",
parts: [{ text: systemPrompt }],
},
},
contents: [...hisMsgs, userMsg],
...hisMsgs,
userMsg,
],
generationConfig: {
maxOutputTokens: maxTokens,
temperature,

View File

@@ -197,7 +197,6 @@ export class InputTranslator {
text,
fromLang,
toLang,
apiSlug,
apiSetting,
});

View File

@@ -45,7 +45,7 @@ import {
BUILTIN_PLACETAGS,
} from "../../config";
function TestButton({ apiSlug, api }) {
function TestButton({ api }) {
const i18n = useI18n();
const alert = useAlert();
const [loading, setLoading] = useState(false);
@@ -53,11 +53,10 @@ function TestButton({ apiSlug, api }) {
try {
setLoading(true);
const [text] = await apiTranslate({
apiSlug,
text: "hello world",
fromLang: "en",
toLang: "zh-CN",
apiSetting: api,
apiSetting: { ...api },
useCache: false,
});
if (!text) {
@@ -691,7 +690,7 @@ function ApiFields({ apiSlug, isUserApi, deleteApi }) {
>
{i18n("save")}
</Button>
<TestButton apiSlug={apiSlug} api={api} />
<TestButton api={api} />
<Button size="small" variant="outlined" onClick={handleReset}>
{i18n("restore_default")}
</Button>