Skip to content

Commit

Permalink
fix: show full gemini url
Browse files Browse the repository at this point in the history
  • Loading branch information
fishjar committed May 12, 2024
1 parent f908372 commit d2ff46e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/apis/trans.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
INPUT_PLACE_TO,
INPUT_PLACE_TEXT,
INPUT_PLACE_KEY,
INPUT_PLACE_MODEL,
} from "../config";
import { msAuth } from "../libs/auth";
import { genDeeplFree } from "./deepl";
Expand Down Expand Up @@ -219,6 +220,9 @@ const genOpenAI = ({ text, from, to, url, key, prompt, model }) => {
};

const genGemini = ({ text, from, to, url, key, prompt, model }) => {
url = url
.replaceAll(INPUT_PLACE_MODEL, model)
.replaceAll(INPUT_PLACE_KEY, key);
prompt = prompt
.replaceAll(INPUT_PLACE_FROM, from)
.replaceAll(INPUT_PLACE_TO, to)
Expand All @@ -237,7 +241,6 @@ const genGemini = ({ text, from, to, url, key, prompt, model }) => {
],
};

const input = `${url}/${model}:generateContent?key=${key}`;
const init = {
headers: {
"Content-type": "application/json",
Expand All @@ -246,7 +249,7 @@ const genGemini = ({ text, from, to, url, key, prompt, model }) => {
body: JSON.stringify(data),
};

return [input, init];
return [url, init];
};

const genOllama = ({ text, from, to, url, key, prompt, model }) => {
Expand Down
5 changes: 3 additions & 2 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ export const INPUT_PLACE_FROM = "{{from}}"; // 占位符
export const INPUT_PLACE_TO = "{{to}}"; // 占位符
export const INPUT_PLACE_TEXT = "{{text}}"; // 占位符
export const INPUT_PLACE_KEY = "{{key}}"; // 占位符
export const INPUT_PLACE_MODEL = "{{model}}"; // 占位符

export const DEFAULT_COLOR = "#209CEE"; // 默认高亮背景色/线条颜色

Expand Down Expand Up @@ -554,15 +555,15 @@ export const DEFAULT_TRANS_APIS = {
[OPT_TRANS_OPENAI_2]: defaultOpenaiApi,
[OPT_TRANS_OPENAI_3]: defaultOpenaiApi,
[OPT_TRANS_GEMINI]: {
url: "https://generativelanguage.googleapis.com/v1/models",
url: `https://generativelanguage.googleapis.com/v1/models/${INPUT_PLACE_MODEL}:generateContent?key=${INPUT_PLACE_KEY}`,
key: "",
model: "gemini-pro",
prompt: `Translate the following text from ${INPUT_PLACE_FROM} to ${INPUT_PLACE_TO}:\n\n${INPUT_PLACE_TEXT}`,
fetchLimit: 1,
fetchInterval: 500,
},
[OPT_TRANS_CLOUDFLAREAI]: {
url: "https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/meta/m2m100-1.2b",
url: "https://api.cloudflare.com/client/v4/accounts/{{ACCOUNT_ID}}/ai/run/@cf/meta/m2m100-1.2b",
key: "",
fetchLimit: 1,
fetchInterval: 500,
Expand Down

0 comments on commit d2ff46e

Please sign in to comment.