diff --git a/packages/tasks/src/tasks/chat-completion/inference.ts b/packages/tasks/src/tasks/chat-completion/inference.ts index 4e36277258..9ee1b60944 100644 --- a/packages/tasks/src/tasks/chat-completion/inference.ts +++ b/packages/tasks/src/tasks/chat-completion/inference.ts @@ -136,35 +136,17 @@ export interface ChatCompletionInputFunctionDefinition { [property: string]: unknown; } export interface ChatCompletionInputGrammarType { - json_schema?: ChatCompletionInputJSONSchemaConfig; type: ChatCompletionInputGrammarTypeType; - [property: string]: unknown; -} -export interface ChatCompletionInputJSONSchemaConfig { - /** - * A description of what the response format is for, used by the model to determine how to - * respond in the format. - */ - description?: string; /** - * The name of the response format. - */ - name: string; - /** - * The schema for the response format, described as a JSON Schema object. Learn how to build - * JSON schemas [here](https://json-schema.org/). - */ - schema?: { - [key: string]: unknown; - }; - /** - * Whether to enable strict schema adherence when generating the output. If set to true, the - * model will always follow the exact schema defined in the `schema` field. + * A string that represents a [JSON Schema](https://json-schema.org/). + * + * JSON Schema is a declarative language that allows to annotate JSON documents + * with types and descriptions. */ - strict?: boolean; + value: unknown; [property: string]: unknown; } -export type ChatCompletionInputGrammarTypeType = "text" | "json_schema" | "json_object"; +export type ChatCompletionInputGrammarTypeType = "json" | "regex" | "json_schema"; export interface ChatCompletionInputStreamOptions { /** * If set, an additional chunk will be streamed before the data: [DONE] message. The usage diff --git a/packages/tasks/src/tasks/chat-completion/spec/input.json b/packages/tasks/src/tasks/chat-completion/spec/input.json index bb99438004..1d2c76da45 100644 --- a/packages/tasks/src/tasks/chat-completion/spec/input.json +++ b/packages/tasks/src/tasks/chat-completion/spec/input.json @@ -291,75 +291,61 @@ "ChatCompletionInputGrammarType": { "oneOf": [ { - "$ref": "#/$defs/ChatCompletionInputResponseFormatText" + "type": "object", + "required": ["type", "value"], + "properties": { + "type": { + "type": "string", + "enum": ["json"] + }, + "value": { + "description": "A string that represents a [JSON Schema](https://json-schema.org/).\n\nJSON Schema is a declarative language that allows to annotate JSON documents\nwith types and descriptions." + } + } }, { - "$ref": "#/$defs/ChatCompletionInputResponseFormatJSONSchema" + "type": "object", + "required": ["type", "value"], + "properties": { + "type": { + "type": "string", + "enum": ["regex"] + }, + "value": { + "type": "string" + } + } }, { - "$ref": "#/$defs/ChatCompletionInputResponseFormatJSONObject" + "type": "object", + "required": ["type", "value"], + "properties": { + "type": { + "type": "string", + "enum": ["json_schema"] + }, + "value": { + "$ref": "#/$defs/ChatCompletionInputJsonSchemaConfig" + } + } } ], - "title": "ChatCompletionInputGrammarType" - }, - "ChatCompletionInputResponseFormatText": { - "type": "object", - "required": ["type"], - "properties": { - "type": { - "type": "string", - "enum": ["text"] - } - }, - "title": "ChatCompletionInputResponseFormatText" - }, - "ChatCompletionInputResponseFormatJSONSchema": { - "type": "object", - "required": ["type", "json_schema"], - "properties": { - "type": { - "type": "string", - "enum": ["json_schema"] - }, - "json_schema": { - "$ref": "#/$defs/ChatCompletionInputJsonSchemaConfig" - } - }, - "title": "ChatCompletionInputResponseFormatJSONSchema" - }, - "ChatCompletionInputResponseFormatJSONObject": { - "type": "object", - "required": ["type"], - "properties": { - "type": { - "type": "string", - "enum": ["json_object"] - } + "discriminator": { + "propertyName": "type" }, - "title": "ChatCompletionInputResponseFormatJSONObject" + "title": "ChatCompletionInputGrammarType" }, "ChatCompletionInputJsonSchemaConfig": { "type": "object", - "required": ["name"], + "required": ["schema"], "properties": { "name": { "type": "string", - "description": "The name of the response format." - }, - "description": { - "type": "string", - "description": "A description of what the response format is for, used by the model to determine how to respond in the format.", + "description": "Optional name identifier for the schema", "nullable": true }, "schema": { - "type": "object", - "description": "The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas [here](https://json-schema.org/).", - "nullable": true - }, - "strict": { - "type": "boolean", - "description": "Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field.", - "nullable": true + "description": "The actual JSON schema definition" } }, "title": "ChatCompletionInputJsonSchemaConfig"