Skip to content

Commit

Permalink
fix: better error message for url add external knowledge (#11537)
Browse files Browse the repository at this point in the history
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
  • Loading branch information
yihong0618 authored Dec 11, 2024
1 parent 225fcd5 commit 50b76dd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/services/external_knowledge_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ def check_endpoint_and_api_key(settings: dict):
endpoint = f"{settings['endpoint']}/retrieval"
api_key = settings["api_key"]
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:
response = httpx.post(endpoint, headers={"Authorization": f"Bearer {api_key}"})
except Exception as e:
Expand Down

0 comments on commit 50b76dd

Please sign in to comment.