Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2bc4a5f
Go back to `parameters?: unknown` in FunctionDefinition model
dargilco Aug 19, 2024
4a29832
Merge remote-tracking branch 'origin/main' into dargilco/ai-model-inf…
dargilco Aug 19, 2024
d68a383
Add missing CompletionsFinishReason comments. Update tool choice rela…
dargilco Aug 19, 2024
adeddf3
Update JSON examples. Fix client.tsp after previous commit to rename …
dargilco Aug 19, 2024
3e95e57
Add ID back to EmbeddingsResult model. Add comment to getModelInfo th…
dargilco Aug 23, 2024
dedab7a
Update comments about hand-written operator methods
dargilco Aug 29, 2024
7507aaf
Update teh ModelInfo enum
dargilco Sep 12, 2024
e71bdd9
Merge branch 'main' into dargilco/ai-model-inference
trangevi Dec 10, 2024
6a1a4bc
Merge remote-tracking branch 'origin/main' into dargilco/ai-model-inf…
dargilco Dec 23, 2024
3e647af
Rename EmbeddingInput to ImageEmbeddingInput (#31953)
dargilco Dec 24, 2024
76224a0
Add Structured Outputs (#31962)
trangevi Dec 26, 2024
84764b1
Naming consistency (#31966)
trangevi Dec 27, 2024
55390d1
Merge remote-tracking branch 'origin/main' into dargilco/ai-model-inf…
dargilco Dec 27, 2024
53f0524
Fixes following `npx tsp format **\*.tsp`
dargilco Dec 27, 2024
f1954ee
Fix a couple of errors from `npx tsv .`
dargilco Dec 27, 2024
ee954ff
Add missing class description. Add updated swagger file
dargilco Dec 27, 2024
be57da7
Update description
dargilco Dec 27, 2024
a2bc8a2
Remove the in-line definition
dargilco Dec 27, 2024
e194ad7
Merge remote-tracking branch 'origin/main' into dargilco/ai-model-inf…
dargilco Jan 3, 2025
3409632
Make all response format models internal (#32005)
dargilco Jan 9, 2025
a4f5d74
Merge branch 'dargilco/ai-model-inference' into trangevi/structured-o…
trangevi Jan 9, 2025
1ae1ba1
Merge branch 'dargilco/ai-model-inference' into trangevi/structured-o…
trangevi Jan 9, 2025
2ade2db
Merge branch 'glharper-inference-ts-dpg' into trangevi/structured-out…
trangevi Jan 9, 2025
3b509f8
Update client.tsp - alias ChatCompletionsResponseFormatJsonObject in …
glharper Jan 13, 2025
51389f8
Update chat_completions.tsp
glharper Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make all response format models internal (#32005)
  • Loading branch information
dargilco authored Jan 9, 2025
commit 3409632fa98a3d1bdf6852cc08426289bf04f886
30 changes: 15 additions & 15 deletions specification/ai/ModelClient/client.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ namespace Customizations; // The actual name here doesn't matter and is here for
@@usage(AI.Model.StreamingChatResponseMessageUpdate, Usage.output);
@@usage(AI.Model.StreamingChatResponseToolCallUpdate, Usage.output);

// Since we made all operator methods internal, we need to expliclty
// say we still want the models they use to be public.
// The operators need to be hidden, since we hand-write the public versions of those
@@access(AI.Model.getChatCompletions, Access.internal);
@@access(AI.Model.getEmbeddings, Access.internal);
@@access(AI.Model.getImageEmbeddings, Access.internal);
@@access(AI.Model.getModelInfo, Access.internal, "python");

// Since we made all operator methods internal, we need to explicity
// say we still want the models they use to be public, since they will be used by hand-written operator methods.
@@access(AI.Model.ChatChoice, Access.public);
@@access(AI.Model.ChatCompletions, Access.public);
@@access(AI.Model.ChatCompletionsToolCall, Access.public);
@@access(AI.Model.ChatCompletionsToolDefinition, Access.public);
@@access(AI.Model.ChatCompletionsNamedToolChoice, Access.public);
@@access(AI.Model.ChatCompletionsNamedToolChoiceFunction, Access.public);
@@access(AI.Model.ChatCompletionsResponseFormat, Access.public);
@@access(AI.Model.ChatCompletionsResponseFormatJsonObject, Access.public);
@@access(AI.Model.ChatCompletionsResponseFormatText, Access.public);
@@access(AI.Model.ChatCompletionsToolCall, Access.public);
@@access(AI.Model.ChatCompletionsToolDefinition, Access.public);
@@access(AI.Model.ChatCompletionsToolChoicePreset, Access.public);
Expand Down Expand Up @@ -58,17 +61,14 @@ namespace Customizations; // The actual name here doesn't matter and is here for
@@access(AI.Model.StreamingChatChoiceUpdate, Access.public, "python");
@@access(AI.Model.StreamingChatResponseMessageUpdate, Access.public, "python");
@@access(AI.Model.StreamingChatResponseToolCallUpdate, Access.public, "python");
@@access(AI.Model.ChatCompletionsResponseFormatJsonSchemaDefinition,
Access.public,
"python"
);

// The operators need to be hidden, since we hand-write the public versions of those
@@access(AI.Model.getChatCompletions, Access.internal);
@@access(AI.Model.getEmbeddings, Access.internal);
@@access(AI.Model.getImageEmbeddings, Access.internal);
@@access(AI.Model.getModelInfo, Access.internal, "python");

// Hide the JSON schema class in favor of a factory method on the ChatCompletionsResponseFormat class
@@access(AI.Model.ChatCompletionsResponseFormatJsonSchema,
Access.internal,
"csharp"
@@clientName(AI.Model.ChatCompletionsResponseFormatJsonSchemaDefinition,
"JsonSchemaFormat",
"python"
);

// We use shorter names in the Python client library
Expand Down
24 changes: 17 additions & 7 deletions specification/ai/ModelClient/models/chat_completions.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -266,22 +266,32 @@ model ChatCompletionsResponseFormatJsonObject
}

@doc("""
The definition of the required JSON schema in the response, and associated metadata.
Defines the response format for chat completions as JSON with a given schema. The AI model
will need to adhere to this schema when generating completions.
""")
model ChatCompletionsResponseFormatJsonSchemaDefinition {
/** The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. */
@doc("""
A name that labels this JSON schema. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
""")
name: string;

/** The definition of the JSON schema */
@doc("""
The definition of the JSON schema. See https://json-schema.org/overview/what-is-jsonschema.
Note that AI models usually only support a subset of the keywords defined by JSON schema. Consult your AI model documentation
to determine what is supported.
""")
schema: Record<unknown>;

/** A description of the response format, used by the AI model to determine how to generate responses in this format. */
@doc("""
A description of the response format, used by the AI model to determine how to generate responses in this format.
""")
description?: string;

@doc("""
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. Only a subset of
JSON Schema is supported when `strict` is `true`.
If set to true, the service will error out if the provided JSON schema contains keywords
not supported by the AI model. An example of such keyword may be `maxLength` for JSON type `string`.
If false, and the provided JSON schema contains keywords not supported
by the AI model, the AI model will not error out. Instead it will ignore the unsupported keywords.
""")
strict?: boolean = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,15 +688,15 @@
},
"ChatCompletionsResponseFormatJsonSchemaDefinition": {
"type": "object",
"description": "The definition of the required JSON schema in the response, and associated metadata.",
"description": "Defines the response format for chat completions as JSON with a given schema. The AI model\nwill need to adhere to this schema when generating completions.",
"properties": {
"name": {
"type": "string",
"description": "The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."
"description": "A name that labels this JSON schema. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."
},
"schema": {
"type": "object",
"description": "The definition of the JSON schema",
"description": "The definition of the JSON schema. See https://json-schema.org/overview/what-is-jsonschema.\nNote that AI models usually only support a subset of the keywords defined by JSON schema. Consult your AI model documentation\nto determine what is supported.",
"additionalProperties": {}
},
"description": {
Expand All @@ -705,7 +705,7 @@
},
"strict": {
"type": "boolean",
"description": "Whether to enable strict schema adherence when generating the output.\nIf set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of\nJSON Schema is supported when `strict` is `true`.",
"description": "If set to true, the service will error out if the provided JSON schema contains keywords\nnot supported by the AI model. An example of such keyword may be `maxLength` for JSON type `string`.\nIf false, and the provided JSON schema contains keywords not supported\nby the AI model, the AI model will not error out. Instead it will ignore the unsupported keywords.",
"default": false
}
},
Expand Down
Loading