mirror of
https://github.com/katanemo/plano.git
synced 2026-05-04 13:23:00 +02:00
start using base_url in place of endpoint (#430)
This commit is contained in:
parent
ed3845040e
commit
e8dc7f18d3
3 changed files with 33 additions and 3 deletions
|
|
@ -62,7 +62,7 @@ properties:
|
||||||
properties:
|
properties:
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
# this field is deprecated, use provider_interface instead
|
# provider field is deprecated, use provider_interface instead
|
||||||
provider:
|
provider:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
|
|
@ -78,8 +78,11 @@ properties:
|
||||||
type: string
|
type: string
|
||||||
default:
|
default:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
# endpoint field is deprecated, use base_url instead
|
||||||
endpoint:
|
endpoint:
|
||||||
type: string
|
type: string
|
||||||
|
base_url:
|
||||||
|
type: string
|
||||||
protocol:
|
protocol:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import os
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
import yaml
|
import yaml
|
||||||
from jsonschema import validate
|
from jsonschema import validate
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
ENVOY_CONFIG_TEMPLATE_FILE = os.getenv(
|
ENVOY_CONFIG_TEMPLATE_FILE = os.getenv(
|
||||||
"ENVOY_CONFIG_TEMPLATE_FILE", "envoy.template.yaml"
|
"ENVOY_CONFIG_TEMPLATE_FILE", "envoy.template.yaml"
|
||||||
|
|
@ -91,6 +92,9 @@ def validate_and_render_schema():
|
||||||
del llm_provider["provider"]
|
del llm_provider["provider"]
|
||||||
updated_llm_providers.append(llm_provider)
|
updated_llm_providers.append(llm_provider)
|
||||||
|
|
||||||
|
if llm_provider.get("endpoint") and llm_provider.get("base_url"):
|
||||||
|
raise Exception("Please provide either endpoint or base_url, not both")
|
||||||
|
|
||||||
if llm_provider.get("endpoint", None):
|
if llm_provider.get("endpoint", None):
|
||||||
endpoint = llm_provider["endpoint"]
|
endpoint = llm_provider["endpoint"]
|
||||||
protocol = llm_provider.get("protocol", "http")
|
protocol = llm_provider.get("protocol", "http")
|
||||||
|
|
@ -98,6 +102,30 @@ def validate_and_render_schema():
|
||||||
endpoint, protocol
|
endpoint, protocol
|
||||||
)
|
)
|
||||||
llms_with_endpoint.append(llm_provider)
|
llms_with_endpoint.append(llm_provider)
|
||||||
|
elif llm_provider.get("base_url", None):
|
||||||
|
base_url = llm_provider["base_url"]
|
||||||
|
urlparse_result = urlparse(base_url)
|
||||||
|
if llm_provider.get("port"):
|
||||||
|
raise Exception("Please provider port in base_url")
|
||||||
|
if urlparse_result.scheme == "" or urlparse_result.scheme not in [
|
||||||
|
"http",
|
||||||
|
"https",
|
||||||
|
]:
|
||||||
|
raise Exception(
|
||||||
|
"Please provide a valid URL with scheme (http/https) in base_url"
|
||||||
|
)
|
||||||
|
protocol = urlparse_result.scheme
|
||||||
|
port = urlparse_result.port
|
||||||
|
if port is None:
|
||||||
|
if protocol == "http":
|
||||||
|
port = 80
|
||||||
|
else:
|
||||||
|
port = 443
|
||||||
|
endpoint = urlparse_result.hostname
|
||||||
|
llm_provider["endpoint"] = endpoint
|
||||||
|
llm_provider["port"] = port
|
||||||
|
llm_provider["protocol"] = protocol
|
||||||
|
llms_with_endpoint.append(llm_provider)
|
||||||
|
|
||||||
config_yaml["llm_providers"] = updated_llm_providers
|
config_yaml["llm_providers"] = updated_llm_providers
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,7 @@ llm_providers:
|
||||||
access_key: $DEEPSEEK_API_KEY
|
access_key: $DEEPSEEK_API_KEY
|
||||||
provider_interface: openai
|
provider_interface: openai
|
||||||
model: deepseek-reasoner
|
model: deepseek-reasoner
|
||||||
endpoint: api.deepseek.com
|
base_url: https://api.deepseek.com/
|
||||||
protocol: https
|
|
||||||
|
|
||||||
tracing:
|
tracing:
|
||||||
random_sampling: 100
|
random_sampling: 100
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue