-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
OpenAI: TypeSpec representations of new Assistants streaming response models #28555
OpenAI: TypeSpec representations of new Assistants streaming response models #28555
Conversation
Next Steps to MergeNext steps that must be taken to merge this PR:
|
Swagger Generation Artifacts
|
Rule | Message |
---|---|
RestBuild error |
"logUrl":"https://apidrop.visualstudio.com/Content%20CI/_build/results?buildId=431088&view=logs&j=fd490c07-0b22-5182-fac9-6d67fe1e939b", "detail":"Run.ps1 failed with exit code 1 " |
️❌
azure-sdk-for-net-track2 failed [Detail]
❌
Failed in generating from 1694ccef63e08a6f3ddc064a359d9b5293429bd4. SDK Automation 14.0.0command pwsh ./eng/scripts/Automation-Sdk-Init.ps1 ../azure-sdk-for-net_tmp/initInput.json ../azure-sdk-for-net_tmp/initOutput.json command pwsh ./eng/scripts/Invoke-GenerateAndBuildV2.ps1 ../azure-sdk-for-net_tmp/generateInput.json ../azure-sdk-for-net_tmp/generateOutput.json cmderr [Invoke-GenerateAndBuildV2.ps1] GeneratePackage: /mnt/vss/_work/1/s/azure-sdk-for-net/eng/scripts/Invoke-GenerateAndBuildV2.ps1:131 cmderr [Invoke-GenerateAndBuildV2.ps1] Line | cmderr [Invoke-GenerateAndBuildV2.ps1] 131 | GeneratePackage ` cmderr [Invoke-GenerateAndBuildV2.ps1] | ~~~~~~~~~~~~~~~~~ cmderr [Invoke-GenerateAndBuildV2.ps1] | Failed to generate sdk. exit code: False cmderr [Invoke-GenerateAndBuildV2.ps1] Get-ChildItem: /mnt/vss/_work/1/s/azure-sdk-for-net/eng/scripts/automation/GenerateAndBuildLib.ps1:807 cmderr [Invoke-GenerateAndBuildV2.ps1] Line | cmderr [Invoke-GenerateAndBuildV2.ps1] 807 | … rtifacts += Get-ChildItem $artifactsPath -Filter *.nupkg -exclude *.s … cmderr [Invoke-GenerateAndBuildV2.ps1] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cmderr [Invoke-GenerateAndBuildV2.ps1] | Cannot find path cmderr [Invoke-GenerateAndBuildV2.ps1] | '/mnt/vss/_work/1/s/azure-sdk-for-net/artifacts/packages/Debug/' because cmderr [Invoke-GenerateAndBuildV2.ps1] | it does not exist. cmderr [Invoke-GenerateAndBuildV2.ps1] GeneratePackage: /mnt/vss/_work/1/s/azure-sdk-for-net/eng/scripts/Invoke-GenerateAndBuildV2.ps1:131 cmderr [Invoke-GenerateAndBuildV2.ps1] Line | cmderr [Invoke-GenerateAndBuildV2.ps1] 131 | GeneratePackage ` cmderr [Invoke-GenerateAndBuildV2.ps1] | ~~~~~~~~~~~~~~~~~ cmderr [Invoke-GenerateAndBuildV2.ps1] | Failed to generate sdk artifact
❌
Azure.AI.OpenAI.Assistants [Preview SDK Changes]info [Changelog]
️⚠️
azure-sdk-for-java warning [Detail]
⚠️
Warning in generating from 1694ccef63e08a6f3ddc064a359d9b5293429bd4. SDK Automation 14.0.0command ./eng/mgmt/automation/init.sh ../azure-sdk-for-java_tmp/initInput.json ../azure-sdk-for-java_tmp/initOutput.json command ./eng/mgmt/automation/generate.py ../azure-sdk-for-java_tmp/generateInput.json ../azure-sdk-for-java_tmp/generateOutput.json cmderr [generate.py] error: import-not-found - Couldn't resolve import "@azure-tools/typespec-azure-rulesets" @ unknown cmderr [generate.py] error: unknown-rule-set - Rule set "data-plane" is not found in library "@azure-tools/typespec-azure-rulesets" @ unknown
️✔️
azure-ai-openai-assistants [Preview SDK Changes]- pom.xml
- azure-ai-openai-assistants-1.0.0-beta.3-sources.jar
- azure-ai-openai-assistants-1.0.0-beta.3.jar
️❌
azure-sdk-for-js failed [Detail]
❌
Code Generator Failed in generating from 1694ccef63e08a6f3ddc064a359d9b5293429bd4. SDK Automation 14.0.0command sh .scripts/automation_init.sh ../azure-sdk-for-js_tmp/initInput.json ../azure-sdk-for-js_tmp/initOutput.json warn File azure-sdk-for-js_tmp/initOutput.json not found to read command sh .scripts/automation_generate.sh ../azure-sdk-for-js_tmp/generateInput.json ../azure-sdk-for-js_tmp/generateOutput.json cmderr [automation_generate.sh] [ERROR] Command failed: pwsh ./eng/common/scripts/TypeSpec-Project-Process.ps1 /mnt/vss/_work/1/s/azure-rest-api-specs/specification/ai/OpenAI.Assistants 1694ccef63e08a6f3ddc064a359d9b5293429bd4 https://github.com/Azure/azure-rest-api-specs cmderr [automation_generate.sh] [ERROR] Command failed: pwsh ./eng/common/scripts/TypeSpec-Project-Process.ps1 /mnt/vss/_work/1/s/azure-rest-api-specs/specification/ai/OpenAI.Assistants 1694ccef63e08a6f3ddc064a359d9b5293429bd4 https://github.com/Azure/azure-rest-api-specs error Script return with result [failed] code [1] signal [null] cwd [azure-sdk-for-js]: sh .scripts/automation_generate.sh warn Skip package processing as generation is failed
Generated ApiView
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to all the comments, do you think it would be a good idea to have the enums for AssistantsStreamEvent, ThreadStreamEvent, RunStreamEvent, RunStepStreamEvent and MessageStreamEvent represented as enums defined and exposed as private
& usage
for the SDKs to make deserialization a bit more uniform across the generated SDKs?
Edit: confirmed this is not the case from the OpenAI swagger perspective. So please dismiss this comment. I will try to figure out how to best approach this as this seems to be a Java only issue.
the |
* Adding streaming events and modified class visibilities * Represented the alias as a union to align better with the swagger and have a class generated * Adding chunk classes to be included on code emission
A couple more models that I noticed while doing streaming stuff: #28864 |
* Added usage models for run and runStep * Added added annotation * Added warning suppresion for nullable fields
…s://github.com/Azure/azure-rest-api-specs into user/travisw/assistants-streaming-models-draft
} | ||
|
||
/** Thread operation related streaming events */ | ||
union ThreadStreamEvent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this union?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This union
is part of all the unions that constitute the larger union AssistantStreamEvent
that represents all the possible event labels the service can send while streaming.
The spec for OpenAI looks like this:
AssistantStreamEvent:
description: |
Represents an event emitted when streaming a Run.
Each event in a server-sent events stream has an `event` and `data` property:
```
event: thread.created
data: {"id": "thread_123", "object": "thread", ...}
```
We emit events whenever a new object is created, transitions to a new state, or is being
streamed in parts (deltas)...
# removed some stuff here to make this more focused on my point
oneOf:
- $ref: "#/components/schemas/ThreadStreamEvent" # <- each one of these have their own documentation
- $ref: "#/components/schemas/RunStreamEvent"
- $ref: "#/components/schemas/RunStepStreamEvent"
- $ref: "#/components/schemas/MessageStreamEvent"
- $ref: "#/components/schemas/ErrorEvent"
- $ref: "#/components/schemas/DoneEvent"
# removed some stuff here to make this more focused on my point
Each "sub-union" of AssistantStreamEvent
has its own documentation for their variants and values. In a setting like Java, where we are relying on users having to cast to the correct type of message coming from the stream, this documentation provides what I think is important guidance on which type to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. As currently implemented, I'm not sure if the docs for each sub-union provides much clarity, but I could see scenarios where it would.
However, if our code generators/libraries expect you to cast to the constituent union member type here, I think I would have some concerns. Wouldn't it be preferable to "flatten" the union in that case? It feels like the ergonomics of using the generated code would be harder than needed...
… models (Azure#28555) * initial commit for models in support of streaming Assistants calls * merge + pr feedback * [OpenAI] [Assistants] PR feedback (Azure#28786) * Adding streaming events and modified class visibilities * Represented the alias as a union to align better with the swagger and have a class generated * Adding chunk classes to be included on code emission * Update specification/ai/OpenAI.Assistants/streaming/events.tsp * Added usage models for run and runStep (Azure#28864) * Added usage models for run and runStep * Added added annotation * Added warning suppresion for nullable fields * Compiled with new models and unions * back ported everything to a past version. Extracted SubmitToolOutputsOptions model * re-compile * Removed toolresources for now and added warning supressions * Brought up to date the classes related to streaming for AssistantStreamEvent * Making filename mandatory uploadFile operation * Project compilation * Re-formated definitiones according to CI instructions * Added missing documentation * Reverted nullability of fileName * re-compiled * Removed openapi v2 and v3 files generated with the placeholder version * reformating * Maded the stream events public to expose types and docs to users * Made stream events publics * remove single-use options model, merge into route params directly * proactively add 2024-05-01-preview label * Removed 05_01 from service version enum ... for now * Added string type to AssistantStreamEvent * tsp validation check --------- Co-authored-by: Jose Alvarez <[email protected]> Co-authored-by: Jose Alvarez <[email protected]>
Edit by @jpalvarezl:
stream
field forcreateAndRunThread
,runThread
andsubmitToolOutputs
function calls (these need to be appropriately handled by clients to deserialize according to all the events detailed instreaming/events.tsp
->AssistantStreamEvent
(here is the Java implementation for reference)2024-02-15-preview
), which in fact reflects the way this changes were introduced by the backend.