Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer port from protocol if port is not specified and add ability to override hostname in clusters def #389

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arch/arch_config_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ properties:
enum:
- http
- https
http_host:
type: string
additionalProperties: false
required:
- endpoint
Expand Down Expand Up @@ -66,6 +68,8 @@ properties:
enum:
- http
- https
http_host:
type: string
additionalProperties: false
required:
- name
Expand Down
8 changes: 8 additions & 0 deletions arch/envoy.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,11 @@ static_resources:
socket_address:
address: {{ cluster.endpoint }}
port_value: {{ cluster.port }}
{% if cluster.http_host %}
hostname: {{ cluster.http_host }}
{% else %}
hostname: {{ cluster.endpoint }}
{% endif %}
{% if cluster.protocol == "https" %}
transport_socket:
name: envoy.transport_sockets.tls
Expand Down Expand Up @@ -566,7 +570,11 @@ static_resources:
socket_address:
address: {{ local_llm_provider.endpoint }}
port_value: {{ local_llm_provider.port }}
{% if local_llm_provider.http_host %}
hostname: {{ local_llm_provider.http_host }}
{% else %}
hostname: {{ local_llm_provider.endpoint }}
{% endif %}
{% if local_llm_provider.protocol == "https" %}
transport_socket:
name: envoy.transport_sockets.tls
Expand Down
29 changes: 23 additions & 6 deletions arch/tools/cli/config_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
)


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():
env = Environment(loader=FileSystemLoader("./"))
template = env.get_template("envoy.template.yaml")
Expand All @@ -42,9 +56,11 @@ def validate_and_render_schema():
for name, endpoint_details in endpoints.items():
inferred_clusters[name] = endpoint_details
endpoint = inferred_clusters[name]["endpoint"]
if len(endpoint.split(":")) > 1:
inferred_clusters[name]["endpoint"] = endpoint.split(":")[0]
inferred_clusters[name]["port"] = int(endpoint.split(":")[1])
protocol = inferred_clusters[name].get("protocol", "http")
(
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))

Expand Down Expand Up @@ -77,9 +93,10 @@ def validate_and_render_schema():

if llm_provider.get("endpoint", None):
endpoint = llm_provider["endpoint"]
if len(endpoint.split(":")) > 1:
llm_provider["endpoint"] = endpoint.split(":")[0]
llm_provider["port"] = int(endpoint.split(":")[1])
protocol = llm_provider.get("protocol", "http")
llm_provider["endpoint"], llm_provider["port"] = get_endpoint_and_port(
endpoint, protocol
)
llms_with_endpoint.append(llm_provider)

config_yaml["llm_providers"] = updated_llm_providers
Expand Down
2 changes: 1 addition & 1 deletion demos/currency_exchange/arch_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ prompt_targets:

endpoints:
frankfurther_api:
endpoint: api.frankfurter.dev:443
endpoint: api.frankfurter.dev
protocol: https

tracing:
Expand Down