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
49.77k stars 7.11k forks source link

Can not add a self-hosted knowledge API endpoint to DIFY via service's name #9917

Open k0286 opened 2 hours ago

k0286 commented 2 hours ago

Self Checks

Dify version

0.10.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. build a self-hosted ragflow service with docker and link its network to DIFY's network
  2. Use the Add an External Knowledge API function in the DIFY's web UI.
  3. Set the API endpoint, e.g. http://ragflow:9999/api/v1/dify

✔️ Expected Behavior

The API endpoint should be added to DIFY.

❌ Actual Behavior

The API endpoint will be blocked by the validators https://github.com/langgenius/dify/blob/aa11141660077618c7ee7f66c1d53017f4c2d4e5/api/services/external_knowledge_service.py#L71

and return 400 Bad Request.

dosubot[bot] commented 2 hours ago

Hey there, @k0286! I'm here to help you with bug fixes, answer your questions, and guide you on how to become a contributor to the project. Let's tackle this issue together!

I found a similar issue related to a 400 Bad Request error when adding an API endpoint in Dify. The validation criteria in the external_knowledge_service.py file could be causing this error. Specifically, the check_endpoint_and_api_key method ensures that both the endpoint and api_key are present and valid. If either is missing or incorrectly formatted, a 400 Bad Request error is returned [1].

To resolve this, ensure that:

  1. The endpoint is correctly specified and is a valid URL.
  2. The api_key is provided and correctly formatted.

These validations are crucial for the successful addition of an external API endpoint in Dify. If the issue persists, double-check the endpoint URL and API key for any discrepancies.

To continue talking to Dosu, mention @dosu.