Skip to content

Commit

Permalink
use body root to specify which parameter models we want to keep group…
Browse files Browse the repository at this point in the history
…ed (#29483)

* add ops.ResourceCollectionAction KeepModel

* add ops.ResourceAction KeepModel

* add ops.LongRunningResourceAction KeepModel

* other templates

* switch over to BodyParameter

* format

* use valueof in BodyParameter template, add doc

* remove unnecessary documentation

* add doc to BodyParameter template

* add extra specs

* fix formatting of BodyParameter

* format

* format

* format

* suppress doc warning

* move body parameter to template

* add default body parameter doc

* default bodyparam doc to body parameter

* fix validation errors

* remove bodyparameter from codetransparency

* try for openai

* remove incorrect alias bodyparameter

* don't spread CreateLivenessWithVerifySessionContent

* fix breaking change in easm

* add readme to openai assistants

* update readme

* add tag to readme

* fix json file reference

* add json files to list

---------

Co-authored-by: iscai-msft <isabellavcai@gmail.com>
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
  • Loading branch information
3 people authored Jun 26, 2024
1 parent 2b6c728 commit c286401
Show file tree
Hide file tree
Showing 52 changed files with 1,656 additions and 1,032 deletions.
11 changes: 11 additions & 0 deletions specification/ai/Face/models.common.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,14 @@ model FaceError {
}

model FaceErrorResponse is Azure.Core.Foundations.ErrorResponseBase<FaceError>;

alias BodyParameter<
T,
TName extends valueof string = "body",
TDoc extends valueof string = "Body parameter."
> = {
@doc(TDoc)
@friendlyName(TName)
@bodyRoot
body: T;
};
4 changes: 2 additions & 2 deletions specification/ai/Face/routes.session.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ interface LivenessSessionOperations {
@returnsDoc(SessionCreationSuccess)
createLivenessSession is FaceResourceCreateWithServiceProvidedName<
LivenessSession,
CreateLivenessSessionContent,
BodyParameter<CreateLivenessSessionContent>,
CreateLivenessSessionResult
>;

Expand Down Expand Up @@ -118,7 +118,7 @@ interface LivenessSessionOperations {
@sharedRoute
createLivenessWithVerifySession is FaceResourceCreateWithServiceProvidedName<
LivenessWithVerifySession,
CreateLivenessSessionContent,
BodyParameter<CreateLivenessSessionContent>,
CreateLivenessWithVerifySessionResult
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,14 @@ model ClinicalCodedElement {
@doc("A value associated with the code within the given clinical coding system.")
value?: string;
}

alias BodyParameter<
T,
TName extends valueof string = "body",
TDoc extends valueof string = "Body parameter."
> = {
@doc(TDoc)
@friendlyName(TName)
@bodyRoot
body: T;
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface OncoPhenotype {
@doc("Gets the status and details of the Onco Phenotype job.")
@get
@route("/onco-phenotype/jobs/{id}")
getJob is HealthInsightsLongRunningPollOperation<OncoPhenotypeResult>;
getJob is HealthInsightsLongRunningPollOperation<BodyParameter<OncoPhenotypeResult>>;

#suppress "@azure-tools/typespec-azure-core/long-running-polling-operation-required" "Polling through operation-location"
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "There is no long-running RPC template in Azure.Core"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface PatientTimeline {
@doc("Gets the status and details of the Patient Timeline job.")
@get
@route("/patient-timeline/jobs/{id}")
getJob is HealthInsightsLongRunningPollOperation<PatientTimelineResult>;
getJob is HealthInsightsLongRunningPollOperation<BodyParameter<PatientTimelineResult>>;

#suppress "@azure-tools/typespec-azure-core/long-running-polling-operation-required" "Polling through operation-location"
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "There is no long-running RPC template in Azure.Core"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface TrialMatcher {
@doc("Gets the status and details of the Trial Matcher job.")
@get
@route("/trial-matcher/jobs/{id}")
getJob is HealthInsightsLongRunningPollOperation<TrialMatcherResult>;
getJob is HealthInsightsLongRunningPollOperation<BodyParameter<TrialMatcherResult>>;

#suppress "@azure-tools/typespec-azure-core/long-running-polling-operation-required" "Polling through operation-location"
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "There is no long-running RPC template in Azure.Core"
Expand Down
4 changes: 2 additions & 2 deletions specification/ai/OpenAI.Assistants/assistants/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Azure.AI.OpenAI.Assistants;
@post
@added(ServiceApiVersions.v2024_02_15_preview)
@route("/assistants")
op createAssistant(...AssistantCreationOptions): Assistant;
op createAssistant(...BodyParameter<AssistantCreationOptions>): Assistant;

/**
* Gets a list of assistants that were previously created.
Expand Down Expand Up @@ -63,7 +63,7 @@ op getAssistant(@path assistantId: string): Assistant;
@post
@route("/assistants/{assistantId}")
@added(ServiceApiVersions.v2024_02_15_preview)
op updateAssistant(...UpdateAssistantOptions): Assistant;
op updateAssistant(...BodyParameter<UpdateAssistantOptions>): Assistant;

/**
* Deletes an assistant.
Expand Down
11 changes: 11 additions & 0 deletions specification/ai/OpenAI.Assistants/common/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,14 @@ union ApiResponseFormat {
/** Using `json_object` format will limit the usage of ToolCall to only functions. */
jsonObject: "json_object",
}

alias BodyParameter<
T,
TName extends valueof string = "body",
TDoc extends valueof string = "Body parameter."
> = {
@doc(TDoc)
@friendlyName(TName)
@bodyRoot
body: T;
};
2 changes: 1 addition & 1 deletion specification/ai/OpenAI.Assistants/runs/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ op cancelRun(@path threadId: string, @path runId: string): ThreadRun;
@route("/threads/runs")
@doc("Creates a new assistant thread and immediately starts a run using that new thread.")
@added(ServiceApiVersions.v2024_02_15_preview)
op createThreadAndRun(...CreateAndRunThreadOptions): ThreadRun;
op createThreadAndRun(...BodyParameter<CreateAndRunThreadOptions>): ThreadRun;
8 changes: 6 additions & 2 deletions specification/ai/OpenAI.Assistants/threads/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ namespace Azure.AI.OpenAI.Assistants;
@post
@added(ServiceApiVersions.v2024_02_15_preview)
@route("/threads")
op createThread(...AssistantThreadCreationOptions): AssistantThread;
op createThread(
...BodyParameter<AssistantThreadCreationOptions>,
): AssistantThread;

// list threads?

Expand Down Expand Up @@ -52,7 +54,9 @@ op getThread(@path threadId: string): AssistantThread;
@post
@route("/threads/{threadId}")
@added(ServiceApiVersions.v2024_02_15_preview)
op updateThread(...UpdateAssistantThreadOptions): AssistantThread;
op updateThread(
...BodyParameter<UpdateAssistantThreadOptions>,
): AssistantThread;

/**
* Deletes an existing thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ op listVectorStores(
@post
@route("/vector_stores")
@added(ServiceApiVersions.v2024_05_01_preview)
op createVectorStore(...VectorStoreOptions): VectorStore;
op createVectorStore(...BodyParameter<VectorStoreOptions>): VectorStore;

/**
* Returns the vector store object matching the specified ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/CreateLivenessSessionContent"
Expand Down Expand Up @@ -5846,6 +5847,7 @@
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/CreateLivenessSessionContent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/AssistantCreationOptions"
Expand Down Expand Up @@ -217,11 +218,16 @@
"description": "Modifies an existing assistant.",
"parameters": [
{
"$ref": "#/parameters/UpdateAssistantOptions.assistantId"
"name": "assistantId",
"in": "path",
"description": "The ID of the assistant to modify.",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/UpdateAssistantOptions"
Expand Down Expand Up @@ -460,6 +466,7 @@
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/AssistantThreadCreationOptions"
Expand Down Expand Up @@ -503,11 +510,16 @@
"description": "Modifies an existing thread.",
"parameters": [
{
"$ref": "#/parameters/UpdateAssistantThreadOptions.threadId"
"name": "threadId",
"in": "path",
"description": "The ID of the thread to modify.",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/UpdateAssistantThreadOptions"
Expand Down Expand Up @@ -1235,6 +1247,7 @@
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/CreateAndRunThreadOptions"
Expand Down Expand Up @@ -3181,22 +3194,5 @@
}
}
},
"parameters": {
"UpdateAssistantOptions.assistantId": {
"name": "assistantId",
"in": "path",
"description": "The ID of the assistant to modify.",
"required": true,
"type": "string",
"x-ms-parameter-location": "method"
},
"UpdateAssistantThreadOptions.threadId": {
"name": "threadId",
"in": "path",
"description": "The ID of the thread to modify.",
"required": true,
"type": "string",
"x-ms-parameter-location": "method"
}
}
"parameters": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/AssistantCreationOptions"
Expand Down Expand Up @@ -217,11 +218,16 @@
"description": "Modifies an existing assistant.",
"parameters": [
{
"$ref": "#/parameters/UpdateAssistantOptions.assistantId"
"name": "assistantId",
"in": "path",
"description": "The ID of the assistant to modify.",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/UpdateAssistantOptions"
Expand Down Expand Up @@ -496,6 +502,7 @@
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/AssistantThreadCreationOptions"
Expand Down Expand Up @@ -539,11 +546,16 @@
"description": "Modifies an existing thread.",
"parameters": [
{
"$ref": "#/parameters/UpdateAssistantThreadOptions.threadId"
"name": "threadId",
"in": "path",
"description": "The ID of the thread to modify.",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/UpdateAssistantThreadOptions"
Expand Down Expand Up @@ -1287,6 +1299,7 @@
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/CreateAndRunThreadOptions"
Expand Down Expand Up @@ -1418,6 +1431,7 @@
{
"name": "body",
"in": "body",
"description": "Body parameter.",
"required": true,
"schema": {
"$ref": "#/definitions/VectorStoreOptions"
Expand Down Expand Up @@ -5172,22 +5186,5 @@
}
}
},
"parameters": {
"UpdateAssistantOptions.assistantId": {
"name": "assistantId",
"in": "path",
"description": "The ID of the assistant to modify.",
"required": true,
"type": "string",
"x-ms-parameter-location": "method"
},
"UpdateAssistantThreadOptions.threadId": {
"name": "threadId",
"in": "path",
"description": "The ID of the thread to modify.",
"required": true,
"type": "string",
"x-ms-parameter-location": "method"
}
}
"parameters": {}
}
Loading

0 comments on commit c286401

Please sign in to comment.