ZGGSONG / STranslate

A ready-to-use, ready-to-go translation ocr tool developed by WPF/WPF 开发的一款即开即用、即用即走的翻译、OCR工具
https://stranslate.zggsong.com
MIT License
1.93k stars 109 forks source link

Cloude服务无法通过连通验证 #214

Open huouer opened 3 hours ago

huouer commented 3 hours ago

Describe the bug Cloude服务无法通过连通验证 Where is the bug

To Reproduce Steps to reproduce the behavior:

  1. Go to '翻译服务'

  2. Click on '+'加入Claude

  3. 加入刚刚在https://console.anthropic.com/settings/keys申请的APIkey

  4. Click on "连通验证“

  5. image

  6. See error image

Expected behavior 可以验证通过,并使用Claude

Screenshots image

Where did you get STranslate?

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Log 2024-10-11 13:18:26.249 [ERR] (Claude)(504b4649-7073-4903-8493-86b7cf140c50) raw content: {"type":"error","error":{"type":"invalid_request_error","message":"messages: Unexpected role \"system\". The Messages API accepts a top-level system parameter, not \"system\" as an input message role."}}

2024-10-11 16:43:52.864 [ERR] (Claude)(504b4649-7073-4903-8493-86b7cf140c50) raw content: {"type":"error","error":{"type":"invalid_request_error","message":"max_tokens: Field required"}} 2024-10-11 16:44:06.058 [ERR] (Claude)(504b4649-7073-4903-8493-86b7cf140c50) raw content: {"type":"error","error":{"type":"invalid_request_error","message":"max_tokens: Field required"}} 2024-10-11 16:44:24.234 [ERR] (Claude)(504b4649-7073-4903-8493-86b7cf140c50) raw content: {"type":"error","error":{"type":"invalid_request_error","message":"max_tokens: Field required"}} 2024-10-11 16:44:24.235 [ERR] [Claude(504b4649-7073-4903-8493-86b7cf140c50)] 翻译出错, 请求API: https://api.anthropic.com, 异常信息: Bad Request max_tokens: Field required 2024-10-11 16:46:27.438 [ERR] (Claude)(504b4649-7073-4903-8493-86b7cf140c50) raw content: {"type":"error","error":{"type":"invalid_request_error","message":"max_tokens: Field required"}} 2024-10-11 16:46:39.418 [ERR] (Claude)(504b4649-7073-4903-8493-86b7cf140c50) raw content: {"type":"error","error":{"type":"invalid_request_error","message":"max_tokens: Field required"}} 2024-10-11 16:46:39.418 [ERR] [Claude(504b4649-7073-4903-8493-86b7cf140c50)] 翻译出错, 请求API: https://api.anthropic.com, 异常信息: Bad Request max_tokens: Field required

ZGGSONG commented 2 hours ago

"message":"messages: Unexpected role "system"

从日志来看 似乎是官方不支持system这个角色,你可以尝试修改prompt将system角色一栏删除掉再试

Snipaste_2024-10-11_14-57-26

huouer commented 2 hours ago

试过了,仍然不行。 image

ZGGSONG commented 1 hour ago

https://github.com/ZGGSONG/STranslate/releases/download/0.01/claude_fix.zip

我的号被封了,适配的时候使用的是第三方的服务商,可能他那边做兼容了,刚按官方文档更新了一下,你再试试

huouer commented 1 hour ago

成功了!多谢。

ZGGSONG commented 1 hour ago

成功了!多谢。

你可以先用 这个版本相较于上个正式版没改啥 加了点小功能 回头再发正式版本

huouer commented 1 hour ago

另外,Claude应该是支持角色“System”的。一旦在prompt删除了system角色,如何加回?现在似乎只能加“user”和“assistant

ZGGSONG commented 5 minutes ago
  1. 依然支持System角色,只是内部按照文档修复了一下请求参数结构
  2. 针对软件内添加回System角色你需要删除其他角色后,再点击添加会判断是否有System角色,没有才会添加,后续添加会根据上一个角色为user则添加assistant上一个角色为assistant则添加user