forked from bterlson/openai-in-typespec
-
Notifications
You must be signed in to change notification settings - Fork 14
Azure OpenAI compilation fixes (post pagination improvements) #190
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 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f1079bf
first pass; compiles but doesn't address new pagination convenience m…
trrwilson 97dd4d7
first change to base library convenience
trrwilson 20d28c4
Merge branch 'main' into user/travisw/aoai-compilation-fixes
trrwilson 18af1a7
fully apply pagination cast pattern; tests pass! also remove browser …
trrwilson 3cf1f30
remove unused file
trrwilson 2415226
Merge branch 'main' into user/travisw/aoai-compilation-fixes
trrwilson 5aac44f
move types to /internal/pagination parallel
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
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
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
46 changes: 46 additions & 0 deletions
46
.dotnet.azure/src/Custom/Assistants/AzureAssistantsPageEnumerator.cs
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,46 @@ | ||
| using System.ClientModel; | ||
| using System.ClientModel.Primitives; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Azure.AI.OpenAI.Assistants; | ||
|
|
||
| internal partial class AzureAssistantsPageEnumerator : AssistantsPageEnumerator | ||
| { | ||
| private readonly Uri _endpoint; | ||
| private readonly string _apiVersion; | ||
|
|
||
| public AzureAssistantsPageEnumerator( | ||
| ClientPipeline pipeline, | ||
| Uri endpoint, | ||
| int? limit, string order, string after, string before, | ||
| string apiVersion, | ||
| RequestOptions options) | ||
| : base(pipeline, endpoint, limit, order, after, before, options) | ||
| { | ||
| _endpoint = endpoint; | ||
| _apiVersion = apiVersion; | ||
| } | ||
|
|
||
| internal override async Task<ClientResult> GetAssistantsAsync(int? limit, string order, string after, string before, RequestOptions options) | ||
| { | ||
| using PipelineMessage message = CreateGetAssistantsRequest(limit, order, after, before, options); | ||
| return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); | ||
| } | ||
|
|
||
| internal override ClientResult GetAssistants(int? limit, string order, string after, string before, RequestOptions options) | ||
| { | ||
| using PipelineMessage message = CreateGetAssistantsRequest(limit, order, after, before, options); | ||
| return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); | ||
| } | ||
|
|
||
| private new PipelineMessage CreateGetAssistantsRequest(int? limit, string order, string after, string before, RequestOptions options) | ||
| => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) | ||
| .WithAssistantsHeader() | ||
| .WithOptions(options) | ||
| .WithMethod("GET") | ||
| .WithAccept("application/json") | ||
| .WithCommonListParameters(limit, order, after, before) | ||
| .WithPath("assistants") | ||
| .Build(); | ||
| } | ||
51 changes: 51 additions & 0 deletions
51
.dotnet.azure/src/Custom/Assistants/AzureMessagesPageEnumerator.cs
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,51 @@ | ||
| using System.ClientModel; | ||
| using System.ClientModel.Primitives; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Azure.AI.OpenAI.Assistants; | ||
|
|
||
| internal partial class AzureMessagesPageEnumerator : MessagesPageEnumerator | ||
|
trrwilson marked this conversation as resolved.
|
||
| { | ||
| private readonly Uri _endpoint; | ||
| private readonly string _apiVersion; | ||
|
|
||
| public AzureMessagesPageEnumerator( | ||
| ClientPipeline pipeline, | ||
| Uri endpoint, | ||
| string threadId, | ||
| int? limit, string order, string after, string before, | ||
| string apiVersion, | ||
| RequestOptions options) | ||
| : base(pipeline, endpoint, threadId, limit, order, after, before, options) | ||
| { | ||
| _endpoint = endpoint; | ||
| _apiVersion = apiVersion; | ||
| } | ||
|
|
||
| internal override async Task<ClientResult> GetMessagesAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options) | ||
| { | ||
| Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); | ||
|
|
||
| using PipelineMessage message = CreateGetMessagesRequest(threadId, limit, order, after, before, options); | ||
| return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); | ||
| } | ||
|
|
||
| internal override ClientResult GetMessages(string threadId, int? limit, string order, string after, string before, RequestOptions options) | ||
| { | ||
| Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); | ||
|
|
||
| using PipelineMessage message = CreateGetMessagesRequest(threadId, limit, order, after, before, options); | ||
| return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); | ||
| } | ||
|
|
||
| private PipelineMessage CreateGetMessagesRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) | ||
| => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) | ||
| .WithAssistantsHeader() | ||
| .WithOptions(options) | ||
| .WithMethod("GET") | ||
| .WithAccept("application/json") | ||
| .WithCommonListParameters(limit, order, after, before) | ||
| .WithPath("threads", threadId, "messages") | ||
| .Build(); | ||
| } | ||
53 changes: 53 additions & 0 deletions
53
.dotnet.azure/src/Custom/Assistants/AzureRunStepsPageEnumerator.cs
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,53 @@ | ||
| using System.ClientModel; | ||
| using System.ClientModel.Primitives; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Azure.AI.OpenAI.Assistants; | ||
|
|
||
| internal partial class AzureRunStepsPageEnumerator : RunStepsPageEnumerator | ||
| { | ||
| private readonly Uri _endpoint; | ||
| private readonly string _apiVersion; | ||
|
|
||
| public AzureRunStepsPageEnumerator( | ||
| ClientPipeline pipeline, | ||
| Uri endpoint, | ||
| string threadId, string runId, | ||
| int? limit, string? order, string? after, string? before, | ||
| string apiVersion, | ||
| RequestOptions options) | ||
| : base(pipeline, endpoint, threadId, runId, limit, order, after, before, options) | ||
| { | ||
| _endpoint = endpoint; | ||
| _apiVersion = apiVersion; | ||
| } | ||
|
|
||
| internal override async Task<ClientResult> GetRunStepsAsync(string threadId, string runId, int? limit, string? order, string? after, string? before, RequestOptions? options) | ||
| { | ||
| Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); | ||
| Argument.AssertNotNullOrEmpty(runId, nameof(runId)); | ||
|
|
||
| using PipelineMessage message = CreateGetRunStepsRequest(threadId, runId, limit, order, after, before, options); | ||
| return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); | ||
| } | ||
|
|
||
| internal override ClientResult GetRunSteps(string threadId, string runId, int? limit, string? order, string? after, string? before, RequestOptions? options) | ||
| { | ||
| Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); | ||
| Argument.AssertNotNullOrEmpty(runId, nameof(runId)); | ||
|
|
||
| using PipelineMessage message = CreateGetRunStepsRequest(threadId, runId, limit, order, after, before, options); | ||
| return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); | ||
| } | ||
|
|
||
| private PipelineMessage CreateGetRunStepsRequest(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) | ||
| => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) | ||
| .WithAssistantsHeader() | ||
| .WithOptions(options) | ||
| .WithMethod("GET") | ||
| .WithAccept("application/json") | ||
| .WithCommonListParameters(limit, order, after, before) | ||
| .WithPath("threads", threadId, "runs", runId, "steps") | ||
| .Build(); | ||
| } |
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.