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

DeepL 自定义 API 支持 JSON 格式的参数 #464

Closed
4 of 5 tasks
NieXi opened this issue Mar 19, 2024 · 9 comments
Closed
4 of 5 tasks

DeepL 自定义 API 支持 JSON 格式的参数 #464

NieXi opened this issue Mar 19, 2024 · 9 comments
Labels
enhancement New feature or request need more info

Comments

@NieXi
Copy link

NieXi commented Mar 19, 2024

请先确认以下事项

  • 已仔细阅读了 README
  • issues 页面搜索过(包括已关闭的 issue),未发现类似功能建议
  • Easydict 已升级到 最新版本
  • 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭

功能描述

自定义 API 使用的是 JSON 格式的参数,看起来当前还不支持

使用场景

使用第三方的接口,只支持 JSON 格式的参数

实现方案(可选)

No response

是否愿意提交 PR 实现该功能

  • 我愿意提交 PR
@NieXi NieXi added the enhancement New feature or request label Mar 19, 2024
Copy link

Hello NieXi, Thank you for your first issue contribution 🎉

@tisfeng
Copy link
Owner

tisfeng commented Mar 19, 2024

没看懂,你能详细描述一下你的想法吗?

@NieXi
Copy link
Author

NieXi commented Mar 20, 2024

不好意思,描述的不清楚。

是这样的,我在 Easydict 中使用第三方 DeepL 接口报错了。因为第三方 DeepL API 只支持 JSON 格式的参数,curl 请求如下:

curl -X POST http:https://localhost:1188/translate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your_access_token" \
-d '{
    "text": "Hello, world!",
    "source_lang": "EN",
    "target_lang": "DE"
}'

然后我看 Easydict 调用 DeepL 接口是用 form 传参的,希望能支持 JSON 格式的传参

@tisfeng
Copy link
Owner

tisfeng commented Mar 20, 2024

ok,我查一下。

@tisfeng
Copy link
Owner

tisfeng commented Mar 20, 2024

看了一下代码,目前 Easydict 目前是支持官方 DeepL URL-encoded 数据格式,这个没问题。

你上面接口是 DeepLX 生成的吧,我本地安装跑了一下,发现它这个好像支持 JSON 格式,并且返回的数据格式也和 DeepL 官方 API 不一样 🥲

我这边可以改成 JSON 格式,但意义不大,这边只是客户端,我觉得这里应该向服务端 DeepLX 提请求,让它支持 form 格式,并且最好返回的数据格式能兼容官方 API,这样能更方便接口在各种第三方平台使用。

@NieXi
Copy link
Author

NieXi commented Mar 20, 2024

好的,谢谢。那我自己先中间套一层好了😂

@tisfeng
Copy link
Owner

tisfeng commented Mar 20, 2024

可能不需要了,DeepLX 那边将会支持 DeepL 官方 API OwO-Network/DeepLX#99 (comment)

@missuo
Copy link

missuo commented Mar 20, 2024

可能不需要了,DeepLX 那边将会支持 DeepL 官方 API OwO-Network/DeepLX#99 (comment)

It is already supported in the latest version v0.9.1.

@NieXi
Copy link
Author

NieXi commented Mar 21, 2024

好的,谢谢^_^

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

No branches or pull requests

3 participants