-
-
Notifications
You must be signed in to change notification settings - Fork 120
Custom Translation Engine Recipes
书伴 edited this page Apr 23, 2024
·
10 revisions
{
"name": "Groq",
"languages": {
"source": {
"English": "english"
},
"target": {
"French": "french"
}
},
"request": {
"url": "https://api.groq.com/openai/v1/chat/completions",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"User-Agent": "Ebook Translator",
"Authorization": "Bearer gsk_xxxxxxxxxxxxxxxx"
},
"data": {
"messages": [
{
"role": "user",
"content": "Translate the content from <source> to <target>: <text>"
}
],
"model": "mixtral-8x7b-32768"
}
},
"response": "response['choices'][0]['message']['content']"
}
{
"name": "LLMstudio",
"languages": {
"source": {
"German": "German",
"Japanese": "Japanese"
},
"target": {
"English": "English"
}
},
"request": {
"url": "http://localhost:8000/api/engine/chat/{provider}",
"method": "POST",
"headers": {"Content-Type": "application/json"},
"data": {
"api_key": "{api_key}",
"model": "{model}",
"chat_input": "Translate the content from <slang> to <tlang>: <text>",
}
},
"response": "response['chat_output']"
}
Before using this code snippet, please replace {provider}
, {api_key}
, and {model}
with the corresponding data first.
{
"name": "ChatGPT",
"languages": {
"source": {
"English": "English"
},
"target": {
"Chinese": "Chinese"
}
},
"request": {
"url": "https://api.openai.com/v1/chat/completions",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer sk-xxxxxxxxxxxxxxxxxxxx",
"User-Agent": "Fill-As-You-Need"
},
"data": {
"model": "gpt-3.5-turbo",
"messages": [
{"role": "system", "content": "Translate the content from <slang> to <tlang>."},
{"role": "user", "content": "<text>"}
]
}
},
"response": "response['choices'][0]['message']['content']"
}
{
"name": "Gemini Pro",
"languages": {
"source": {
"English": "English",
"German": "German"
},
"target": {
"Chinese": "Chinese",
"Japanese": "Japanese"
}
},
"request": {
"url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=YOURKEYHERE",
"method": "POST",
"headers": {
"Content-Type": "application/json"
},
"data": {
"contents": [{
"role": "user",
"parts": [{"text": "Translate the content from <source> to <target>: <text>."}]
}]
}
},
"response": "response['candidates'][0]['content']['parts'][0]['text']"
}
{
"name": "LibreTranslate",
"languages": {
"source": {
"English": "en"
},
"target": {
"Chinese": "zh-CN"
}
},
"request": {
"url": "http://127.0.0.1:5000",
"method": "POST",
"headers": {
"Content-Type": "application/json"
},
"data": {
"source": "<source>",
"target": "<target>",
"q": "<text>"
}
},
"response": "response['translatedText']"
}
{
"name": "彩云小译",
"languages": {
"手动指定": "custom"
},
"request": {
"url": "https://api.interpreter.caiyunai.com/v1/translator",
"method": "POST",
"headers": {
"content-type": "application/json",
"x-authorization": "token 3975l6lr5pcbvidl6jl2"
},
"data": {
"detect": true,
"trans_type": "auto2zh",
"source": "<text>"
}
},
"response": "response['target']"
}
{
"name": "有道翻译",
"languages": {
"手动指定": "custom"
},
"request": {
"url": "https://fanyi.youdao.com/translate",
"method": "GET",
"data": {
"doctype": "json",
"i": "<text>"
}
},
"response": "''.join(i['tgt'] for i in response['translateResult'][0])"
}
♥ by bookfere.com