diff --git a/config_generator/Dockerfile b/config_generator/Dockerfile index fcfd0655..a639504c 100644 --- a/config_generator/Dockerfile +++ b/config_generator/Dockerfile @@ -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"] diff --git a/config_generator/arch_config_schema.yaml b/config_generator/arch_config_schema.yaml new file mode 100644 index 00000000..c8f7259f --- /dev/null +++ b/config_generator/arch_config_schema.yaml @@ -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 diff --git a/config_generator/config_generator.py b/config_generator/config_generator.py index 3b0b048a..8f98b92c 100644 --- a/config_generator/config_generator.py +++ b/config_generator/config_generator.py @@ -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('./')) @@ -12,7 +14,17 @@ template = env.get_template('envoy.template.yaml') 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 = {} diff --git a/config_generator/requirements.txt b/config_generator/requirements.txt index 4e859bb8..d7b1241e 100644 --- a/config_generator/requirements.txt +++ b/config_generator/requirements.txt @@ -1,2 +1,3 @@ jinja2 pyyaml +jsonschema diff --git a/demos/function_calling/arch_config.yaml b/demos/function_calling/arch_config.yaml index 70ac9922..7a6010f1 100644 --- a/demos/function_calling/arch_config.yaml +++ b/demos/function_calling/arch_config.yaml @@ -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 @@ -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