langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
51.18k stars 7.37k forks source link

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

Closed xwineapplex closed 3 months ago

xwineapplex commented 3 months ago

Self Checks

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)"

crazywoola commented 3 months ago

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

sinomoe commented 3 months ago

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

Of course, I'll take a look at this

sinomoe commented 3 months ago

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

xwineapplex commented 3 months ago

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?

sinomoe commented 3 months ago

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 commented 3 months ago

@crazywoola take a look at this #6503

xwineapplex commented 3 months ago

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