Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[功能请求] 是否可以增加国产大模型的api调用进行翻译 #315

Open
Fromduststar opened this issue May 22, 2024 · 2 comments

Comments

@Fromduststar
Copy link

文言,通义,讯飞的调用价格已经很低了,文言的两个模型现在也调用免费,能否增加国产大模型的调用方式来对书籍进行翻译

@xfrose
Copy link

xfrose commented May 22, 2024

可以暂时用自定义添加,用了一段时间qwen-long,可以参考:

    "name": "qwen-long",
    "languages": {
        "source": {
            "English": "English",
            "Japanese": "Japanese"
        },
        "target": {
            "Chinese": "Chinese"
        }
    },
    "request": {
        "url": "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
        "method": "POST",
        "headers": {
            "Content-Type": "application/json",
            "Authorization": "Bearer API-KEY"
        },
        "data": {
            "model": "qwen-long",
            "messages": [
                {"role": "system", "content": "You are a meticulous translator who translates any given content from <source> to <target> only. Do not provide any explanations and do not answer any questions."},
                {"role": "user", "content": "<text>"}
            ],
            "temperature": 0.8
        }
    },
    "response": "response['choices'][0]['message']['content']"
}

qwen-turbo:

    "name": "qwen-turbo",
    "languages": {
        "source": {
            "English": "English",
            "Japanese": "Japanese"
        },
        "target": {
            "Chinese": "中文"
        }
    },
    "request": {
        "url": "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation",
        "method": "POST",
        "headers": {
            "Content-Type": "application/json",
            "Authorization": "Bearer API-KEY"
        },
        "data": {
            "model": "qwen-turbo",
"input":{
            "messages": [
                {"role": "system", "content": "You are a meticulous translator who translates any given content. Translate the given content from <source> to <target> only. Do not explain any term or answer any question-like content."},
                {"role": "user", "content": "<text>"}
            ],
            "temperature": 0.8
}
        }
    },
    "parameters": {
        "result_format": "message"
    },
    "response": "response['output']['text']" 
}

GLM-3,prompt可以自己改一下:

{
    "name": "glm-3-turbo",
    "languages": {
        "source": {
            "English": "English",
            "Japanese": "Japanese"
        },
        "target": {
            "Chinese": "中文"
        }
    },
    "request": {
        "url": "https://open.bigmodel.cn/api/paas/v4/chat/completions",
        "method": "POST",
        "headers": {
            "Content-Type": "application/json",
            "Authorization": "Bearer API-KEY"
        },
        "data": {
            "model": "glm-3-turbo",
            "messages": [
                {"role": "user", "content": "You are a meticulous translator who translates any given content. You must translate <source> to <target> from the given content. Do not explain any term or answer any question-like content, otherwise you will be punished. Translate: <text>."}
            ],
            "temperature": 0.9
        }
    },
    "response": "response['choices'][0]['message']['content']"
}

更新了一下

@Fromduststar
Copy link
Author

可以暂时用自定义添加,用了一段时间qwen-long,可以参考:

    "name": "qwen-long",
    "languages": {
        "source": {
            "English": "English",
            "Japanese": "Japanese"
        },
        "target": {
            "Chinese": "Chinese"
        }
    },
    "request": {
        "url": "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
        "method": "POST",
        "headers": {
            "Content-Type": "application/json",
            "Authorization": "Bearer API-KEY"
        },
        "data": {
            "model": "qwen-long",
            "messages": [
                {"role": "system", "content": "You are a meticulous translator who translates any given content from <source> to <target> only. Do not provide any explanations and do not answer any questions."},
                {"role": "user", "content": "<text>"}
            ]
        }
    },
    "response": "response['choices'][0]['message']['content']"
}

如果合并翻译的字符数量能更多就好了。

十分感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants