docs: custom api
This commit is contained in:
@@ -204,3 +204,53 @@ async ({ res }) => {
|
|||||||
return { translations: [[res?.choices?.[0]?.message?.content || ""]] };
|
return { translations: [[res?.choices?.[0]?.message?.content || ""]] };
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## 语言代码表及说明
|
||||||
|
|
||||||
|
Hook参数里面的语言含义说明:
|
||||||
|
|
||||||
|
- `toLang`, `fromLang` 是本插件支持的标准语言代码
|
||||||
|
- `to`, `from` 是转换后的适用于特定接口的语言代码
|
||||||
|
|
||||||
|
如果你的自定义接口与下面的标准语言代码不匹配,需要自行映射转换。
|
||||||
|
|
||||||
|
```
|
||||||
|
["en", "English - English"],
|
||||||
|
["zh-CN", "Simplified Chinese - 简体中文"],
|
||||||
|
["zh-TW", "Traditional Chinese - 繁體中文"],
|
||||||
|
["ar", "Arabic - العربية"],
|
||||||
|
["bg", "Bulgarian - Български"],
|
||||||
|
["ca", "Catalan - Català"],
|
||||||
|
["hr", "Croatian - Hrvatski"],
|
||||||
|
["cs", "Czech - Čeština"],
|
||||||
|
["da", "Danish - Dansk"],
|
||||||
|
["nl", "Dutch - Nederlands"],
|
||||||
|
["fi", "Finnish - Suomi"],
|
||||||
|
["fr", "French - Français"],
|
||||||
|
["de", "German - Deutsch"],
|
||||||
|
["el", "Greek - Ελληνικά"],
|
||||||
|
["hi", "Hindi - हिन्दी"],
|
||||||
|
["hu", "Hungarian - Magyar"],
|
||||||
|
["id", "Indonesian - Indonesia"],
|
||||||
|
["it", "Italian - Italiano"],
|
||||||
|
["ja", "Japanese - 日本語"],
|
||||||
|
["ko", "Korean - 한국어"],
|
||||||
|
["ms", "Malay - Melayu"],
|
||||||
|
["mt", "Maltese - Malti"],
|
||||||
|
["nb", "Norwegian - Norsk Bokmål"],
|
||||||
|
["pl", "Polish - Polski"],
|
||||||
|
["pt", "Portuguese - Português"],
|
||||||
|
["ro", "Romanian - Română"],
|
||||||
|
["ru", "Russian - Русский"],
|
||||||
|
["sk", "Slovak - Slovenčina"],
|
||||||
|
["sl", "Slovenian - Slovenščina"],
|
||||||
|
["es", "Spanish - Español"],
|
||||||
|
["sv", "Swedish - Svenska"],
|
||||||
|
["ta", "Tamil - தமிழ்"],
|
||||||
|
["te", "Telugu - తెలుగు"],
|
||||||
|
["th", "Thai - ไทย"],
|
||||||
|
["tr", "Turkish - Türkçe"],
|
||||||
|
["uk", "Ukrainian - Українська"],
|
||||||
|
["vi", "Vietnamese - Tiếng Việt"],
|
||||||
|
```
|
||||||
|
|||||||
@@ -156,13 +156,13 @@ async (args, { url, body, headers, userMsg, method } = {}) => {
|
|||||||
|
|
||||||
const responsetHookHelperZH = `1、第一个参数包含如下字段:'res', ...
|
const responsetHookHelperZH = `1、第一个参数包含如下字段:'res', ...
|
||||||
2、返回值必须是包含以下字段的对象: 'translations'
|
2、返回值必须是包含以下字段的对象: 'translations'
|
||||||
('translations' 应为一个二维数组:[[译文, 源语言]])
|
('translations' 应为一个二维数组:[[译文, 原文语言]])
|
||||||
3、如返回空值,则hook函数不会产生任何效果。
|
3、如返回空值,则hook函数不会产生任何效果。
|
||||||
|
|
||||||
// 示例
|
// 示例
|
||||||
async ({ res, ...args }) => {
|
async ({ res, ...args }) => {
|
||||||
const translations = [["你好", "zh"]];
|
const translations = [["你好", "en"]];
|
||||||
const modelMsg = "";
|
const modelMsg = {}; // 用于AI上下文
|
||||||
return { translations, modelMsg };
|
return { translations, modelMsg };
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
@@ -173,8 +173,8 @@ const responsetHookHelperEN = `1. The first parameter contains the following fie
|
|||||||
|
|
||||||
// Example
|
// Example
|
||||||
async ({ res, ...args }) => {
|
async ({ res, ...args }) => {
|
||||||
const translations = [["你好", "zh"]];
|
const translations = [["你好", "en"]];
|
||||||
const modelMsg = "";
|
const modelMsg = {}; // For AI context
|
||||||
return { translations, modelMsg };
|
return { translations, modelMsg };
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user