doc: update custom api help

This commit is contained in:
Gabe
2025-08-10 21:50:33 +08:00
parent 16607fb069
commit 9e4c510684
3 changed files with 67 additions and 2 deletions

View File

@@ -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]
```

View File

@@ -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]
```

View File

@@ -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]]
```