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

可以自定义Chatgpt API域名么 #34

Closed
whlnolan opened this issue May 7, 2023 · 33 comments
Closed

可以自定义Chatgpt API域名么 #34

whlnolan opened this issue May 7, 2023 · 33 comments
Labels
enhancement New feature or request

Comments

@whlnolan
Copy link

whlnolan commented May 7, 2023

可否加一个自定义API域名得功能不🤣

@bookfere bookfere added the enhancement New feature or request label May 7, 2023
@bookfere
Copy link
Owner

bookfere commented May 8, 2023

后面的版本会尝试将其添加到自定义内置翻译引擎功能中。

@lhj5426
Copy link

lhj5426 commented May 8, 2023

确实需要
image
想自己添加 但是完全看不懂要怎么添加ChatGPT的自定义域名

希望能傻瓜式点的
image

@bookfere
Copy link
Owner

bookfere commented May 8, 2023

@lhj5426

如果你想要把 ChatGPT 添加到自定义翻译引擎可以复制粘贴修改以下代码片段:

{
    "name": "Custom ChatGPT",
    "languages": {
        "source": {
            "English": "English"
        },
        "target": {
            "中文": "Chinese"
        }
    },
    "request": {
        "url": "https://api.openai.com/v1/chat/completions",
        "method": "POST",
        "headers": {
            "Content-Type": "application/json",
            "Authorization": "Bearer sk-xxxxxxxxxxxxxxxxxxxxx"
        },
        "data": {
            "model": "gpt-3.5-turbo",
            "messages": [{
                "role": "user",
                "content": "Translate the content to <target>: <text>"
            }]
        }
    },
    "response": "response['choices'][0]['message']['content']"
}

其中需要替换的内容有:

  • https://api.openai.com/v1/chat/completions 改成你想要的任意 URL;
  • sk-xxxxxxxxxxxxxxxxxxxxx 改成你自己的密钥;
  • Translate the content to <target>: <text> 改成你想要的提示词。

最后点击测试按钮测试。

@lhj5426
Copy link

lhj5426 commented May 8, 2023

按照您说的填写 返回的是错误

image
我用的这2个第三方试的 都不行
https://api2d.com/wiki/doc

https://openai-sb.com/api/openai/
这种在带有傻瓜式 API 填写 软件上如
https://github.com/Bin-Huang/chatbox
是都好使的

@bookfere
Copy link
Owner

bookfere commented May 9, 2023

看起来像是请求没有被正常响应,这个错误出现时网络代理是开启状态吗?

以你截图中的 URL 为例,我测试了一下可以正常返回响应。你可以测试一下,把 URL 改成一个不存在的网址 https://api-cf.openai-sb.com/xxx 测试一下,看是否能正常返回这样的响应:

{"code":"404","msg":"未定义的路由,请检查你的URL是否正确!","data":null}

@lhj5426
Copy link

lhj5426 commented May 9, 2023

看起来像是请求没有被正常响应,这个错误出现时网络_代理_是开启状态吗?

以你截图中的 URL 为例,我测试了一下可以正常返回响应。你可以测试一下,把 URL 改成一个不存在的网址 https://api-cf.openai-sb.com/xxx 测试一下,看是否能正常返回这样的响应:

{"code":"404","msg":"未定义的路由,请检查你的URL是否正确!","data":null}

tianruo_20230509180018
按照您说的 域名这里瞎写 好像返回的是一样的内容

@whlnolan
Copy link
Author

whlnolan commented May 9, 2023

我的自定义sb的api倒是能翻,但速度太慢了

@whlnolan
Copy link
Author

whlnolan commented May 9, 2023

等作者后期更新这个功能吧还是,自己不折腾了

@lhj5426
Copy link

lhj5426 commented May 9, 2023

我的自定义sb的api倒是能翻,但速度太慢了

能发一下你的配置吗 记得脱敏

我是完全配置不上
慢 是这个软件是一行行翻译的吗?

@bookfere
Copy link
Owner

bookfere commented May 9, 2023

@lhj5426 是否开启了网络代理?也有可能是代理设置导致请求没成功。

@lhj5426
Copy link

lhj5426 commented May 9, 2023

@lhj5426 是否开启了网络_代理_?也有可能是_代理_设置导致请求没成功。

代理一直是开着的而且 插进上也有设置
image
image

@lhj5426
Copy link

lhj5426 commented May 9, 2023

@lhj5426 是否开启了网络_代理_?也有可能是_代理_设置导致请求没成功。

突然有一个疑问 这个软件上的代理是 HTTP sock5?

@bookfere
Copy link
Owner

bookfere commented May 9, 2023

是 HTTP 代理,改成 8890 试试。另外你所用的第三方转发服务是否需要代理,如果不需要也可以关掉代理。

@lhj5426
Copy link

lhj5426 commented May 9, 2023

是 HTTP 代理,改成 8890 试试。另外你所用的第三方转发服务是否需要_代理_,如果不需要也可以关掉_代理_。

哦 我挂是sockS 我试试

@lhj5426
Copy link

lhj5426 commented May 9, 2023

是 HTTP 代理,改成 8890 试试。另外你所用的第三方转发服务是否需要_代理_,如果不需要也可以关掉_代理_。

这次的响应报错就换了
image
我再把api地址改回去试试

@lhj5426
Copy link

lhj5426 commented May 9, 2023

然后变成了这样
image

@bookfere
Copy link
Owner

bookfere commented May 9, 2023

这是能正常响应了,但是密钥没有通过验证。如果你确认密钥没错,检查一下请求标头 Authorization 中的 Bearer 后面是否有多个空格,如果有改成一个再试试。

@lhj5426
Copy link

lhj5426 commented May 9, 2023

这是能正常响应了,但是密钥没有通过验证。如果你确认密钥没错,检查一下请求标头 Authorization 中的 Bearer 后面是否有多个空格,如果有改成一个再试试。

image
好像没多?

@lhj5426
Copy link

lhj5426 commented May 9, 2023

image
不对 是我的错 忘记点保存了 设置完代理忘记点保存了 又变回8891了 是我的锅 现在可以正常跟API通信了

@lhj5426
Copy link

lhj5426 commented May 9, 2023

非常感谢您的耐心帮助
image
已经可以翻译了 不过这个进度 和已翻译? 对不上

@bookfere
Copy link
Owner

bookfere commented May 9, 2023

这个进度确实有点儿奇怪,后面的版本会优化一下。

@lhj5426
Copy link

lhj5426 commented May 9, 2023

这个进度确实有点儿奇怪,后面的版本会优化一下。

哥哥 不是有点奇怪 是 非常奇怪 一个TXT文档412行就 跑1个小时
image 这个号第三方API是没有 1分钟调用限制的。 不像免费api 一分钟就调用3次 所以这个速度很不正常

@whlnolan
Copy link
Author

whlnolan commented May 9, 2023

所以先别折腾了,等更新哈哈

@bookfere
Copy link
Owner

bookfere commented May 9, 2023

@lhj5426 速度问题同 #36

@QingHui653
Copy link

image
请问下数据解析是怎么样的? 这边api返回的直接是一个 翻译的结果, 文本格式.

但是我看这边是有处理 text的 .不知道为什么解析失败
image

配置如下
image

@bookfere
Copy link
Owner

@QingHui653 插件没能正确处理这种情况,试试这个版本:

ebook-translator_202305202020.zip

@QingHui653
Copy link

image
修改提示,让 chatgpt 返回 json格式, 然后这样配置就行了. 但是 使用 chatgpt 在一些语句上,说 不理解意思, 然后提示出一推无意义的内容

@bookfere
Copy link
Owner

@QingHui653#20#29。在翻译某些问句和名词时,ChatGPT 经常会自由发挥。这需要优化提示词,让 ChatGPT 仅做翻译。近几天插件会发布新版本,增加了“高级翻译”面板,你也可以通过这个面板调整这些不太合适的翻译内容。

advanced-translation

@whlnolan
Copy link
Author

这次新版本加入自定义api url么?

@bookfere
Copy link
Owner

@whlnolan 会。这个更新会尽量解决当前的 Open Issues.

@WeeAris
Copy link

WeeAris commented May 26, 2023

@lhj5426

如果你想要把 ChatGPT 添加到自定义翻译引擎可以复制粘贴修改以下代码片段:

{
    "name": "Custom ChatGPT",
    "languages": {
        "source": {
            "English": "English"
        },
        "target": {
            "中文": "Chinese"
        }
    },
    "request": {
        "url": "https://api.openai.com/v1/chat/completions",
        "method": "POST",
        "headers": {
            "Content-Type": "application/json",
            "Authorization": "Bearer sk-xxxxxxxxxxxxxxxxxxxxx"
        },
        "data": {
            "model": "gpt-3.5-turbo",
            "messages": [{
                "role": "user",
                "content": "Translate the content to <target>: <text>"
            }]
        }
    },
    "response": "response['choices'][0]['message']['content']"
}

其中需要替换的内容有:

  • https://api.openai.com/v1/chat/completions 改成你想要的任意 URL;
  • sk-xxxxxxxxxxxxxxxxxxxxx 改成你自己的密钥;
  • Translate the content to <target>: <text> 改成你想要的提示词。

最后点击测试按钮测试。

照着这个改了,但是不知道为什么返回的却是谷歌翻译的结果

@riverai
Copy link

riverai commented Jul 18, 2023

@lhj5426

如果你想要把 ChatGPT 添加到自定义翻译引擎可以复制粘贴修改以下代码片段:

{
    "name": "Custom ChatGPT",
    "languages": {
        "source": {
            "English": "English"
        },
        "target": {
            "中文": "Chinese"
        }
    },
    "request": {
        "url": "https://api.openai.com/v1/chat/completions",
        "method": "POST",
        "headers": {
            "Content-Type": "application/json",
            "Authorization": "Bearer sk-xxxxxxxxxxxxxxxxxxxxx"
        },
        "data": {
            "model": "gpt-3.5-turbo",
            "messages": [{
                "role": "user",
                "content": "Translate the content to <target>: <text>"
            }]
        }
    },
    "response": "response['choices'][0]['message']['content']"
}

其中需要替换的内容有:

  • https://api.openai.com/v1/chat/completions 改成你想要的任意 URL;
  • sk-xxxxxxxxxxxxxxxxxxxxx 改成你自己的密钥;
  • Translate the content to <target>: <text> 改成你想要的提示词。

最后点击测试按钮测试。

你好,这个模板应该如何调节”温度“?

@bookfere
Copy link
Owner

@riverai

可以参考 ChatGPT 的 API 文档提供的请求体参数根据自己的需求修改 "data" 中的请求数据。比如要使用 temperature 调节温度,就可以像下面这样修改 "data" 中的请求数据,其中 0.8 处是参数值,文档给出的范围是 0~2,可自行修改:

...
        "data": {
            "model": "gpt-3.5-turbo",
            "temperature": 0.8,
            "messages": [{
                "role": "user",
                "content": "Translate the content to <target>: <text>"
            }]
        }
...

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

No branches or pull requests

6 participants