mirror of
https://github.com/katanemo/plano.git
synced 2026-07-02 15:51:02 +02:00
Infer port from protocol if port is not specified and add ability to override hostname in clusters def (#389)
This commit is contained in:
parent
d8970d4334
commit
631d2d591f
4 changed files with 30 additions and 7 deletions
|
|
@ -68,6 +68,8 @@ properties:
|
||||||
enum:
|
enum:
|
||||||
- http
|
- http
|
||||||
- https
|
- https
|
||||||
|
http_host:
|
||||||
|
type: string
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
|
|
|
||||||
|
|
@ -570,7 +570,11 @@ static_resources:
|
||||||
socket_address:
|
socket_address:
|
||||||
address: {{ local_llm_provider.endpoint }}
|
address: {{ local_llm_provider.endpoint }}
|
||||||
port_value: {{ local_llm_provider.port }}
|
port_value: {{ local_llm_provider.port }}
|
||||||
|
{% if local_llm_provider.http_host %}
|
||||||
|
hostname: {{ local_llm_provider.http_host }}
|
||||||
|
{% else %}
|
||||||
hostname: {{ local_llm_provider.endpoint }}
|
hostname: {{ local_llm_provider.endpoint }}
|
||||||
|
{% endif %}
|
||||||
{% if local_llm_provider.protocol == "https" %}
|
{% if local_llm_provider.protocol == "https" %}
|
||||||
transport_socket:
|
transport_socket:
|
||||||
name: envoy.transport_sockets.tls
|
name: envoy.transport_sockets.tls
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,20 @@ ARCH_CONFIG_SCHEMA_FILE = os.getenv(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_endpoint_and_port(endpoint, protocol):
|
||||||
|
endpoint_tokens = endpoint.split(":")
|
||||||
|
if len(endpoint_tokens) > 1:
|
||||||
|
endpoint = endpoint_tokens[0]
|
||||||
|
port = int(endpoint_tokens[1])
|
||||||
|
return endpoint, port
|
||||||
|
else:
|
||||||
|
if protocol == "http":
|
||||||
|
port = 80
|
||||||
|
else:
|
||||||
|
port = 443
|
||||||
|
return endpoint, port
|
||||||
|
|
||||||
|
|
||||||
def validate_and_render_schema():
|
def validate_and_render_schema():
|
||||||
env = Environment(loader=FileSystemLoader("./"))
|
env = Environment(loader=FileSystemLoader("./"))
|
||||||
template = env.get_template("envoy.template.yaml")
|
template = env.get_template("envoy.template.yaml")
|
||||||
|
|
@ -42,9 +56,11 @@ def validate_and_render_schema():
|
||||||
for name, endpoint_details in endpoints.items():
|
for name, endpoint_details in endpoints.items():
|
||||||
inferred_clusters[name] = endpoint_details
|
inferred_clusters[name] = endpoint_details
|
||||||
endpoint = inferred_clusters[name]["endpoint"]
|
endpoint = inferred_clusters[name]["endpoint"]
|
||||||
if len(endpoint.split(":")) > 1:
|
protocol = inferred_clusters[name].get("protocol", "http")
|
||||||
inferred_clusters[name]["endpoint"] = endpoint.split(":")[0]
|
(
|
||||||
inferred_clusters[name]["port"] = int(endpoint.split(":")[1])
|
inferred_clusters[name]["endpoint"],
|
||||||
|
inferred_clusters[name]["port"],
|
||||||
|
) = get_endpoint_and_port(endpoint, protocol)
|
||||||
|
|
||||||
print("defined clusters from arch_config.yaml: ", json.dumps(inferred_clusters))
|
print("defined clusters from arch_config.yaml: ", json.dumps(inferred_clusters))
|
||||||
|
|
||||||
|
|
@ -77,9 +93,10 @@ def validate_and_render_schema():
|
||||||
|
|
||||||
if llm_provider.get("endpoint", None):
|
if llm_provider.get("endpoint", None):
|
||||||
endpoint = llm_provider["endpoint"]
|
endpoint = llm_provider["endpoint"]
|
||||||
if len(endpoint.split(":")) > 1:
|
protocol = llm_provider.get("protocol", "http")
|
||||||
llm_provider["endpoint"] = endpoint.split(":")[0]
|
llm_provider["endpoint"], llm_provider["port"] = get_endpoint_and_port(
|
||||||
llm_provider["port"] = int(endpoint.split(":")[1])
|
endpoint, protocol
|
||||||
|
)
|
||||||
llms_with_endpoint.append(llm_provider)
|
llms_with_endpoint.append(llm_provider)
|
||||||
|
|
||||||
config_yaml["llm_providers"] = updated_llm_providers
|
config_yaml["llm_providers"] = updated_llm_providers
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ prompt_targets:
|
||||||
|
|
||||||
endpoints:
|
endpoints:
|
||||||
frankfurther_api:
|
frankfurther_api:
|
||||||
endpoint: api.frankfurter.dev:443
|
endpoint: api.frankfurter.dev
|
||||||
protocol: https
|
protocol: https
|
||||||
|
|
||||||
tracing:
|
tracing:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue