From 9e4c510684fe0b2e25c17388d4aa6e54faa4c616 Mon Sep 17 00:00:00 2001 From: Gabe Date: Sun, 10 Aug 2025 21:50:33 +0800 Subject: [PATCH] doc: update custom api help --- README.en.md | 3 ++- README.md | 3 ++- custom-api.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/README.en.md b/README.en.md index 1e41d13..f26ee57 100644 --- a/README.en.md +++ b/README.en.md @@ -169,7 +169,8 @@ Example of a Response Hook function: * @param {string} to Target language * @returns {Array[string, boolean]} [Translated text, whether target language is same as source] * Note: If the second return value is true (target language same as source), - * the translation will not be displayed on the page + * the translation will not be displayed on the page, + * If the parameters are incomplete, it is recommended to return false directly */ (res, text, from, to) => [res.text, to === res.src] ``` diff --git a/README.md b/README.md index 0ed5b56..0ef8c1e 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,8 @@ Response Hook 函数示例如下: * @param {string} from 原文语言 * @param {string} to 译文语言 * @returns {Array[string, boolean]} [译文, 译文语言与原文语言是否相同] - * 注:如果返回值第二个值为true(译文语言与原文语言相同)则译文不会在页面显示 + * 注:如果返回值第二个值为true(译文语言与原文语言相同)则译文不会在页面显示, + * 参数不全的情况建议直接返回false */ (res, text, from, to) => [res.text, to === res.src] ``` diff --git a/custom-api.md b/custom-api.md index 9cde264..4bbcb22 100644 --- a/custom-api.md +++ b/custom-api.md @@ -135,6 +135,67 @@ Response Hook ] ``` +## 接入 gemini-2.5-flash, 关闭思考模式, 去审查 + +> 由网友 Rick Sanchez 提供 + +URL + +```sh +https://generativelanguage.googleapis.com/v1beta/models +``` + +Request Hook + +```js +(text, from, to, url, key) => [`${url}/gemini-2.5-flash:generateContent?key=${key}`, { + headers: { + "Content-Type": "application/json", + }, + method: "POST", + body: JSON.stringify({ + "generationConfig": { + "temperature": 0.8, + "thinkingConfig": { + "thinkingBudget": 0, //gemini-2.5-flash设为0关闭思考模式 + }, + }, + "safetySettings": [ + { + "category": "HARM_CATEGORY_HARASSMENT", + "threshold": "BLOCK_NONE", + }, + { + "category": "HARM_CATEGORY_HATE_SPEECH", + "threshold": "BLOCK_NONE", + }, + { + "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", + "threshold": "BLOCK_NONE", + }, + { + "category": "HARM_CATEGORY_DANGEROUS_CONTENT", + "threshold": "BLOCK_NONE", + } + ], + "contents": [{ + "parts": [{ + "text": `自定义提示词` + }] + }], + }), +}] +``` + +Response Hook + +```js +(res, text, from, to) => [ + res.candidates?.[0]?.content?.parts?.[0]?.text ?? "", + false +] +``` + ## 接入 openrouter > 由网友 atom 提供 @@ -281,3 +342,5 @@ Response Hook ```js (res, text, from, to) => [res?.[0]?.join(" ") || "Translation unavailable", to === res?.[1]?.[0]] ``` + +