Update discriminator to have the correct mapping

This commit is contained in:
Ashwin Bharambe 2025-01-25 22:02:37 -08:00
parent 891bf704eb
commit b9bb6eee39
5 changed files with 404 additions and 143 deletions

View file

@ -122,10 +122,16 @@ class JsonSchemaAnyOf(JsonSchemaNode):
anyOf: List["JsonSchemaAny"] anyOf: List["JsonSchemaAny"]
@dataclass
class Discriminator:
propertyName: str
mapping: Dict[str, str]
@dataclass @dataclass
class JsonSchemaOneOf(JsonSchemaNode): class JsonSchemaOneOf(JsonSchemaNode):
oneOf: List["JsonSchemaAny"] oneOf: List["JsonSchemaAny"]
discriminator: Optional[str] discriminator: Optional[Discriminator]
JsonSchemaAny = Union[ JsonSchemaAny = Union[

View file

@ -456,8 +456,19 @@ class JsonSchemaGenerator:
] ]
} }
if discriminator: if discriminator:
# for each union type, we need to read the value of the discriminator
mapping = {}
for union_type in typing.get_args(typ):
props = self.type_to_schema(union_type, force_expand=True)[
"properties"
]
mapping[props[discriminator]["default"]] = self.type_to_schema(
union_type
)["$ref"]
ret["discriminator"] = { ret["discriminator"] = {
"propertyName": discriminator, "propertyName": discriminator,
"mapping": mapping,
} }
return ret return ret
elif origin_type is Literal: elif origin_type is Literal:

View file

@ -3812,7 +3812,11 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"image": "#/components/schemas/ImageContentItem",
"text": "#/components/schemas/TextContentItem"
}
} }
}, },
"Message": { "Message": {
@ -3831,7 +3835,13 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "role" "propertyName": "role",
"mapping": {
"user": "#/components/schemas/UserMessage",
"system": "#/components/schemas/SystemMessage",
"tool": "#/components/schemas/ToolResponseMessage",
"assistant": "#/components/schemas/CompletionMessage"
}
} }
}, },
"SamplingParams": { "SamplingParams": {
@ -3850,7 +3860,12 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"greedy": "#/components/schemas/GreedySamplingStrategy",
"top_p": "#/components/schemas/TopPSamplingStrategy",
"top_k": "#/components/schemas/TopKSamplingStrategy"
}
} }
}, },
"max_tokens": { "max_tokens": {
@ -4313,91 +4328,101 @@
"job_uuid" "job_uuid"
] ]
}, },
"GrammarResponseFormat": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "grammar",
"default": "grammar"
},
"bnf": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "null"
},
{
"type": "boolean"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array"
},
{
"type": "object"
}
]
}
}
},
"additionalProperties": false,
"required": [
"type",
"bnf"
]
},
"JsonSchemaResponseFormat": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "json_schema",
"default": "json_schema"
},
"json_schema": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "null"
},
{
"type": "boolean"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array"
},
{
"type": "object"
}
]
}
}
},
"additionalProperties": false,
"required": [
"type",
"json_schema"
]
},
"ResponseFormat": { "ResponseFormat": {
"oneOf": [ "oneOf": [
{ {
"type": "object", "$ref": "#/components/schemas/JsonSchemaResponseFormat"
"properties": {
"type": {
"type": "string",
"const": "json_schema",
"default": "json_schema"
},
"json_schema": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "null"
},
{
"type": "boolean"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array"
},
{
"type": "object"
}
]
}
}
},
"additionalProperties": false,
"required": [
"type",
"json_schema"
]
}, },
{ {
"type": "object", "$ref": "#/components/schemas/GrammarResponseFormat"
"properties": {
"type": {
"type": "string",
"const": "grammar",
"default": "grammar"
},
"bnf": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "null"
},
{
"type": "boolean"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array"
},
{
"type": "object"
}
]
}
}
},
"additionalProperties": false,
"required": [
"type",
"bnf"
]
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"json_schema": "#/components/schemas/JsonSchemaResponseFormat",
"grammar": "#/components/schemas/GrammarResponseFormat"
}
} }
}, },
"ChatCompletionRequest": { "ChatCompletionRequest": {
@ -4529,7 +4554,12 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"text": "#/components/schemas/TextDelta",
"image": "#/components/schemas/ImageDelta",
"tool_call": "#/components/schemas/ToolCallDelta"
}
} }
}, },
"ImageDelta": { "ImageDelta": {
@ -4737,8 +4767,7 @@
"default": "auto" "default": "auto"
}, },
"tool_prompt_format": { "tool_prompt_format": {
"$ref": "#/components/schemas/ToolPromptFormat", "$ref": "#/components/schemas/ToolPromptFormat"
"default": "json"
}, },
"max_infer_iters": { "max_infer_iters": {
"type": "integer", "type": "integer",
@ -5036,7 +5065,14 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "event_type" "propertyName": "event_type",
"mapping": {
"step_start": "#/components/schemas/AgentTurnResponseStepStartPayload",
"step_progress": "#/components/schemas/AgentTurnResponseStepProgressPayload",
"step_complete": "#/components/schemas/AgentTurnResponseStepCompletePayload",
"turn_start": "#/components/schemas/AgentTurnResponseTurnStartPayload",
"turn_complete": "#/components/schemas/AgentTurnResponseTurnCompletePayload"
}
} }
} }
}, },
@ -5082,7 +5118,13 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "step_type" "propertyName": "step_type",
"mapping": {
"inference": "#/components/schemas/InferenceStep",
"tool_execution": "#/components/schemas/ToolExecutionStep",
"shield_call": "#/components/schemas/ShieldCallStep",
"memory_retrieval": "#/components/schemas/MemoryRetrievalStep"
}
} }
} }
}, },
@ -5485,7 +5527,13 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "step_type" "propertyName": "step_type",
"mapping": {
"inference": "#/components/schemas/InferenceStep",
"tool_execution": "#/components/schemas/ToolExecutionStep",
"shield_call": "#/components/schemas/ShieldCallStep",
"memory_retrieval": "#/components/schemas/MemoryRetrievalStep"
}
} }
} }
}, },
@ -5638,7 +5686,11 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"model": "#/components/schemas/ModelCandidate",
"agent": "#/components/schemas/AgentCandidate"
}
} }
}, },
"scoring_params": { "scoring_params": {
@ -5656,7 +5708,12 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"llm_as_judge": "#/components/schemas/LLMAsJudgeScoringFnParams",
"regex_parser": "#/components/schemas/RegexParserScoringFnParams",
"basic": "#/components/schemas/BasicScoringFnParams"
}
} }
} }
}, },
@ -5709,7 +5766,11 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"model": "#/components/schemas/ModelCandidate",
"agent": "#/components/schemas/AgentCandidate"
}
} }
}, },
"num_examples": { "num_examples": {
@ -5853,7 +5914,11 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"benchmark": "#/components/schemas/BenchmarkEvalTaskConfig",
"app": "#/components/schemas/AppEvalTaskConfig"
}
} }
} }
}, },
@ -6019,7 +6084,13 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "step_type" "propertyName": "step_type",
"mapping": {
"inference": "#/components/schemas/InferenceStep",
"tool_execution": "#/components/schemas/ToolExecutionStep",
"shield_call": "#/components/schemas/ShieldCallStep",
"memory_retrieval": "#/components/schemas/MemoryRetrievalStep"
}
} }
} }
}, },
@ -6237,7 +6308,19 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"string": "#/components/schemas/StringType",
"number": "#/components/schemas/NumberType",
"boolean": "#/components/schemas/BooleanType",
"array": "#/components/schemas/ArrayType",
"object": "#/components/schemas/ObjectType",
"json": "#/components/schemas/JsonType",
"union": "#/components/schemas/UnionType",
"chat_completion_input": "#/components/schemas/ChatCompletionInputType",
"completion_input": "#/components/schemas/CompletionInputType",
"agent_turn_input": "#/components/schemas/AgentTurnInputType"
}
} }
}, },
"StringType": { "StringType": {
@ -6500,7 +6583,12 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"llm_as_judge": "#/components/schemas/LLMAsJudgeScoringFnParams",
"regex_parser": "#/components/schemas/RegexParserScoringFnParams",
"basic": "#/components/schemas/BasicScoringFnParams"
}
} }
} }
}, },
@ -7589,7 +7677,11 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"span_start": "#/components/schemas/SpanStartPayload",
"span_end": "#/components/schemas/SpanEndPayload"
}
} }
} }
}, },
@ -7678,7 +7770,12 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"unstructured_log": "#/components/schemas/UnstructuredLogEvent",
"metric": "#/components/schemas/MetricEvent",
"structured_log": "#/components/schemas/StructuredLogEvent"
}
} }
}, },
"ttl_seconds": { "ttl_seconds": {
@ -8011,7 +8108,11 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"default": "#/components/schemas/DefaultRAGQueryGeneratorConfig",
"llm": "#/components/schemas/LLMRAGQueryGeneratorConfig"
}
} }
}, },
"QueryRequest": { "QueryRequest": {
@ -8406,7 +8507,12 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"llm_as_judge": "#/components/schemas/LLMAsJudgeScoringFnParams",
"regex_parser": "#/components/schemas/RegexParserScoringFnParams",
"basic": "#/components/schemas/BasicScoringFnParams"
}
} }
} }
}, },
@ -8542,7 +8648,11 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"benchmark": "#/components/schemas/BenchmarkEvalTaskConfig",
"app": "#/components/schemas/AppEvalTaskConfig"
}
} }
} }
}, },
@ -8694,7 +8804,12 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"llm_as_judge": "#/components/schemas/LLMAsJudgeScoringFnParams",
"regex_parser": "#/components/schemas/RegexParserScoringFnParams",
"basic": "#/components/schemas/BasicScoringFnParams"
}
} }
}, },
{ {
@ -8748,7 +8863,12 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"llm_as_judge": "#/components/schemas/LLMAsJudgeScoringFnParams",
"regex_parser": "#/components/schemas/RegexParserScoringFnParams",
"basic": "#/components/schemas/BasicScoringFnParams"
}
} }
}, },
{ {
@ -8928,7 +9048,11 @@
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type" "propertyName": "type",
"mapping": {
"LoRA": "#/components/schemas/LoraFinetuningConfig",
"QAT": "#/components/schemas/QATFinetuningConfig"
}
} }
} }
}, },
@ -9290,6 +9414,10 @@
"name": "EvaluateRowsRequest", "name": "EvaluateRowsRequest",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/EvaluateRowsRequest\" />" "description": "<SchemaDefinition schemaRef=\"#/components/schemas/EvaluateRowsRequest\" />"
}, },
{
"name": "GrammarResponseFormat",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/GrammarResponseFormat\" />"
},
{ {
"name": "GreedySamplingStrategy", "name": "GreedySamplingStrategy",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/GreedySamplingStrategy\" />" "description": "<SchemaDefinition schemaRef=\"#/components/schemas/GreedySamplingStrategy\" />"
@ -9344,6 +9472,10 @@
"name": "JobStatus", "name": "JobStatus",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/JobStatus\" />" "description": "<SchemaDefinition schemaRef=\"#/components/schemas/JobStatus\" />"
}, },
{
"name": "JsonSchemaResponseFormat",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/JsonSchemaResponseFormat\" />"
},
{ {
"name": "JsonType", "name": "JsonType",
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/JsonType\" />" "description": "<SchemaDefinition schemaRef=\"#/components/schemas/JsonType\" />"
@ -9924,6 +10056,7 @@
"EvalTask", "EvalTask",
"EvaluateResponse", "EvaluateResponse",
"EvaluateRowsRequest", "EvaluateRowsRequest",
"GrammarResponseFormat",
"GreedySamplingStrategy", "GreedySamplingStrategy",
"HealthInfo", "HealthInfo",
"ImageContentItem", "ImageContentItem",
@ -9936,6 +10069,7 @@
"InvokeToolRequest", "InvokeToolRequest",
"Job", "Job",
"JobStatus", "JobStatus",
"JsonSchemaResponseFormat",
"JsonType", "JsonType",
"LLMAsJudgeScoringFnParams", "LLMAsJudgeScoringFnParams",
"LLMRAGQueryGeneratorConfig", "LLMRAGQueryGeneratorConfig",

View file

@ -45,7 +45,6 @@ components:
default: auto default: auto
tool_prompt_format: tool_prompt_format:
$ref: '#/components/schemas/ToolPromptFormat' $ref: '#/components/schemas/ToolPromptFormat'
default: json
toolgroups: toolgroups:
items: items:
$ref: '#/components/schemas/AgentTool' $ref: '#/components/schemas/AgentTool'
@ -77,6 +76,11 @@ components:
properties: properties:
step: step:
discriminator: discriminator:
mapping:
inference: '#/components/schemas/InferenceStep'
memory_retrieval: '#/components/schemas/MemoryRetrievalStep'
shield_call: '#/components/schemas/ShieldCallStep'
tool_execution: '#/components/schemas/ToolExecutionStep'
propertyName: step_type propertyName: step_type
oneOf: oneOf:
- $ref: '#/components/schemas/InferenceStep' - $ref: '#/components/schemas/InferenceStep'
@ -122,6 +126,12 @@ components:
properties: properties:
payload: payload:
discriminator: discriminator:
mapping:
step_complete: '#/components/schemas/AgentTurnResponseStepCompletePayload'
step_progress: '#/components/schemas/AgentTurnResponseStepProgressPayload'
step_start: '#/components/schemas/AgentTurnResponseStepStartPayload'
turn_complete: '#/components/schemas/AgentTurnResponseTurnCompletePayload'
turn_start: '#/components/schemas/AgentTurnResponseTurnStartPayload'
propertyName: event_type propertyName: event_type
oneOf: oneOf:
- $ref: '#/components/schemas/AgentTurnResponseStepStartPayload' - $ref: '#/components/schemas/AgentTurnResponseStepStartPayload'
@ -142,6 +152,11 @@ components:
type: string type: string
step_details: step_details:
discriminator: discriminator:
mapping:
inference: '#/components/schemas/InferenceStep'
memory_retrieval: '#/components/schemas/MemoryRetrievalStep'
shield_call: '#/components/schemas/ShieldCallStep'
tool_execution: '#/components/schemas/ToolExecutionStep'
propertyName: step_type propertyName: step_type
oneOf: oneOf:
- $ref: '#/components/schemas/InferenceStep' - $ref: '#/components/schemas/InferenceStep'
@ -265,6 +280,9 @@ components:
properties: properties:
eval_candidate: eval_candidate:
discriminator: discriminator:
mapping:
agent: '#/components/schemas/AgentCandidate'
model: '#/components/schemas/ModelCandidate'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/ModelCandidate' - $ref: '#/components/schemas/ModelCandidate'
@ -274,6 +292,10 @@ components:
scoring_params: scoring_params:
additionalProperties: additionalProperties:
discriminator: discriminator:
mapping:
basic: '#/components/schemas/BasicScoringFnParams'
llm_as_judge: '#/components/schemas/LLMAsJudgeScoringFnParams'
regex_parser: '#/components/schemas/RegexParserScoringFnParams'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/LLMAsJudgeScoringFnParams' - $ref: '#/components/schemas/LLMAsJudgeScoringFnParams'
@ -413,6 +435,9 @@ components:
properties: properties:
eval_candidate: eval_candidate:
discriminator: discriminator:
mapping:
agent: '#/components/schemas/AgentCandidate'
model: '#/components/schemas/ModelCandidate'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/ModelCandidate' - $ref: '#/components/schemas/ModelCandidate'
@ -632,6 +657,10 @@ components:
type: object type: object
ContentDelta: ContentDelta:
discriminator: discriminator:
mapping:
image: '#/components/schemas/ImageDelta'
text: '#/components/schemas/TextDelta'
tool_call: '#/components/schemas/ToolCallDelta'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/TextDelta' - $ref: '#/components/schemas/TextDelta'
@ -912,6 +941,9 @@ components:
type: array type: array
task_config: task_config:
discriminator: discriminator:
mapping:
app: '#/components/schemas/AppEvalTaskConfig'
benchmark: '#/components/schemas/BenchmarkEvalTaskConfig'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/BenchmarkEvalTaskConfig' - $ref: '#/components/schemas/BenchmarkEvalTaskConfig'
@ -921,6 +953,27 @@ components:
- scoring_functions - scoring_functions
- task_config - task_config
type: object type: object
GrammarResponseFormat:
additionalProperties: false
properties:
bnf:
additionalProperties:
oneOf:
- type: 'null'
- type: boolean
- type: number
- type: string
- type: array
- type: object
type: object
type:
const: grammar
default: grammar
type: string
required:
- type
- bnf
type: object
GreedySamplingStrategy: GreedySamplingStrategy:
additionalProperties: false additionalProperties: false
properties: properties:
@ -1055,6 +1108,9 @@ components:
type: array type: array
InterleavedContentItem: InterleavedContentItem:
discriminator: discriminator:
mapping:
image: '#/components/schemas/ImageContentItem'
text: '#/components/schemas/TextContentItem'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/ImageContentItem' - $ref: '#/components/schemas/ImageContentItem'
@ -1093,6 +1149,27 @@ components:
- failed - failed
- scheduled - scheduled
type: string type: string
JsonSchemaResponseFormat:
additionalProperties: false
properties:
json_schema:
additionalProperties:
oneOf:
- type: 'null'
- type: boolean
- type: number
- type: string
- type: array
- type: object
type: object
type:
const: json_schema
default: json_schema
type: string
required:
- type
- json_schema
type: object
JsonType: JsonType:
additionalProperties: false additionalProperties: false
properties: properties:
@ -1263,6 +1340,10 @@ components:
properties: properties:
event: event:
discriminator: discriminator:
mapping:
metric: '#/components/schemas/MetricEvent'
structured_log: '#/components/schemas/StructuredLogEvent'
unstructured_log: '#/components/schemas/UnstructuredLogEvent'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/UnstructuredLogEvent' - $ref: '#/components/schemas/UnstructuredLogEvent'
@ -1346,6 +1427,11 @@ components:
type: object type: object
Message: Message:
discriminator: discriminator:
mapping:
assistant: '#/components/schemas/CompletionMessage'
system: '#/components/schemas/SystemMessage'
tool: '#/components/schemas/ToolResponseMessage'
user: '#/components/schemas/UserMessage'
propertyName: role propertyName: role
oneOf: oneOf:
- $ref: '#/components/schemas/UserMessage' - $ref: '#/components/schemas/UserMessage'
@ -1518,6 +1604,17 @@ components:
type: object type: object
ParamType: ParamType:
discriminator: discriminator:
mapping:
agent_turn_input: '#/components/schemas/AgentTurnInputType'
array: '#/components/schemas/ArrayType'
boolean: '#/components/schemas/BooleanType'
chat_completion_input: '#/components/schemas/ChatCompletionInputType'
completion_input: '#/components/schemas/CompletionInputType'
json: '#/components/schemas/JsonType'
number: '#/components/schemas/NumberType'
object: '#/components/schemas/ObjectType'
string: '#/components/schemas/StringType'
union: '#/components/schemas/UnionType'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/StringType' - $ref: '#/components/schemas/StringType'
@ -1830,6 +1927,9 @@ components:
type: object type: object
RAGQueryGeneratorConfig: RAGQueryGeneratorConfig:
discriminator: discriminator:
mapping:
default: '#/components/schemas/DefaultRAGQueryGeneratorConfig'
llm: '#/components/schemas/LLMRAGQueryGeneratorConfig'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/DefaultRAGQueryGeneratorConfig' - $ref: '#/components/schemas/DefaultRAGQueryGeneratorConfig'
@ -1949,6 +2049,10 @@ components:
type: string type: string
params: params:
discriminator: discriminator:
mapping:
basic: '#/components/schemas/BasicScoringFnParams'
llm_as_judge: '#/components/schemas/LLMAsJudgeScoringFnParams'
regex_parser: '#/components/schemas/RegexParserScoringFnParams'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/LLMAsJudgeScoringFnParams' - $ref: '#/components/schemas/LLMAsJudgeScoringFnParams'
@ -2031,48 +2135,13 @@ components:
type: object type: object
ResponseFormat: ResponseFormat:
discriminator: discriminator:
mapping:
grammar: '#/components/schemas/GrammarResponseFormat'
json_schema: '#/components/schemas/JsonSchemaResponseFormat'
propertyName: type propertyName: type
oneOf: oneOf:
- additionalProperties: false - $ref: '#/components/schemas/JsonSchemaResponseFormat'
properties: - $ref: '#/components/schemas/GrammarResponseFormat'
json_schema:
additionalProperties:
oneOf:
- type: 'null'
- type: boolean
- type: number
- type: string
- type: array
- type: object
type: object
type:
const: json_schema
default: json_schema
type: string
required:
- type
- json_schema
type: object
- additionalProperties: false
properties:
bnf:
additionalProperties:
oneOf:
- type: 'null'
- type: boolean
- type: number
- type: string
- type: array
- type: object
type: object
type:
const: grammar
default: grammar
type: string
required:
- type
- bnf
type: object
RouteInfo: RouteInfo:
additionalProperties: false additionalProperties: false
properties: properties:
@ -2094,6 +2163,9 @@ components:
properties: properties:
task_config: task_config:
discriminator: discriminator:
mapping:
app: '#/components/schemas/AppEvalTaskConfig'
benchmark: '#/components/schemas/BenchmarkEvalTaskConfig'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/BenchmarkEvalTaskConfig' - $ref: '#/components/schemas/BenchmarkEvalTaskConfig'
@ -2163,6 +2235,10 @@ components:
type: number type: number
strategy: strategy:
discriminator: discriminator:
mapping:
greedy: '#/components/schemas/GreedySamplingStrategy'
top_k: '#/components/schemas/TopKSamplingStrategy'
top_p: '#/components/schemas/TopPSamplingStrategy'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/GreedySamplingStrategy' - $ref: '#/components/schemas/GreedySamplingStrategy'
@ -2202,6 +2278,10 @@ components:
additionalProperties: additionalProperties:
oneOf: oneOf:
- discriminator: - discriminator:
mapping:
basic: '#/components/schemas/BasicScoringFnParams'
llm_as_judge: '#/components/schemas/LLMAsJudgeScoringFnParams'
regex_parser: '#/components/schemas/RegexParserScoringFnParams'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/LLMAsJudgeScoringFnParams' - $ref: '#/components/schemas/LLMAsJudgeScoringFnParams'
@ -2245,6 +2325,10 @@ components:
additionalProperties: additionalProperties:
oneOf: oneOf:
- discriminator: - discriminator:
mapping:
basic: '#/components/schemas/BasicScoringFnParams'
llm_as_judge: '#/components/schemas/LLMAsJudgeScoringFnParams'
regex_parser: '#/components/schemas/RegexParserScoringFnParams'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/LLMAsJudgeScoringFnParams' - $ref: '#/components/schemas/LLMAsJudgeScoringFnParams'
@ -2285,6 +2369,10 @@ components:
type: object type: object
params: params:
discriminator: discriminator:
mapping:
basic: '#/components/schemas/BasicScoringFnParams'
llm_as_judge: '#/components/schemas/LLMAsJudgeScoringFnParams'
regex_parser: '#/components/schemas/RegexParserScoringFnParams'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/LLMAsJudgeScoringFnParams' - $ref: '#/components/schemas/LLMAsJudgeScoringFnParams'
@ -2544,6 +2632,9 @@ components:
type: object type: object
payload: payload:
discriminator: discriminator:
mapping:
span_end: '#/components/schemas/SpanEndPayload'
span_start: '#/components/schemas/SpanStartPayload'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/SpanStartPayload' - $ref: '#/components/schemas/SpanStartPayload'
@ -2571,6 +2662,9 @@ components:
properties: properties:
algorithm_config: algorithm_config:
discriminator: discriminator:
mapping:
LoRA: '#/components/schemas/LoraFinetuningConfig'
QAT: '#/components/schemas/QATFinetuningConfig'
propertyName: type propertyName: type
oneOf: oneOf:
- $ref: '#/components/schemas/LoraFinetuningConfig' - $ref: '#/components/schemas/LoraFinetuningConfig'
@ -3160,6 +3254,11 @@ components:
steps: steps:
items: items:
discriminator: discriminator:
mapping:
inference: '#/components/schemas/InferenceStep'
memory_retrieval: '#/components/schemas/MemoryRetrievalStep'
shield_call: '#/components/schemas/ShieldCallStep'
tool_execution: '#/components/schemas/ToolExecutionStep'
propertyName: step_type propertyName: step_type
oneOf: oneOf:
- $ref: '#/components/schemas/InferenceStep' - $ref: '#/components/schemas/InferenceStep'
@ -5846,6 +5945,9 @@ tags:
- description: <SchemaDefinition schemaRef="#/components/schemas/EvaluateRowsRequest" - description: <SchemaDefinition schemaRef="#/components/schemas/EvaluateRowsRequest"
/> />
name: EvaluateRowsRequest name: EvaluateRowsRequest
- description: <SchemaDefinition schemaRef="#/components/schemas/GrammarResponseFormat"
/>
name: GrammarResponseFormat
- description: <SchemaDefinition schemaRef="#/components/schemas/GreedySamplingStrategy" - description: <SchemaDefinition schemaRef="#/components/schemas/GreedySamplingStrategy"
/> />
name: GreedySamplingStrategy name: GreedySamplingStrategy
@ -5878,6 +5980,9 @@ tags:
name: Job name: Job
- description: <SchemaDefinition schemaRef="#/components/schemas/JobStatus" /> - description: <SchemaDefinition schemaRef="#/components/schemas/JobStatus" />
name: JobStatus name: JobStatus
- description: <SchemaDefinition schemaRef="#/components/schemas/JsonSchemaResponseFormat"
/>
name: JsonSchemaResponseFormat
- description: <SchemaDefinition schemaRef="#/components/schemas/JsonType" /> - description: <SchemaDefinition schemaRef="#/components/schemas/JsonType" />
name: JsonType name: JsonType
- description: <SchemaDefinition schemaRef="#/components/schemas/LLMAsJudgeScoringFnParams" - description: <SchemaDefinition schemaRef="#/components/schemas/LLMAsJudgeScoringFnParams"
@ -6285,6 +6390,7 @@ x-tagGroups:
- EvalTask - EvalTask
- EvaluateResponse - EvaluateResponse
- EvaluateRowsRequest - EvaluateRowsRequest
- GrammarResponseFormat
- GreedySamplingStrategy - GreedySamplingStrategy
- HealthInfo - HealthInfo
- ImageContentItem - ImageContentItem
@ -6297,6 +6403,7 @@ x-tagGroups:
- InvokeToolRequest - InvokeToolRequest
- Job - Job
- JobStatus - JobStatus
- JsonSchemaResponseFormat
- JsonType - JsonType
- LLMAsJudgeScoringFnParams - LLMAsJudgeScoringFnParams
- LLMRAGQueryGeneratorConfig - LLMRAGQueryGeneratorConfig

View file

@ -157,11 +157,13 @@ class ChatCompletionResponseEvent(BaseModel):
stop_reason: Optional[StopReason] = None stop_reason: Optional[StopReason] = None
@json_schema_type
class ResponseFormatType(Enum): class ResponseFormatType(Enum):
json_schema = "json_schema" json_schema = "json_schema"
grammar = "grammar" grammar = "grammar"
@json_schema_type
class JsonSchemaResponseFormat(BaseModel): class JsonSchemaResponseFormat(BaseModel):
type: Literal[ResponseFormatType.json_schema.value] = ( type: Literal[ResponseFormatType.json_schema.value] = (
ResponseFormatType.json_schema.value ResponseFormatType.json_schema.value
@ -169,6 +171,7 @@ class JsonSchemaResponseFormat(BaseModel):
json_schema: Dict[str, Any] json_schema: Dict[str, Any]
@json_schema_type
class GrammarResponseFormat(BaseModel): class GrammarResponseFormat(BaseModel):
type: Literal[ResponseFormatType.grammar.value] = ResponseFormatType.grammar.value type: Literal[ResponseFormatType.grammar.value] = ResponseFormatType.grammar.value
bnf: Dict[str, Any] bnf: Dict[str, Any]