mirror of
https://github.com/katanemo/plano.git
synced 2026-04-25 00:36:34 +02:00
arch schema validator (#105)
* add arch schema validator * schema validator
This commit is contained in:
parent
15869825e3
commit
41cdef590a
5 changed files with 165 additions and 3 deletions
|
|
@ -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
config_generator/arch_config_schema.yaml
Normal file
147
config_generator/arch_config_schema.yaml
Normal file
|
|
@ -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
|
||||
|
|
@ -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 = {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
jinja2
|
||||
pyyaml
|
||||
jsonschema
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue