openai-translator / bob-plugin-openai-translator

基于 ChatGPT API 的文本翻译、文本润色、语法纠错 Bob 插件,让我们一起迎接不需要巴别塔的新时代!Licensed under CC BY-NC-SA 4.0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Azure Open AI 的验证功能失效

JiyuShao opened this issue · comments

Please search before asking

  • I searched in the issues and found nothing similar.

Please read README

  • I have read the usage instructions section in README in detail.

Please check your network and OpenAI API quota

  • I am sure it is not a network issue or an OpenAI API quota issue.

OpenAI Translator Bob Plugin version

2.2.0

系统版本 | System version

macOS 12.2.1

Bob version

Bob 1.8.2 [148]

复现步骤 | Reproduce step

使用 Azure OpenAI,配置完成后点击验证出错,但是保存后能正常使用

你看到了什么错误?What errors do you see?

image

你期望看到什么?What did you expect to see?

验证的逻辑应该与正常使用的逻辑相同,失败与成功的表现一致

还有其他的内容吗?Anything else?

验证的时候请求了 https://xxx.openai.azure.com/v1/models 接口,返回结果如下:
{"error":{"code":"404","message": "Resource not found"}}

image

你是否愿意提交一份 PR 来修改这个错误?Are you willing to submit a PR?

  • 我愿意提供 PR! I'm willing to submit a PR!

验证的还是报错:
image

image

正常的请求如下:
image

一样的问题,应该是 POST Body 的格式不对
https://github.com/openai-translator/bob-plugin-openai-translator/blob/v2.2.2/src/main.js#L366

Body 下面这个格式是失败的:
{"max_tokens":5,"prompt":"Once upon a time"}

Body 下面这个格式是成功的:
{"stream":true,"messages":[{"content":"You are a translation engine that can only translate text and cannot interpret it.","role":"system"},{"content":"translate from en to zh-Hans:\n\nOnce upon a time","role":"user"}],"frequency_penalty":1,"model":"gpt-3.5-turbo-16k","temperature":0.20000000000000001,"presence_penalty":1,"top_p":1,"max_tokens":1000}

挺奇怪的,我是看着官方的 Example 是这样写的 https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2023-05-15/examples/completions.json#L9

  • 这个是 completion 的示例,Completions API 已经过时了
  • 代码里用的是 chat completion 的接口,所以应该参考这个 Example

可以了