#23342The `_invoke` method in `ApiTool` always returns `TEXT` message type, even when the response is valid JSON. This should be fixed to return `JSON` message type when appropriate.
Issue Details
Author
Self Checks
- I have read the Contributing Guide and Language Policy.
- This is only for bug report, if you would like to ask a question, please head to Discussions.
- I have searched for existing issues search for existing issues, including closed ones.
- I confirm that I am using English to submit this report, otherwise it will be closed.
- 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
- Please do not modify this template :) and fill in all the required fields.
Dify version
1.3.0
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
- Configure an Custom API tool that returns JSON responses
- Ensure the server returns
Content-Type: application/json; charset=utf-8
- The tool will always treat it as plain text. JSON field is empty. Here is the stream message outputs fields example:
{ "text": "{\"status_code\": 200, \"stat\": 1, \"errcode\": \"success\", \"msg\": \"success\", \"data\": null}" "files": [], "json": [] }
✔️ Expected Behavior
I expect it should be like this:
{ "text": "" "files": [], "json": [{"status_code": 200, "stat": 1, "errcode": "success", "msg": "success", "data": null}] }
I have fixed it simply like this,but it is ugly.
in api/core/tools/custom_tool/tool.py
❌ Actual Behavior
No response