dify icon indicating copy to clipboard operation
dify copied to clipboard

sys.query Cannot Be Modified via action=overridden in Dify 1.0.0 Beta API Extension

Open hzcoolwind opened this issue 10 months 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] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

1.0.0-beta1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Configure API Extension: Set up a moderation API endpoint that returns JSON responses.
  2. Create a chatbot and enable moderation for in mode. then run app.
  3. API Returns action=overridden: return { "flagged": true, "action": "overridden", "inputs": { "var_1": "", "var_2": "" }, "query": "Sanitized query" // Expected to update sys.query }
  4. Observe Behavior: sys.query remains the original value . Provided query ("Sanitized query") is ignored.

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

hzcoolwind avatar Feb 22 '25 06:02 hzcoolwind

Hey @hzcoolwind! 👋 I'm here to help you with any bugs, questions, or contributions you have for Dify 1.0.0 Beta API Extension. I'm looking forward to assisting you!

The issue you're experiencing with sys.query not being modified when the API returns action=overridden in Dify 1.0.0 Beta seems to contradict the expected behavior. According to the documentation, when the API returns action=overridden, the input variable values and the current dialogue input content from the end-user should be overridden with the values provided in the response [1].

If sys.query is not being updated as expected, it might be due to a bug or a configuration issue. Here are a few steps you can take to troubleshoot:

  1. Verify Configuration: Ensure that the moderation API endpoint is correctly configured and that the response format matches the expected structure.

  2. Check Logs: Look at the application logs to see if there are any errors or warnings that might indicate why the sys.query is not being updated.

  3. Review Code: If you have access to the code, review the part responsible for handling the moderation API response to ensure it processes the action=overridden correctly.

  4. Test with Different Inputs: Try using different inputs to see if the issue persists across various scenarios.

If the problem continues, it might be worth checking for any updates or patches that address this issue in newer versions of Dify.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar Feb 22 '25 06:02 dosubot[bot]

And another question is:
API-Based Extension supported module extensions include: external_data_tool. I write a external_data_tool service. and I launch the API service. Configure this API in Dify. then I want to Select this API extension in the App. but i can't find where should select this api extension , can not find in tools, can not find api extension. Could you tell me how I can invoke this 'external_data_tool' API extension in the APP, it's impormant to me, thanks.

hzcoolwind avatar Feb 22 '25 07:02 hzcoolwind

To invoke the 'external_data_tool' API extension in the Dify app after configuring it, follow these steps:

  1. Configure the API in Dify: Ensure that you have added the API extension in Dify by providing the API endpoint and the API Key through the Dify interface.

  2. Select the API Extension in the App: After configuring the API, you should be able to select this API extension within your Dify app. Look for a section labeled "选择扩展" (Select Extension) in the app interface, which is indicated by a screenshot in the documentation.

  3. Verify API Functionality: Ensure that your API is set up to handle requests from Dify correctly. The API should respond to a "ping" request with a "pong" response to verify its functionality.

  4. API Specification: Make sure your API follows the required specifications. Dify will call your API using a POST request to your specified endpoint. The request will include headers such as Content-Type: application/json and Authorization: Bearer {api_key}. The request body will contain a "point" and "params" as specified in the documentation.

  5. Example Implementation: You can refer to the provided example using Python FastAPI to implement your API. This includes handling different points like "ping" and "app.external_data_tool.query" [1][2][3][4].

If you have configured the API correctly and still cannot find where to select it, ensure that you have followed all configuration steps and check for any additional documentation or support from Dify regarding the app interface.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar Feb 22 '25 07:02 dosubot[bot]

@dosu I done all these 5 steps and i sure it's all ok , but only I can not find where to select it in my app (chatbot/chatflow/workflow).

hzcoolwind avatar Feb 22 '25 07:02 hzcoolwind

To select the 'external_data_tool' API extension in your Dify app after completing all configuration steps, follow these instructions:

  1. Go to the prompt composition page in your Dify app.
  2. Click the "+添加" (Add) button on the right side of "工具" (Tools).
  3. In the "添加工具" (Add Tool) dialog that opens, enter the name and variable name (ensure the variable name is in English as it will be referenced in the prompt).
  4. Select the API-based extension you added during the configuration process.

Ensure that your API is correctly set up according to Dify's API specifications. This includes setting up the API endpoint to handle requests with the appropriate headers and request body format. Dify will send a request to verify the API's availability, expecting a response of result=pong when the point=ping is sent. Make sure your API is ready to handle these requests and return the expected responses [1][2][3][4].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar Feb 22 '25 07:02 dosubot[bot]

@ dosu I go to the prompt compositon page in my app, i can only find '接点‘、‘工具’ but not find the Add button. just like this :

Image

hzcoolwind avatar Feb 22 '25 07:02 hzcoolwind

Hi, @hzcoolwind. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary

  • The issue involves a bug in the Dify 1.0.0 Beta API Extension where sys.query is not updated with action=overridden.
  • Despite correct setup of a moderation API endpoint, the query remains unchanged.
  • You are unable to find the option to select the 'external_data_tool' API extension in the app interface.
  • Guidance was provided, but further assistance is needed to locate the necessary interface elements.

Next Steps

  • Please confirm if this issue is still relevant to the latest version of the Dify repository by commenting on this issue.
  • If there is no further activity, the issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

dosubot[bot] avatar Mar 25 '25 16:03 dosubot[bot]