From 604185290306326605e7f77b2c2675be69c414d9 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 17 Jul 2024 15:00:17 +0800 Subject: [PATCH] tsp, openai-assistants, refactor BodyParameter (#29749) --- .../OpenAI.Assistants/assistants/routes.tsp | 16 ++++++++-- specification/ai/OpenAI.Assistants/client.tsp | 31 +++++++++++++++++++ .../ai/OpenAI.Assistants/common/models.tsp | 11 ------- .../ai/OpenAI.Assistants/messages/routes.tsp | 2 +- .../ai/OpenAI.Assistants/runs/routes.tsp | 17 ++++++++-- .../ai/OpenAI.Assistants/threads/routes.tsp | 12 +++++-- .../vector_stores/routes.tsp | 14 +++++++-- .../assistants_generated.json | 13 ++++---- .../assistants_generated.json | 17 +++++----- .../assistants_generated.yaml | 13 ++++---- .../assistants_generated.yaml | 17 +++++----- 11 files changed, 115 insertions(+), 48 deletions(-) diff --git a/specification/ai/OpenAI.Assistants/assistants/routes.tsp b/specification/ai/OpenAI.Assistants/assistants/routes.tsp index e8746c12abf6..8c03597f64a0 100644 --- a/specification/ai/OpenAI.Assistants/assistants/routes.tsp +++ b/specification/ai/OpenAI.Assistants/assistants/routes.tsp @@ -20,7 +20,13 @@ namespace Azure.AI.OpenAI.Assistants; @post @added(ServiceApiVersions.v2024_02_15_preview) @route("/assistants") -op createAssistant(...BodyParameter): Assistant; +op createAssistant( + /** + * The request details to use when creating a new assistant. + */ + @bodyRoot + body: AssistantCreationOptions, +): Assistant; /** * Gets a list of assistants that were previously created. @@ -63,7 +69,13 @@ op getAssistant(@path assistantId: string): Assistant; @post @route("/assistants/{assistantId}") @added(ServiceApiVersions.v2024_02_15_preview) -op updateAssistant(...BodyParameter): Assistant; +op updateAssistant( + /** + * The request details to use when modifying an existing assistant. + */ + @bodyRoot + body: UpdateAssistantOptions, +): Assistant; /** * Deletes an assistant. diff --git a/specification/ai/OpenAI.Assistants/client.tsp b/specification/ai/OpenAI.Assistants/client.tsp index 09cbd97e3622..c7d3bf1c8a79 100644 --- a/specification/ai/OpenAI.Assistants/client.tsp +++ b/specification/ai/OpenAI.Assistants/client.tsp @@ -230,4 +230,35 @@ namespace Azure.AI.OpenAI.Assistants { // From https://platform.openai.com/docs/assistants/how-it-works // "Note that deleting an AssistantFile doesn’t delete the original File object, it simply deletes the association // between that File and the Assistant." + + @@clientName(createAssistant::parameters.body, + "assistantCreationOptions", + "java" + ); + @@clientName(updateAssistant::parameters.body, + "updateAssistantOptions", + "java" + ); + @@clientName(createThreadAndRun::parameters.body, + "createAndRunThreadOptions", + "java" + ); + @@clientName(createThread::parameters.body, + "assistantThreadCreationOptions", + "java" + ); + @@clientName(updateThread::parameters.body, + "updateAssistantThreadOptions", + "java" + ); + @@clientName(createVectorStore::parameters.body, + "vectorStoreOptions", + "java" + ); + @@clientName(modifyVectorStore::parameters.body, + "vectorStoreUpdateOptions", + "java" + ); + @@clientName(createRun::parameters.body, "createRunOptions", "java"); + @@clientName(createMessage::parameters.body, "threadMessageOptions", "java"); } diff --git a/specification/ai/OpenAI.Assistants/common/models.tsp b/specification/ai/OpenAI.Assistants/common/models.tsp index 85fb2d648611..5c446a1d1d42 100644 --- a/specification/ai/OpenAI.Assistants/common/models.tsp +++ b/specification/ai/OpenAI.Assistants/common/models.tsp @@ -148,14 +148,3 @@ 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; -}; diff --git a/specification/ai/OpenAI.Assistants/messages/routes.tsp b/specification/ai/OpenAI.Assistants/messages/routes.tsp index 181f50433021..bb8e40cbba3a 100644 --- a/specification/ai/OpenAI.Assistants/messages/routes.tsp +++ b/specification/ai/OpenAI.Assistants/messages/routes.tsp @@ -32,7 +32,7 @@ op createMessage( @path threadId: string, /** A single message within an assistant thread, as provided during that thread's creation for its initial state. */ - ...BodyParameter, + @bodyRoot body: ThreadMessageOptions, ): ThreadMessage; /** diff --git a/specification/ai/OpenAI.Assistants/runs/routes.tsp b/specification/ai/OpenAI.Assistants/runs/routes.tsp index 6d2d3ed7eab8..dfe573ab50f1 100644 --- a/specification/ai/OpenAI.Assistants/runs/routes.tsp +++ b/specification/ai/OpenAI.Assistants/runs/routes.tsp @@ -28,7 +28,14 @@ namespace Azure.AI.OpenAI.Assistants; @route("/threads/{threadId}/runs") @doc("Creates a new run for an assistant thread.") @added(ServiceApiVersions.v2024_02_15_preview) -op createRun(@path threadId: string, ...CreateRunOptions): ThreadRun; +op createRun( + @path threadId: string, + + /** + * The details used when creating a new run of an assistant thread. + */ + @bodyRoot body: CreateRunOptions, +): ThreadRun; /** * Gets a list of runs for a specified thread. @@ -136,4 +143,10 @@ 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(...BodyParameter): ThreadRun; +op createThreadAndRun( + /** + * The details used when creating and immediately running a new assistant thread. + */ + @bodyRoot + body: CreateAndRunThreadOptions, +): ThreadRun; diff --git a/specification/ai/OpenAI.Assistants/threads/routes.tsp b/specification/ai/OpenAI.Assistants/threads/routes.tsp index 2f06aacfb89d..84cb8de0b557 100644 --- a/specification/ai/OpenAI.Assistants/threads/routes.tsp +++ b/specification/ai/OpenAI.Assistants/threads/routes.tsp @@ -21,7 +21,11 @@ namespace Azure.AI.OpenAI.Assistants; @added(ServiceApiVersions.v2024_02_15_preview) @route("/threads") op createThread( - ...BodyParameter, + /** + * The details used to create a new assistant thread. + */ + @bodyRoot + body: AssistantThreadCreationOptions, ): AssistantThread; // list threads? @@ -55,7 +59,11 @@ op getThread(@path threadId: string): AssistantThread; @route("/threads/{threadId}") @added(ServiceApiVersions.v2024_02_15_preview) op updateThread( - ...BodyParameter, + /** + * The details used to update an existing assistant thread. + */ + @bodyRoot + body: UpdateAssistantThreadOptions, ): AssistantThread; /** diff --git a/specification/ai/OpenAI.Assistants/vector_stores/routes.tsp b/specification/ai/OpenAI.Assistants/vector_stores/routes.tsp index 6662d455a6a2..28bd617bcfc0 100644 --- a/specification/ai/OpenAI.Assistants/vector_stores/routes.tsp +++ b/specification/ai/OpenAI.Assistants/vector_stores/routes.tsp @@ -34,7 +34,13 @@ op listVectorStores( @post @route("/vector_stores") @added(ServiceApiVersions.v2024_05_01_preview) -op createVectorStore(...BodyParameter): VectorStore; +op createVectorStore( + /** + * Request object for creating a vector store. + */ + @bodyRoot + body: VectorStoreOptions, +): VectorStore; /** * Returns the vector store object matching the specified ID. @@ -63,7 +69,11 @@ op modifyVectorStore( /** The ID of the vector store to modify. */ @path vectorStoreId: string, - ...BodyParameter, + /** + * Request object for updating a vector store. + */ + @bodyRoot + body: VectorStoreUpdateOptions, ): VectorStore; /** diff --git a/specification/ai/data-plane/OpenAI.Assistants/OpenApiV2/preview/2024-02-15-preview/assistants_generated.json b/specification/ai/data-plane/OpenAI.Assistants/OpenApiV2/preview/2024-02-15-preview/assistants_generated.json index df03da8c2ff9..e0e6a4265818 100644 --- a/specification/ai/data-plane/OpenAI.Assistants/OpenApiV2/preview/2024-02-15-preview/assistants_generated.json +++ b/specification/ai/data-plane/OpenAI.Assistants/OpenApiV2/preview/2024-02-15-preview/assistants_generated.json @@ -179,7 +179,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "The request details to use when creating a new assistant.", "required": true, "schema": { "$ref": "#/definitions/AssistantCreationOptions" @@ -242,7 +242,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "The request details to use when modifying an existing assistant.", "required": true, "schema": { "$ref": "#/definitions/UpdateAssistantOptions" @@ -516,7 +516,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "The details used to create a new assistant thread.", "required": true, "schema": { "$ref": "#/definitions/AssistantThreadCreationOptions" @@ -579,7 +579,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "The details used to update an existing assistant thread.", "required": true, "schema": { "$ref": "#/definitions/UpdateAssistantThreadOptions" @@ -761,7 +761,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "A single message within an assistant thread, as provided during that thread's creation for its initial state.", "required": true, "schema": { "$ref": "#/definitions/ThreadMessageOptions" @@ -1003,6 +1003,7 @@ { "name": "body", "in": "body", + "description": "The details used when creating a new run of an assistant thread.", "required": true, "schema": { "$ref": "#/definitions/CreateRunOptions" @@ -1385,7 +1386,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "The details used when creating and immediately running a new assistant thread.", "required": true, "schema": { "$ref": "#/definitions/CreateAndRunThreadOptions" diff --git a/specification/ai/data-plane/OpenAI.Assistants/OpenApiV2/preview/2024-05-01-preview/assistants_generated.json b/specification/ai/data-plane/OpenAI.Assistants/OpenApiV2/preview/2024-05-01-preview/assistants_generated.json index c574712af773..4865bb16194e 100644 --- a/specification/ai/data-plane/OpenAI.Assistants/OpenApiV2/preview/2024-05-01-preview/assistants_generated.json +++ b/specification/ai/data-plane/OpenAI.Assistants/OpenApiV2/preview/2024-05-01-preview/assistants_generated.json @@ -179,7 +179,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "The request details to use when creating a new assistant.", "required": true, "schema": { "$ref": "#/definitions/AssistantCreationOptions" @@ -242,7 +242,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "The request details to use when modifying an existing assistant.", "required": true, "schema": { "$ref": "#/definitions/UpdateAssistantOptions" @@ -552,7 +552,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "The details used to create a new assistant thread.", "required": true, "schema": { "$ref": "#/definitions/AssistantThreadCreationOptions" @@ -615,7 +615,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "The details used to update an existing assistant thread.", "required": true, "schema": { "$ref": "#/definitions/UpdateAssistantThreadOptions" @@ -804,7 +804,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "A single message within an assistant thread, as provided during that thread's creation for its initial state.", "required": true, "schema": { "$ref": "#/definitions/ThreadMessageOptions" @@ -1046,6 +1046,7 @@ { "name": "body", "in": "body", + "description": "The details used when creating a new run of an assistant thread.", "required": true, "schema": { "$ref": "#/definitions/CreateRunOptions" @@ -1428,7 +1429,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "The details used when creating and immediately running a new assistant thread.", "required": true, "schema": { "$ref": "#/definitions/CreateAndRunThreadOptions" @@ -1570,7 +1571,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "Request object for creating a vector store.", "required": true, "schema": { "$ref": "#/definitions/VectorStoreOptions" @@ -1633,7 +1634,7 @@ { "name": "body", "in": "body", - "description": "Body parameter.", + "description": "Request object for updating a vector store.", "required": true, "schema": { "$ref": "#/definitions/VectorStoreUpdateOptions" diff --git a/specification/ai/data-plane/OpenAI.Assistants/OpenApiV3/2024-02-15-preview/assistants_generated.yaml b/specification/ai/data-plane/OpenAI.Assistants/OpenApiV3/2024-02-15-preview/assistants_generated.yaml index f9a9e7602c4a..a60a83e089b4 100644 --- a/specification/ai/data-plane/OpenAI.Assistants/OpenApiV3/2024-02-15-preview/assistants_generated.yaml +++ b/specification/ai/data-plane/OpenAI.Assistants/OpenApiV3/2024-02-15-preview/assistants_generated.yaml @@ -18,7 +18,7 @@ paths: schema: $ref: '#/components/schemas/Assistant' requestBody: - description: Body parameter. + description: The request details to use when creating a new assistant. required: true content: application/json: @@ -125,7 +125,7 @@ paths: schema: $ref: '#/components/schemas/Assistant' requestBody: - description: Body parameter. + description: The request details to use when modifying an existing assistant. required: true content: application/json: @@ -264,7 +264,7 @@ paths: schema: $ref: '#/components/schemas/AssistantThread' requestBody: - description: Body parameter. + description: The details used to create a new assistant thread. required: true content: application/json: @@ -283,7 +283,7 @@ paths: schema: $ref: '#/components/schemas/ThreadRun' requestBody: - description: Body parameter. + description: The details used when creating and immediately running a new assistant thread. required: true content: application/json: @@ -325,7 +325,7 @@ paths: schema: $ref: '#/components/schemas/AssistantThread' requestBody: - description: Body parameter. + description: The details used to update an existing assistant thread. required: true content: application/json: @@ -367,7 +367,7 @@ paths: schema: $ref: '#/components/schemas/ThreadMessage' requestBody: - description: Body parameter. + description: A single message within an assistant thread, as provided during that thread's creation for its initial state. required: true content: application/json: @@ -523,6 +523,7 @@ paths: schema: $ref: '#/components/schemas/ThreadRun' requestBody: + description: The details used when creating a new run of an assistant thread. required: true content: application/json: diff --git a/specification/ai/data-plane/OpenAI.Assistants/OpenApiV3/2024-05-01-preview/assistants_generated.yaml b/specification/ai/data-plane/OpenAI.Assistants/OpenApiV3/2024-05-01-preview/assistants_generated.yaml index 4a68786a0ff0..f763ef81895c 100644 --- a/specification/ai/data-plane/OpenAI.Assistants/OpenApiV3/2024-05-01-preview/assistants_generated.yaml +++ b/specification/ai/data-plane/OpenAI.Assistants/OpenApiV3/2024-05-01-preview/assistants_generated.yaml @@ -18,7 +18,7 @@ paths: schema: $ref: '#/components/schemas/Assistant' requestBody: - description: Body parameter. + description: The request details to use when creating a new assistant. required: true content: application/json: @@ -125,7 +125,7 @@ paths: schema: $ref: '#/components/schemas/Assistant' requestBody: - description: Body parameter. + description: The request details to use when modifying an existing assistant. required: true content: application/json: @@ -264,7 +264,7 @@ paths: schema: $ref: '#/components/schemas/AssistantThread' requestBody: - description: Body parameter. + description: The details used to create a new assistant thread. required: true content: application/json: @@ -283,7 +283,7 @@ paths: schema: $ref: '#/components/schemas/ThreadRun' requestBody: - description: Body parameter. + description: The details used when creating and immediately running a new assistant thread. required: true content: application/json: @@ -325,7 +325,7 @@ paths: schema: $ref: '#/components/schemas/AssistantThread' requestBody: - description: Body parameter. + description: The details used to update an existing assistant thread. required: true content: application/json: @@ -367,7 +367,7 @@ paths: schema: $ref: '#/components/schemas/ThreadMessage' requestBody: - description: Body parameter. + description: A single message within an assistant thread, as provided during that thread's creation for its initial state. required: true content: application/json: @@ -529,6 +529,7 @@ paths: schema: $ref: '#/components/schemas/ThreadRun' requestBody: + description: The details used when creating a new run of an assistant thread. required: true content: application/json: @@ -917,7 +918,7 @@ paths: schema: $ref: '#/components/schemas/VectorStore' requestBody: - description: Body parameter. + description: Request object for creating a vector store. required: true content: application/json: @@ -959,7 +960,7 @@ paths: schema: $ref: '#/components/schemas/VectorStore' requestBody: - description: Body parameter. + description: Request object for updating a vector store. required: true content: application/json: