Skip to content
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

Merged
merged 48 commits into from
May 24, 2024

Conversation

trrwilson
Copy link
Member

@trrwilson trrwilson commented Apr 2, 2024

Edit by @jpalvarezl:

  • Introducing pre-Assistants v2 changes allowing the usage of streaming functionality.
  • Included stream field for createAndRunThread , runThread and submitToolOutputs function calls (these need to be appropriately handled by clients to deserialize according to all the events detailed in streaming/events.tsp -> AssistantStreamEvent (here is the Java implementation for reference)
  • These changes won't be released on their own; they are part of an incremental effort to bring the (more extensive) changes introduced byAssistants v2.
  • All the new changes are backported to the initial version release (2024-02-15-preview), which in fact reflects the way this changes were introduced by the backend.

Copy link

openapi-pipeline-app bot commented Apr 2, 2024

Next Steps to Merge

Next steps that must be taken to merge this PR:
  • ❌ This PR has at least one breaking change (label: BreakingChangeReviewRequired).
    To unblock this PR, follow the process at aka.ms/brch.
  • ❌ The required check named Swagger ModelValidation has failed. Refer to the check in the PR's 'Checks' tab for details on how to fix it

Copy link

openapi-pipeline-app bot commented Apr 2, 2024

Swagger Validation Report

️❌BreakingChange: 26 Errors, 0 Warnings failed [Detail]
Compared specs (v0.10.9) new version base version
assistants_generated.json 2024-02-15-preview(31fb77c) 2024-02-15-preview(main)
Rule Message
1025 - RequiredStatusChange The 'required' status changed from the old version('True') to the new version('False').
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L2485:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L2387:7
1025 - RequiredStatusChange The 'required' status changed from the old version('True') to the new version('False').
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L2536:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L2426:7
1033 - RemovedProperty The new version is missing a property found in the old version. Was 'start_index' renamed or removed?
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L2425:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L2313:7
1033 - RemovedProperty The new version is missing a property found in the old version. Was 'end_index' renamed or removed?
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L2425:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L2313:7
1034 - AddedRequiredProperty The new version has new required property 'status' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3445:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3255:7
1034 - AddedRequiredProperty The new version has new required property 'incomplete_details' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3445:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3255:7
1034 - AddedRequiredProperty The new version has new required property 'completed_at' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3445:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3255:7
1034 - AddedRequiredProperty The new version has new required property 'incomplete_at' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3445:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3255:7
1034 - AddedRequiredProperty The new version has new required property 'status, incomplete_details, completed_at, incomplete_at' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L859:19
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L859:19
1034 - AddedRequiredProperty The new version has new required property 'status, incomplete_details, completed_at, incomplete_at' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L943:13
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L943:13
1034 - AddedRequiredProperty The new version has new required property 'status, incomplete_details, completed_at, incomplete_at' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L973:13
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L973:13
1034 - AddedRequiredProperty The new version has new required property 'status, incomplete_details, completed_at, incomplete_at' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1019:13
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1019:13
1034 - AddedRequiredProperty The new version has new required property 'incomplete_details' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3552:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3334:7
1034 - AddedRequiredProperty The new version has new required property 'usage' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3552:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3334:7
1034 - AddedRequiredProperty The new version has new required property 'incomplete_details, usage' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1270:19
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1270:19
1034 - AddedRequiredProperty The new version has new required property 'incomplete_details, usage' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1325:13
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1325:13
1034 - AddedRequiredProperty The new version has new required property 'incomplete_details, usage' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1355:13
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1355:13
1034 - AddedRequiredProperty The new version has new required property 'incomplete_details, usage' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1401:13
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1401:13
1034 - AddedRequiredProperty The new version has new required property 'incomplete_details, usage' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1431:13
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1431:13
1034 - AddedRequiredProperty The new version has new required property 'incomplete_details, usage' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1648:13
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1643:13
1034 - AddedRequiredProperty The new version has new required property 'incomplete_details, usage' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1672:13
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1667:13
1034 - AddedRequiredProperty The new version has new required property 'status, incomplete_details, completed_at, incomplete_at' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3442:5
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3252:5
1034 - AddedRequiredProperty The new version has new required property 'incomplete_details, usage' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3549:5
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3331:5
1041 - AddedPropertyInResponse The new version has a new property 'usage' in response that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L2816:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L2665:7
1045 - AddedOptionalProperty The new version has a new optional property 'stream' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1988:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1983:7
1045 - AddedOptionalProperty The new version has a new optional property 'stream' that was not found in the old version.
New: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L2037:7
Old: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L2025:7
️️✔️Breaking Change(Cross-Version) succeeded [Detail] [Expand]
There are no breaking changes.
️️✔️CredScan succeeded [Detail] [Expand]
There is no credential detected.
️️✔️LintDiff succeeded [Detail] [Expand]
Validation passes for LintDiff.
️❌Avocado: 2 Errors, 0 Warnings failed [Detail]
Rule Message
MISSING_README Can not find readme.md in the folder. If no readme.md file, it will block SDK generation.
folder: OpenAI.Assistants/OpenApiV2/preview/2024-02-15-preview
MISSING_README Can not find readme.md in the folder. If no readme.md file, it will block SDK generation.
folder: data-plane/OpenAI.Assistants/OpenApiV3/2024-02-15-preview
️❌SwaggerAPIView: 1 Errors, 0 Warnings failed [Detail]
Rule Message
Failed to generate swagger APIView. The readme file format is invalid and the tag is not defined. Use the provided readme template for guidance readme template. For more details, please check the detail log. "How to fix":"Check the readme file and make sure the readme file format is valid and the tag is defined. Use the provided readme template"
️️✔️TypeSpecAPIView succeeded [Detail] [Expand]
️❌ModelValidation: 33 Errors, 0 Warnings failed [Detail]

Only 30 items are listed, please refer to log for more details.

Rule Message
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in ListAssistants.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L63:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in CreateAssistant.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L170:15
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in GetAssistant.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L194:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in UpdateAssistant.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L215:15
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in DeleteAssistant.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L240:17
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in ListAssistantFiles.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L263:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in CreateAssistantFile.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L377:15
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in GetAssistantFile.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L418:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in DeleteAssistantFile.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L446:17
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in ListFiles.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L476:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in UploadFile.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L529:15
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in GetFile.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L601:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in DeleteFile.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L622:17
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in GetFileContent.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L645:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in CreateThread.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L669:15
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in GetThread.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L693:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in UpdateThread.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L714:15
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in DeleteThread.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L753:17
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in ListMessages.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L776:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in CreateMessage.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L890:15
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in GetMessage.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L951:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in UpdateMessage.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L979:15
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in ListMessageFiles.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1027:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in GetMessageFile.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1150:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in ListRuns.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1187:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in CreateRun.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1301:15
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in GetRun.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1333:14
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in UpdateRun.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1361:15
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in CancelRun.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1409:15
XMS_EXAMPLE_NOTFOUND_ERROR x-ms-example not found in ListRunSteps.
Url: OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L1439:14
️️✔️SemanticValidation succeeded [Detail] [Expand]
Validation passes for SemanticValidation.
️️✔️PoliCheck succeeded [Detail] [Expand]
Validation passed for PoliCheck.
️️✔️SpellCheck succeeded [Detail] [Expand]
Validation passes for SpellCheck.
️️✔️Lint(RPaaS) succeeded [Detail] [Expand]
Validation passes for Lint(RPaaS).
️️✔️PR Summary succeeded [Detail] [Expand]
Validation passes for Summary.
️️✔️Automated merging requirements met succeeded [Detail] [Expand]
Posted by Swagger Pipeline | How to fix these errors?

Copy link

openapi-pipeline-app bot commented Apr 2, 2024

Swagger Generation Artifacts

️❌ApiDocPreview: 1 Errors, 0 Warnings failed [Detail]
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 1694cce. SDK Automation 14.0.0
    command	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 1694cce. SDK Automation 14.0.0
    command	./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 1694cce. SDK Automation 14.0.0
    command	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
Posted by Swagger Pipeline | How to fix these errors?

Copy link

openapi-pipeline-app bot commented Apr 2, 2024

Copy link
Member

@jpalvarezl jpalvarezl left a 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?

specification/ai/OpenAI.Assistants/runs/routes.tsp Outdated Show resolved Hide resolved
specification/ai/OpenAI.Assistants/messages/models.tsp Outdated Show resolved Hide resolved
specification/ai/OpenAI.Assistants/messages/models.tsp Outdated Show resolved Hide resolved
specification/ai/OpenAI.Assistants/run_steps/models.tsp Outdated Show resolved Hide resolved
specification/ai/OpenAI.Assistants/run_steps/models.tsp Outdated Show resolved Hide resolved
specification/ai/OpenAI.Assistants/run_steps/models.tsp Outdated Show resolved Hide resolved
@jpalvarezl
Copy link
Member

jpalvarezl commented Apr 23, 2024

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.

There is an API breaking-ish change that we may want to address in this PR. For the uploadFile operation:

@post
@added(ServiceApiVersions.v2024_02_15_preview)
@route("/files")
op uploadFile(
  @header contentType: "multipart/form-data",
  @clientName("Data", "csharp") file: bytes,
  purpose: FilePurpose,

  /*
   * Spec note: filename is not documented as a distinct option but functionally should be one. The value is encoded
   *            in the multipart Content-Disposition header for the data section and can be provided independently of
   *            any specific data source like a file. It can be inferred in some circumstances (as when using direct
   *            file input, like curl does) but should remain configurable when using a stream or other data source
   *            lacking an a priori name.
   */
  filename: string,
): OpenAIFile;

the filename has actually turned into mandatory 🤔

* 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
@jpalvarezl
Copy link
Member

A couple more models that I noticed while doing streaming stuff: #28864

}

/** Thread operation related streaming events */
union ThreadStreamEvent {
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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...

@lmazuel lmazuel merged commit 1bf1fa2 into main May 24, 2024
23 of 32 checks passed
@lmazuel lmazuel deleted the user/travisw/assistants-streaming-models-draft branch May 24, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BreakingChangeReviewRequired <valid label in PR review process>add this label when breaking change review is required data-plane TypeSpec Authored with TypeSpec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants