Updated the api spec to include COT object

This commit is contained in:
Yukt Mitash 2025-03-10 14:31:06 -07:00
parent 0b8cb830b9
commit 5388d212bc
3 changed files with 60 additions and 2 deletions

View file

@ -3706,6 +3706,28 @@
], ],
"title": "AppendRowsRequest" "title": "AppendRowsRequest"
}, },
"ChainOfThoughtContentItem": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "chainOfThought",
"default": "chainOfThought",
"description": "Discriminator type of the content item. Always \"ChainOfThought\""
},
"text": {
"type": "string",
"description": "Chain of Thought content"
}
},
"additionalProperties": false,
"required": [
"type",
"text"
],
"title": "ChainOfThoughtContentItem",
"description": "A Chain of Thought content item"
},
"CompletionMessage": { "CompletionMessage": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -3861,13 +3883,17 @@
}, },
{ {
"$ref": "#/components/schemas/TextContentItem" "$ref": "#/components/schemas/TextContentItem"
},
{
"$ref": "#/components/schemas/ChainOfThoughtContentItem"
} }
], ],
"discriminator": { "discriminator": {
"propertyName": "type", "propertyName": "type",
"mapping": { "mapping": {
"image": "#/components/schemas/ImageContentItem", "image": "#/components/schemas/ImageContentItem",
"text": "#/components/schemas/TextContentItem" "text": "#/components/schemas/TextContentItem",
"chainOfThought": "#/components/schemas/ChainOfThoughtContentItem"
} }
} }
}, },

View file

@ -2518,6 +2518,24 @@ components:
- dataset_id - dataset_id
- rows - rows
title: AppendRowsRequest title: AppendRowsRequest
ChainOfThoughtContentItem:
type: object
properties:
type:
type: string
const: chainOfThought
default: chainOfThought
description: >-
Discriminator type of the content item. Always "ChainOfThought"
text:
type: string
description: Chain of Thought content
additionalProperties: false
required:
- type
- text
title: ChainOfThoughtContentItem
description: A Chain of Thought content item
CompletionMessage: CompletionMessage:
type: object type: object
properties: properties:
@ -2637,11 +2655,13 @@ components:
oneOf: oneOf:
- $ref: '#/components/schemas/ImageContentItem' - $ref: '#/components/schemas/ImageContentItem'
- $ref: '#/components/schemas/TextContentItem' - $ref: '#/components/schemas/TextContentItem'
- $ref: '#/components/schemas/ChainOfThoughtContentItem'
discriminator: discriminator:
propertyName: type propertyName: type
mapping: mapping:
image: '#/components/schemas/ImageContentItem' image: '#/components/schemas/ImageContentItem'
text: '#/components/schemas/TextContentItem' text: '#/components/schemas/TextContentItem'
chainOfThought: '#/components/schemas/ChainOfThoughtContentItem'
JsonSchemaResponseFormat: JsonSchemaResponseFormat:
type: object type: object
properties: properties:

View file

@ -50,6 +50,18 @@ class ImageContentItem(BaseModel):
image: _URLOrData image: _URLOrData
@json_schema_type
class ChainOfThoughtContentItem(BaseModel):
"""A Chain of Thought content item
:param type: Discriminator type of the content item. Always "ChainOfThought"
:param text: Chain of Thought content
"""
type: Literal["chainOfThought"] = "chainOfThought"
text: str
@json_schema_type @json_schema_type
class TextContentItem(BaseModel): class TextContentItem(BaseModel):
"""A text content item """A text content item
@ -65,7 +77,7 @@ class TextContentItem(BaseModel):
# other modalities can be added here # other modalities can be added here
InterleavedContentItem = register_schema( InterleavedContentItem = register_schema(
Annotated[ Annotated[
Union[ImageContentItem, TextContentItem], Union[ImageContentItem, TextContentItem, ChainOfThoughtContentItem],
Field(discriminator="type"), Field(discriminator="type"),
], ],
name="InterleavedContentItem", name="InterleavedContentItem",