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

是否能增加AI翻译?如DeepSeek。提供设置可以填入API KEY使用 #2275

Open
Huan-zhaojun opened this issue Feb 19, 2025 · 0 comments

Comments

@Huan-zhaojun
Copy link

设备信息

  • 操作系统: [[Window11]
  • 浏览器版本: [Chrome127.0.6533.120]
  • 沙拉查词版本: [v7.20.0]

请描述目前使用沙拉查词遇到什么不便

缺乏AI翻译,目前使用ai翻译已经非常常见了,最近DeepSeek大火。

理想情况下,沙拉查词应该怎么做

增加AI翻译选项,其实代码工作量很低,大部分的AI的api是兼容OpenAi API的格式的,只需要写一个就行了。
很多ai的网络请求代码都类似于这样:

curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
        "model": "gpt-4o",
        "store": true,
        "messages": [
            {"role": "user", "content": "write a haiku about ai"}
        ]
    }'

import OpenAI from "openai";
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
    model: "gpt-4o",
    store: true,
    messages: [
        {"role": "user", "content": "write a haiku about ai"}
    ]
});

只要能自定义请求api网址、密钥、模型id 就行了。剩下content就是划词填入的内容。

替代方案

沉浸式翻译插件已经支持多种ai翻译了。建议抄沉浸式翻译插件

额外信息

Overview - OpenAI API
DeepSeek API 文档
火山方舟-API 参考

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

1 participant