Skip to content

Commit

Permalink
arch schema validator (#105)
Browse files Browse the repository at this point in the history
* add arch schema validator

* schema validator
  • Loading branch information
adilhafeez authored Oct 1, 2024
1 parent 1586982 commit 41cdef5
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config_generator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ COPY config_generator/requirements.txt .
RUN pip install -r requirements.txt
COPY config_generator/config_generator.py .
COPY arch/envoy.template.yaml .

COPY config_generator/arch_config_schema.yaml .
CMD ["python", "config_generator.py"]
147 changes: 147 additions & 0 deletions config_generator/arch_config_schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
$schema: "http://json-schema.org/draft-07/schema#"
type: object
properties:
version:
type: string
listener:
type: object
properties:
address:
type: string
port:
type: integer
message_format:
type: string
connect_timeout:
type: string
additionalProperties: false
required:
- address
- port
endpoints:
type: object
patternProperties:
"^.*$":
type: object
properties:
endpoint:
type: string
connect_timeout:
type: string
additionalProperties: false
required:
- endpoint
llm_providers:
type: array
items:
type: object
properties:
name:
type: string
access_key:
type: string
model:
type: string
default:
type: boolean
additionalProperties: false
required:
- name
- access_key
- model
overrides:
type: object
properties:
prompt_target_intent_matching_threshold:
type: number
system_prompt:
type: string
prompt_targets:
type: array
items:
type: object
properties:
name:
type: string
default:
type: boolean
description:
type: string
parameters:
type: array
items:
type: object
properties:
name:
type: string
additionalProperties: false
required:
type: boolean
default:
type: string
description:
type: string
type:
type: string
additionalProperties: false
required:
- name
- description
- type
endpoint:
type: object
properties:
name:
type: string
path:
type: string
additionalProperties: false
required:
- name
- path
system_prompt:
type: string
additionalProperties: false
required:
- name
- description
ratelimits:
type: array
items:
type: object
properties:
provider:
type: string
selector:
type: object
properties:
key:
type: string
value:
type: string
additionalProperties: false
required:
- key
- value
limit:
type: object
properties:
tokens:
type: integer
unit:
type: string
additionalProperties: false
required:
- tokens
- unit
additionalProperties: false
required:
- provider
- selector
- limit
additionalProperties: false
required:
- version
- listener
- llm_providers
- prompt_targets
12 changes: 12 additions & 0 deletions config_generator/config_generator.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os
from jinja2 import Environment, FileSystemLoader
import yaml
from jsonschema import validate

ENVOY_CONFIG_TEMPLATE_FILE = os.getenv('ENVOY_CONFIG_TEMPLATE_FILE', 'envoy.template.yaml')
ARCH_CONFIG_FILE = os.getenv('ARCH_CONFIG_FILE', 'arch_config.yaml')
ARCH_CONFIG_SCHEMA_FILE = os.getenv('ARCH_CONFIG_SCHEMA_FILE', 'arch_config_schema.yaml')
ENVOY_CONFIG_FILE_RENDERED = os.getenv('ENVOY_CONFIG_FILE_RENDERED', '/usr/src/app/out/envoy.yaml')

env = Environment(loader=FileSystemLoader('./'))
Expand All @@ -12,7 +14,17 @@
with open(ARCH_CONFIG_FILE, 'r') as file:
katanemo_config = file.read()

with open(ARCH_CONFIG_SCHEMA_FILE, 'r') as file:
arch_config_schema = file.read()

config_yaml = yaml.safe_load(katanemo_config)
config_schema_yaml = yaml.safe_load(arch_config_schema)

try:
validate(config_yaml, config_schema_yaml)
except Exception as e:
print(f"Error validating arch_config file: {ARCH_CONFIG_FILE}, error: {e.message}")
exit(1)

inferred_clusters = {}

Expand Down
1 change: 1 addition & 0 deletions config_generator/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
jinja2
pyyaml
jsonschema
6 changes: 4 additions & 2 deletions demos/function_calling/arch_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ prompt_targets:
- name: city
required: true
description: The city for which the weather forecast is requested.
type: string
- name: days
description: The number of days for which the weather forecast is requested.
type: integer
- name: units
description: The units in which the weather forecast is requested.
type: string
endpoint:
name: api_server
path: /weather
Expand All @@ -50,17 +53,16 @@ prompt_targets:
- name: timezone
description: The city for which the weather forecast is requested.
default: US/Pacific
type: string
endpoint:
name: api_server
path: /current_time
method: Get
system_prompt: |
You are a helpful system time provider. Use system time data that is provided to you. Please following following guidelines when responding to user queries:
- Use 12 hour time format
- Use AM/PM for time
- name: insurance_claim_details
type: function_resolver
description: This function resolver provides insurance claim details for a given policy number.
parameters:
- name: policy_number
Expand Down

0 comments on commit 41cdef5

Please sign in to comment.