dify icon indicating copy to clipboard operation
dify copied to clipboard

Error "Expecting value: line 1 column 1 (char 0)" when using Claude model through OpenRouter API

Open xwineapplex opened this issue 2 years ago • 7 comments

Self Checks

  • [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [X] I have searched for existing issues search for existing issues, including closed ones.
  • [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [X] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [X] Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.14

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

螢幕擷取畫面 2024-07-20 212629

As shown in the attached image, when I use the Claude Sonnet 3.5 model via OpenRouter's API in Agent Assistant mode, I encounter an "Expecting value: line 1 column 1 (char 0)" error whenever the model attempts to use tools.

I'm unsure if this is a Dify or OpenRouter issue, but I really hope it can function normally.

If this is an OpenRouter-related problem, could you please inform me of the possible causes so I can check with OpenRouter?


This issue was translated with the assistance of Claude.

✔️ Expected Behavior

螢幕擷取畫面 2024-07-20 214459

Works normally, able to retrieve data through tools and respond to users.

❌ Actual Behavior

"Expecting value: line 1 column 1 (char 0)"

xwineapplex avatar Jul 20 '24 13:07 xwineapplex

@sinomoe Could you help to take a look at this issue?

crazywoola avatar Jul 20 '24 14:07 crazywoola

@sinomoe Could you help to take a look at this issue?

Of course, I'll take a look at this

sinomoe avatar Jul 21 '24 02:07 sinomoe

@xd845217xd I can't reproduce the issue, could you provide the error message and DSL?

sinomoe avatar Jul 21 '24 03:07 sinomoe

Test-with-tools.txt

GitHub doesn't support uploading yml files, so I've exported and converted it to a txt file.

My testing method is as follows: I ask the model a question like "What time is it now?", prompting the model to use the "current_time" tool.

Subsequently, an error message "Expecting value: line 1 column 1 (char 0)" appears in the upper right corner.

Using the OpenAI API, for example with gpt-4o, there's no issue.

The only visible error on the webpage is "Expecting value: line 1 column 1 (char 0)".

Is there any additional information I can provide?

xwineapplex avatar Jul 21 '24 03:07 xwineapplex

Test-with-tools.txt

GitHub doesn't support uploading yml files, so I've exported and converted it to a txt file.

My testing method is as follows: I ask the model a question like "What time is it now?", prompting the model to use the "current_time" tool.

Subsequently, an error message "Expecting value: line 1 column 1 (char 0)" appears in the upper right corner.

Using the OpenAI API, for example with gpt-4o, there's no issue.

The only visible error on the webpage is "Expecting value: line 1 column 1 (char 0)".

Is there any additional information I can provide?

It seems that there is an issue with claude-3.5-sonnet, as it behaves differently from the openai when calling a tool without any arguments. I will create a pull request to make it compatible.

sinomoe avatar Jul 21 '24 07:07 sinomoe

@crazywoola take a look at this #6503

sinomoe avatar Jul 21 '24 07:07 sinomoe

Thank you for your quick response and support.

I'm not sure if this issue is specific to Sonnet 3.5. I've also tried testing with Opus 3 and Haiku 3 models through the OpenRouter API, and I encountered the same error.

I haven't tried using the API directly through Anthropic, AWS Bedrock, or Google Vertex.

~~May I ask if you tested this through OpenRouter as well, or did you use Anthropic's API directly?~~

~~Or perhaps there's no significant difference between these methods in this context?~~

Oh, I see your PR now. It seems you also tested through OpenRouter. My apologies for the oversight.

螢幕擷取畫面 2024-07-21 152556 螢幕擷取畫面 2024-07-21 152729

xwineapplex avatar Jul 21 '24 07:07 xwineapplex