-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.Net Fix Add Missing OpenAI Connector Choice properties to Metadata (#…
…5655) ## Description Resolves #5289 This pull request includes changes to both the `dotnet/samples/KernelSyntaxExamples/Example43_GetModelResult.cs` and `dotnet/src/Connectors/Connectors.OpenAI/AzureSdk/ClientCore.cs` files. The changes mainly focus on improving the handling of metadata and simplifying the codebase. Changes in `Example43_GetModelResult.cs`: * The method `GetTokenUsageMetadataAsync()` was modified to use implicit type (`var`) instead of explicit type (`Kernel`) when creating a kernel. This change simplifies the code and makes it more readable. * A new method `GetFullModelMetadataAsync()` was added. This method creates a kernel, defines a function, invokes the function through the kernel, and displays the results. This addition expands the functionality of the class. Changes in `ClientCore.cs`: * The method `ClientCore()` was modified to use `GetTextChoiceMetadata()` instead of `GetChoiceMetadata()`. This change improves the handling of metadata. * The method `GetStreamingTextContentsAsync()` was also modified to use `GetTextChoiceMetadata()` instead of `GetChoiceMetadata()`. This change improves the handling of metadata. * The methods `GetTextChoiceMetadata()`, `GetChatChoiceMetadata()`, and `GetResponseMetadata()` were modified to include additional metadata fields. This change improves the amount of information available in the metadata. * The method `AddResponseMessage()` was modified to handle `null` values for `finishReason`. This change improves the robustness of the code. Changes in `AzureOpenAIChatCompletionServiceTests.cs`: * The method `GetStreamingChatMessageContentsWorksCorrectlyAsync()` was modified to use an enumerator instead of a foreach loop. This change simplifies the code and makes it more readable. Changes in `chat_completion_streaming_test_response.txt`: * The test response was modified to include additional data. This change improves the accuracy of the tests.
- Loading branch information
1 parent
4aeeb9e
commit b997dcb
Showing
5 changed files
with
127 additions
and
31 deletions.
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
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
4 changes: 3 additions & 1 deletion
4
...nnectors/Connectors.UnitTests/OpenAI/TestData/chat_completion_streaming_test_response.txt
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,3 +1,5 @@ | ||
data: {"id":"response-id","object":"chat.completion.chunk","created":1704212243,"model":"gpt-4","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":"Test chat streaming response"},"finish_reason":null}]} | ||
data: {"id":"chatcmpl-96fqQVHGjG9Yzs4ZMB1K6nfy2oEoo","object":"chat.completion.chunk","created":1711377846,"model":"gpt-4-0125-preview","system_fingerprint":"fp_a7daf7c51e","choices":[{"index":0,"delta":{"content":"Test chat streaming response"},"logprobs":null,"finish_reason":null}]} | ||
|
||
data: {"id":"chatcmpl-96fqQVHGjG9Yzs4ZMB1K6nfy2oEoo","object":"chat.completion.chunk","created":1711377846,"model":"gpt-4-0125-preview","system_fingerprint":"fp_a7daf7c51e","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} | ||
|
||
data: [DONE] |