소스 검색

fix: better error message for url add external knowledge (#11537)

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
tags/0.14.0
yihong 10 달 전
부모
커밋
50b76dd5a2
No account linked to committer's email address
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4
    1
      api/services/external_knowledge_service.py

+ 4
- 1
api/services/external_knowledge_service.py 파일 보기

@@ -69,7 +69,10 @@ class ExternalDatasetService:
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:

Loading…
취소
저장