-
Notifications
You must be signed in to change notification settings - Fork 5.9k
OpenAI: TypeSpec project for Assistants #27076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
32b957b
Initial public commit for OpenAI Assistants spec
trrwilson fc8196d
small typo correction for 'interpeter' -- thank you, spellcheck!
trrwilson 5a88a4b
rename list type for generation clarity; recompile
trrwilson 8993b0a
client.tsp: suppress visibility of 'list' methods to facilitate plumb…
trrwilson 42403d5
Client visibility pass for more nested objects
trrwilson 3b2fbbe
include omitted ../data-plane items
trrwilson 7b3bafb
tools pass: model name updates and client.tsp clarification
trrwilson e627e3a
very small update: explicit import inclusion for java diagnosis
trrwilson 3ad11f5
Merge branch 'main' into user/travisw/aoai-assistants
trrwilson 9f0a47d
Update specification/ai/OpenAI.Assistants/runs/routes.tsp
jpalvarezl beec617
Update specification/ai/OpenAI.Assistants/runs/routes.tsp
mssfang 5272126
substantial feedback incorporation, version realignment, removal of i…
trrwilson 84706e6
Merge branch 'main' into user/travisw/aoai-assistants
trrwilson cdb2544
distinct ThreadInitializationMessage model for one-shot thread/message
trrwilson 89a4b1b
Update specification/ai/OpenAI.Assistants/client.tsp
mssfang 015be36
[OpenAI-Assistant] Rename some method and model names. (#27456)
mssfang 873977e
some PR feedback + tsp compile clean
trrwilson a74834e
PR feedback: address needed split of required_action and run_step too…
trrwilson 77935c9
PR feedback: address newer additional_instructions, model refactor an…
trrwilson 18c2435
access/visibility updates (mainly C#); fix optionality of additional_…
trrwilson cacb3dc
move @path parameter into UpdateAssistantOptions model
trrwilson 82d67ea
PR feedback: remove defunct suppression from much older version of de…
trrwilson 780283d
Merge branch 'main' into user/travisw/aoai-assistants
trrwilson 5dca284
merge, PR feedback for v2 core update, regen yaml (no downstream impact)
trrwilson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| **/package.json | ||
| **/package-lock.json | ||
| tsp-output/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| title: OpenAIAssistants | ||
| clear-output-folder: false | ||
| guessResourceKey: true | ||
| isAzureSpec: true | ||
| namespace: azure.openai.assistants |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| import "./models.tsp"; | ||
| import "./routes.tsp"; |
131 changes: 131 additions & 0 deletions
131
specification/ai/OpenAI.Assistants/assistants/models.tsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| import "@typespec/versioning"; | ||
| import "../common/models.tsp"; | ||
| import "../tools/models.tsp"; | ||
|
|
||
| namespace Azure.AI.OpenAI.Assistants; | ||
|
|
||
| using TypeSpec.Versioning; | ||
|
|
||
| @doc("Represents an assistant that can call the model and use tools.") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| model Assistant { | ||
| @doc("The identifier, which can be referenced in API endpoints.") | ||
| id: string; | ||
|
|
||
| @doc("The object type, which is always assistant.") | ||
| object: "assistant"; | ||
|
|
||
| @projectedName("json", "created_at") | ||
| @encode(DateTimeKnownEncoding.unixTimestamp, int32) | ||
| @doc("The Unix timestamp, in seconds, representing when this object was created.") | ||
| createdAt: utcDateTime; | ||
|
|
||
| #suppress "@azure-tools/typespec-azure-core/no-nullable" "explicitly required+nullable in mirrored API" | ||
| @doc("The name of the assistant.") | ||
| name: string | null; | ||
|
|
||
| #suppress "@azure-tools/typespec-azure-core/no-nullable" "explicitly required+nullable in mirrored API" | ||
| @doc("The description of the assistant.") | ||
| description: string | null; | ||
|
|
||
| @doc("The ID of the model to use.") | ||
| `model`: string; | ||
|
|
||
| #suppress "@azure-tools/typespec-azure-core/no-nullable" "explicitly required+nullable in mirrored API" | ||
| @doc("The system instructions for the assistant to use.") | ||
| instructions: string | null; | ||
|
|
||
| @doc("The collection of tools enabled for the assistant.") | ||
| tools: ToolDefinition[]; | ||
|
|
||
| @projectedName("json", "file_ids") | ||
| @doc("A list of attached file IDs, ordered by creation date in ascending order.") | ||
| fileIds: string[]; | ||
|
|
||
| ...OptionalMetadata; | ||
| } | ||
|
|
||
| @doc("The request details to use when creating a new assistant.") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| model AssistantCreationOptions { | ||
| @doc("The ID of the model to use.") | ||
| `model`: string; | ||
|
|
||
| @doc("The name of the new assistant.") | ||
| name?: string; | ||
|
|
||
| @doc("The description of the new assistant.") | ||
| description?: string; | ||
|
|
||
| @doc("The system instructions for the new assistant to use.") | ||
| instructions?: string; | ||
|
|
||
| @doc("The collection of tools to enable for the new assistant.") | ||
| tools?: ToolDefinition[]; | ||
|
|
||
| @projectedName("json", "file_ids") | ||
| @doc("A list of previously uploaded file IDs to attach to the assistant.") | ||
| fileIds?: string[]; | ||
|
trrwilson marked this conversation as resolved.
Outdated
|
||
|
|
||
| ...OptionalMetadata; | ||
| } | ||
|
|
||
| @doc("The request details to use when modifying an existing assistant.") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| model AssistantModificationOptions { | ||
| @doc("The ID of the model to use.") | ||
| `model`?: string; | ||
|
|
||
| @doc("The modified name for the assistant to use.") | ||
| name?: string; | ||
|
|
||
| @doc("The modified description for the assistant to use.") | ||
| description?: string; | ||
|
|
||
| @doc("The modified system instructions for the new assistant to use.") | ||
| instructions?: string; | ||
|
trrwilson marked this conversation as resolved.
Outdated
|
||
|
|
||
| @doc("The modified collection of tools to enable for the assistant.") | ||
| tools?: ToolDefinition[]; | ||
|
|
||
| @projectedName("json", "file_ids") | ||
| @doc("The modified list of previously uploaded fileIDs to attach to the assistant.") | ||
| fileIds?: string[]; | ||
|
|
||
| ...OptionalMetadata; | ||
| } | ||
|
|
||
| #suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "https://github.com/Azure/autorest.csharp/issues/4041" | ||
|
trrwilson marked this conversation as resolved.
Outdated
|
||
| @doc("The status of an assistant deletion operation.") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| model AssistantDeletionStatus extends DeletionStatus { | ||
|
trrwilson marked this conversation as resolved.
Outdated
|
||
| @doc("The object type, which is always 'assistant.deleted'.") | ||
| object: "assistant.deleted"; | ||
| } | ||
|
|
||
| @doc("Information about a file attached to an assistant, as used by tools that can read files.") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| model AssistantFile { | ||
| @doc("The identifier, which can be referenced in API endpoints.") | ||
| id: string; | ||
|
|
||
| @doc("The object type, which is always 'assistant.file'.") | ||
| object: "assistant.file"; | ||
|
|
||
| @projectedName("json", "created_at") | ||
| @encode(DateTimeKnownEncoding.unixTimestamp, int32) | ||
| @doc("The Unix timestamp, in seconds, representing when this object was created.") | ||
| createdAt: utcDateTime; | ||
|
|
||
| @projectedName("json", "assistant_id") | ||
| @doc("The assistant ID that the file is attached to.") | ||
| assistantId: string; | ||
| } | ||
|
|
||
| #suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "https://github.com/Azure/autorest.csharp/issues/4041" | ||
| @doc("The status of an assistant file deletion operation.") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| model AssistantFileDeletionStatus extends DeletionStatus { | ||
|
trrwilson marked this conversation as resolved.
Outdated
|
||
| @doc("The object type, which is always 'assistant.file.deleted'.") | ||
| object: "assistant.file.deleted"; | ||
| } | ||
159 changes: 159 additions & 0 deletions
159
specification/ai/OpenAI.Assistants/assistants/routes.tsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| import "@typespec/rest"; | ||
| import "@typespec/http"; | ||
| import "@typespec/versioning"; | ||
| import "./models.tsp"; | ||
|
|
||
| using TypeSpec.Rest; | ||
| using TypeSpec.Http; | ||
| using TypeSpec.Versioning; | ||
|
|
||
| namespace Azure.AI.OpenAI.Assistants; | ||
|
|
||
| @route("/assistants") | ||
| interface Assistants { | ||
| /** | ||
| * Creates a new assistant. | ||
| * | ||
| * @returns The new assistant instance. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "not yet an Azure operation" | ||
| #suppress "@azure-tools/typespec-azure-core/no-operation-id" "non-standard operations" | ||
| #suppress "@azure-tools/typespec-azure-core/operation-missing-api-version" "not yet versioned" | ||
| @post | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| createAssistant(...AssistantCreationOptions): Assistant; | ||
|
|
||
| /** | ||
| * Gets a list of assistants that were previously created. | ||
| * | ||
| * @returns The requested list of assistants. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-names" "mirrored API responds with a container" | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "not yet an Azure operation" | ||
| #suppress "@azure-tools/typespec-azure-core/no-operation-id" "non-standard operations" | ||
| #suppress "@azure-tools/typespec-azure-core/operation-missing-api-version" "not yet versioned" | ||
| @get | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| listAssistants(...OpenAIListRequestOptions): OpenAIPageableListOf<Assistant>; | ||
|
|
||
| /** | ||
| * Retrieves an existing assistant. | ||
| * | ||
| * @param assistantId The ID of the assistant to retrieve. | ||
| * @returns The requested assistant instance. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "not yet an Azure operation" | ||
| #suppress "@azure-tools/typespec-azure-core/no-operation-id" "non-standard operations" | ||
| #suppress "@azure-tools/typespec-azure-core/operation-missing-api-version" "not yet versioned" | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-names" "mirrored API name parity" | ||
| @get | ||
| @route("{assistantId}") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| retrieveAssistant(@path assistantId: string): Assistant; | ||
|
trrwilson marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * Modifies an existing assistant. | ||
| * | ||
| * @param assistantId The ID of the assistant to modify. | ||
| * @param modificationOptions The details of the modification to perform on the specified assistant. | ||
| * @returns The updated assistant instance. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "not yet an Azure operation" | ||
| #suppress "@azure-tools/typespec-azure-core/no-operation-id" "non-standard operations" | ||
| #suppress "@azure-tools/typespec-azure-core/operation-missing-api-version" "not yet versioned" | ||
| @post | ||
|
trrwilson marked this conversation as resolved.
Outdated
|
||
| @route("{assistantId}") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| modifyAssistant( | ||
| @path assistantId: string, | ||
| @body modificationOptions: AssistantModificationOptions, | ||
| ): Assistant; | ||
|
|
||
| /** | ||
| * Deletes an assistant. | ||
| * | ||
| * @param assistantId The ID of the assistant to delete. | ||
| * @returns Status information about the requested deletion operation. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "not yet an Azure operation" | ||
| #suppress "@azure-tools/typespec-azure-core/no-operation-id" "non-standard operations" | ||
| #suppress "@azure-tools/typespec-azure-core/operation-missing-api-version" "not yet versioned" | ||
| @delete | ||
| @route("{assistantId}") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| deleteAssistant(@path assistantId: string): AssistantDeletionStatus; | ||
|
|
||
| /** | ||
| * Attaches a previously uploaded file to an assistant for use by tools that can read files. | ||
| * | ||
| * @param assistantId The ID of the assistant to attach the file to. | ||
| * @param fileId The ID of the previously uploaded file to attach. | ||
| * @returns Information about the attached file. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "not yet an Azure operation" | ||
| #suppress "@azure-tools/typespec-azure-core/no-operation-id" "non-standard operations" | ||
| #suppress "@azure-tools/typespec-azure-core/operation-missing-api-version" "not yet versioned" | ||
| @post | ||
| @route("{assistantId}/files") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| createAssistantFile( | ||
| @path assistantId: string, | ||
| @projectedName("json", "file_id") fileId: string, | ||
|
trrwilson marked this conversation as resolved.
Outdated
|
||
| ): AssistantFile; | ||
|
|
||
| /** | ||
| * Gets a list of files attached to a specific assistant, as used by tools that can read files. | ||
| * | ||
| * @param assistantId The ID of the assistant to retrieve the list of attached files for. | ||
| * @returns The requested list of files attached to the specified assistant. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-names" "mirrored API responds with a container" | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "not yet an Azure operation" | ||
| #suppress "@azure-tools/typespec-azure-core/no-operation-id" "non-standard operations" | ||
| #suppress "@azure-tools/typespec-azure-core/operation-missing-api-version" "not yet versioned" | ||
| @get | ||
| @route("{assistantId}/files") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| listAssistantFiles( | ||
| @path assistantId: string, | ||
| ...OpenAIListRequestOptions, | ||
| ): OpenAIPageableListOf<AssistantFile>; | ||
|
|
||
| /** | ||
| * Retrieves a file attached to an assistant. | ||
| * | ||
| * @param assistantId The ID of the assistant associated with the attached file. | ||
| * @param fileId The ID of the file to retrieve. | ||
| * @returns A representation of the attached file. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "not yet an Azure operation" | ||
| #suppress "@azure-tools/typespec-azure-core/no-operation-id" "non-standard operations" | ||
| #suppress "@azure-tools/typespec-azure-core/operation-missing-api-version" "not yet versioned" | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-names" "mirrored API name parity" | ||
| @get | ||
| @route("{assistantId}/files/{fileId}") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| retrieveAssistantFile( | ||
|
trrwilson marked this conversation as resolved.
Outdated
|
||
| @path assistantId: string, | ||
| @path fileId: string, | ||
| ): AssistantFile; | ||
|
|
||
| /** | ||
| * Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read | ||
| * files. | ||
| * | ||
| * @param assistantId The ID of the assistant from which the specified file should be unlinked. | ||
| * @param fileId The ID of the file to unlink from the specified assistant. | ||
| * @returns Status information about the requested file association deletion. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "not yet an Azure operation" | ||
| #suppress "@azure-tools/typespec-azure-core/no-operation-id" "non-standard operations" | ||
| #suppress "@azure-tools/typespec-azure-core/operation-missing-api-version" "not yet versioned" | ||
| @delete | ||
| @route("{assistantId}/files/{fileId}") | ||
| @added(ServiceApiVersions.v2023_11_06_beta) | ||
| deleteAssistantFile( | ||
| @path assistantId: string, | ||
| @path fileId: string, | ||
| ): AssistantFileDeletionStatus; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.