mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 11:56:09 +08:00
fix: better error message for url add external knowledge (#11537)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
parent
225fcd5e41
commit
50b76dd5a2
@ -69,7 +69,10 @@ class ExternalDatasetService:
|
|||||||
endpoint = f"{settings['endpoint']}/retrieval"
|
endpoint = f"{settings['endpoint']}/retrieval"
|
||||||
api_key = settings["api_key"]
|
api_key = settings["api_key"]
|
||||||
if not validators.url(endpoint, simple_host=True):
|
if not validators.url(endpoint, simple_host=True):
|
||||||
raise ValueError(f"invalid endpoint: {endpoint}")
|
if not endpoint.startswith("http://") and not endpoint.startswith("https://"):
|
||||||
|
raise ValueError(f"invalid endpoint: {endpoint} must start with http:// or https://")
|
||||||
|
else:
|
||||||
|
raise ValueError(f"invalid endpoint: {endpoint}")
|
||||||
try:
|
try:
|
||||||
response = httpx.post(endpoint, headers={"Authorization": f"Bearer {api_key}"})
|
response = httpx.post(endpoint, headers={"Authorization": f"Bearer {api_key}"})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user