Skip to content

Commit 7e9250b

Browse files
committed
feat(viking_url): support http https
1 parent 7d0c7b4 commit 7e9250b

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

veadk/integrations/ve_viking_db_memory/ve_viking_db_memory.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,17 @@ def __init__(
5858
env_host = getenv(
5959
"DATABASE_VIKINGMEM_BASE_URL", default_value=None, allow_false_values=True
6060
)
61-
if env_host is not None:
61+
if env_host:
6262
if env_host.startswith("http://"):
6363
host = env_host.replace("http://", "")
6464
scheme = "http"
65+
elif env_host.startswith("https://"):
66+
host = env_host.replace("https://", "")
67+
scheme = "https"
6568
else:
66-
raise ValueError("DATABASE_VIKINGMEM_BASE_URL must start with http://")
69+
raise ValueError(
70+
"DATABASE_VIKINGMEM_BASE_URL must start with http:// or https://"
71+
)
6772

6873
self.service_info = VikingDBMemoryClient.get_service_info(
6974
host, region, scheme, connection_timeout, socket_timeout

veadk/knowledgebase/backends/vikingdb_knowledge_backend.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -557,18 +557,21 @@ def _do_request(
557557
path: str,
558558
method: Literal["GET", "POST", "PUT", "DELETE"] = "POST",
559559
) -> dict:
560-
VIKINGDB_KNOWLEDGEBASE_BASE_URL = "api-knowledgebase.mlp.cn-beijing.volces.com"
561-
full_path = f"https://{VIKINGDB_KNOWLEDGEBASE_BASE_URL}{path}"
560+
VIKINGDB_KNOWLEDGEBASE_BASE_URL = (
561+
"https://api-knowledgebase.mlp.cn-beijing.volces.com"
562+
)
563+
full_path = f"{VIKINGDB_KNOWLEDGEBASE_BASE_URL}{path}"
562564

563565
env_host = getenv(
564566
"DATABASE_VIKING_BASE_URL", default_value=None, allow_false_values=True
565567
)
566-
if env_host is not None:
567-
if env_host.startswith("http://"):
568-
VIKINGDB_KNOWLEDGEBASE_BASE_URL = env_host.replace("http://", "")
569-
full_path = f"http://{VIKINGDB_KNOWLEDGEBASE_BASE_URL}{path}"
568+
if env_host:
569+
if env_host.startswith("http://") or env_host.startswith("https://"):
570+
full_path = f"{env_host}{path}"
570571
else:
571-
raise ValueError("DATABASE_VIKING_BASE_URL must start with http://")
572+
raise ValueError(
573+
"DATABASE_VIKING_BASE_URL must start with http:// or https://"
574+
)
572575

573576
volcengine_access_key = self.volcengine_access_key
574577
volcengine_secret_key = self.volcengine_secret_key

0 commit comments

Comments
 (0)