forked from bterlson/openai-in-typespec
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Experiment #312
Draft
annelo-msft
wants to merge
17
commits into
joseharriaga:main
Choose a base branch
from
annelo-msft:oai-realtime-websocket
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Experiment #312
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ef35471
local SCM csproj
annelo-msft 353530c
notes regarding implementation
annelo-msft f9bdb8b
rename
annelo-msft 29de298
backup of WIP | working toward idea of fitting the subclient to an SC…
annelo-msft 95326ed
exploratory rework of one approach to reshaping the API
annelo-msft 79b91c7
more ideas
annelo-msft 3396b60
comments/questions
annelo-msft effc1d1
add prototype protocol method stubs; make SendCommand internal
annelo-msft 2663c05
move to base SendAsync method
annelo-msft 461f8e0
updates to Azure client
annelo-msft f3b81dd
export API
annelo-msft 9ba287f
API updates
annelo-msft 0495ac2
nit revert
annelo-msft 16669e5
make RO nullable
annelo-msft e9bc3c5
move session configuration to StartConversation method
annelo-msft db8d3dc
updates
annelo-msft f624c96
updates per duplex renaming - just starting on this
annelo-msft 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 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
63 changes: 32 additions & 31 deletions
63
...re.AI.OpenAI/src/Custom/RealtimeConversation/AzureRealtimeConversationSession.Protocol.cs
This file contains 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 |
---|---|---|
@@ -1,44 +1,45 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Azure.Core; | ||
using OpenAI.RealtimeConversation; | ||
using System.ClientModel.Primitives; | ||
using System.ComponentModel; | ||
using System.Net.WebSockets; | ||
using System.ClientModel.Primitives.TwoWayClient; | ||
|
||
namespace Azure.AI.OpenAI.RealtimeConversation; | ||
|
||
internal partial class AzureRealtimeConversationSession : RealtimeConversationSession | ||
internal partial class AzureRealtimeConversation : AssistantConversation | ||
{ | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
protected internal override async Task ConnectAsync(RequestOptions options) | ||
public AzureRealtimeConversation(PipelineResponse response, TwoWayPipelineOptions options) : base(response, options) | ||
{ | ||
ClientUriBuilder uriBuilder = new(); | ||
uriBuilder.Reset(_endpoint); | ||
} | ||
|
||
if (_tokenCredential is not null) | ||
{ | ||
AccessToken token = await _tokenCredential.GetTokenAsync(_tokenRequestContext, options?.CancellationToken ?? default).ConfigureAwait(false); | ||
_clientWebSocket.Options.SetRequestHeader("Authorization", $"Bearer {token.Token}"); | ||
} | ||
else | ||
{ | ||
_keyCredential.Deconstruct(out string dangerousCredential); | ||
_clientWebSocket.Options.SetRequestHeader("api-key", dangerousCredential); | ||
// uriBuilder.AppendQuery("api-key", dangerousCredential, escape: false); | ||
} | ||
//[EditorBrowsable(EditorBrowsableState.Never)] | ||
//internal override async Task ConnectAsync(RequestOptions options) | ||
//{ | ||
// ClientUriBuilder uriBuilder = new(); | ||
// uriBuilder.Reset(_endpoint); | ||
|
||
Uri endpoint = uriBuilder.ToUri(); | ||
// if (_tokenCredential is not null) | ||
// { | ||
// AccessToken token = await _tokenCredential.GetTokenAsync(_tokenRequestContext, options?.CancellationToken ?? default).ConfigureAwait(false); | ||
// _clientWebSocket.Options.SetRequestHeader("Authorization", $"Bearer {token.Token}"); | ||
// } | ||
// else | ||
// { | ||
// _keyCredential.Deconstruct(out string dangerousCredential); | ||
// _clientWebSocket.Options.SetRequestHeader("api-key", dangerousCredential); | ||
// // uriBuilder.AppendQuery("api-key", dangerousCredential, escape: false); | ||
// } | ||
|
||
try | ||
{ | ||
await _clientWebSocket.ConnectAsync(endpoint, options?.CancellationToken ?? default) | ||
.ConfigureAwait(false); | ||
} | ||
catch (WebSocketException) | ||
{ | ||
throw; | ||
} | ||
} | ||
// Uri endpoint = uriBuilder.ToUri(); | ||
|
||
// try | ||
// { | ||
// await _clientWebSocket.ConnectAsync(endpoint, options?.CancellationToken ?? default) | ||
// .ConfigureAwait(false); | ||
// } | ||
// catch (WebSocketException) | ||
// { | ||
// throw; | ||
// } | ||
//} | ||
} |
This file contains 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 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 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 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 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
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.
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.
What does it look like to configure the conversation in a protocol-only world? (When we have munged HTTP and WebSocket messages -- i.e. making two calls on different protocols from the Start method?)