@@ -4,7 +4,6 @@ use std::{
44} ;
55
66use serde:: { Deserialize , Serialize , de:: Error } ;
7- use serde_json:: json;
87use utoipa:: ToSchema ;
98
109use super :: { ConfigProvider , EntityStore , IndexFn } ;
@@ -18,82 +17,8 @@ use crate::{
1817} ;
1918
2019static SCHEMA : LazyLock < serde_json:: Value > = LazyLock :: new ( || {
21- json ! ( {
22- "$schema" : "https://json-schema.org/draft/2020-12/schema#" ,
23- "type" : "object" ,
24- "properties" : {
25- "name" : { "type" : "string" } ,
26- "model" : {
27- "type" : "string" ,
28- "pattern" : MODELS_PATTERN
29- } ,
30- "provider_config" : { "type" : "object" } ,
31- "timeout" : {
32- "type" : "integer" ,
33- "minimum" : 0
34- } ,
35- "rate_limit" : { "type" : "object" }
36- } ,
37- "required" : [ "name" , "model" , "provider_config" ] ,
38- "additionalProperties" : false ,
39- "allOf" : [
40- {
41- "if" : {
42- "properties" : {
43- "model" : {
44- "type" : "string" ,
45- "pattern" : "^(anthropic|deepseek|gemini|openai)/.+$"
46- }
47- } ,
48- "required" : [ "model" ]
49- } ,
50- "then" : {
51- "properties" : {
52- "provider_config" : { "$ref" : "#/$defs/openai_compatible" }
53- }
54- }
55- } ,
56- {
57- "if" : {
58- "properties" : {
59- "model" : {
60- "type" : "string" ,
61- "pattern" : "^bedrock/.+$"
62- }
63- } ,
64- "required" : [ "model" ]
65- } ,
66- "then" : {
67- "properties" : {
68- "provider_config" : { "$ref" : "#/$defs/bedrock" }
69- }
70- }
71- }
72- ] ,
73- "$defs" : {
74- "openai_compatible" : {
75- "type" : "object" ,
76- "required" : [ "api_key" ] ,
77- "properties" : {
78- "api_key" : { "type" : "string" } ,
79- "api_base" : { "type" : "string" }
80- } ,
81- "additionalProperties" : false
82- } ,
83- "bedrock" : {
84- "type" : "object" ,
85- "required" : [ "region" , "access_key_id" , "secret_access_key" ] ,
86- "properties" : {
87- "region" : { "type" : "string" } ,
88- "access_key_id" : { "type" : "string" } ,
89- "secret_access_key" : { "type" : "string" } ,
90- "session_token" : { "type" : "string" } ,
91- "endpoint" : { "type" : "string" }
92- } ,
93- "additionalProperties" : false
94- }
95- }
96- } )
20+ serde_json:: from_str ( include_str ! ( "models-schema.json" ) )
21+ . expect ( "Invalid JSON document for Model schema" )
9722} ) ;
9823pub static SCHEMA_VALIDATOR : LazyLock < jsonschema:: Validator > =
9924 LazyLock :: new ( || jsonschema:: validator_for ( & SCHEMA ) . expect ( "Invalid JSON schema for Model" ) ) ;
0 commit comments