Skip to content

Commit

Permalink
Renaming FunctionResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerBarreto committed Oct 24, 2023
1 parent 7cc2058 commit 7d48210
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static async Task CompleteChatWithFunctionsAsync(string ask, ChatHistory
}

// Check for function response
OpenAIFunctionResponse? functionResponse = chatResult.GetFunctionResponse();
OpenAIFunctionResponse? functionResponse = chatResult.GetOpenAIFunctionResponse();
if (functionResponse is not null)
{
// Print function response details
Expand Down Expand Up @@ -144,7 +144,7 @@ private static async Task StreamingCompleteChatWithFunctionsAsync(string ask, Ch
}
chatHistory.AddAssistantMessage(chatContent.ToString());

var functionResponse = await chatResult.GetStreamingFunctionResponseAsync();
var functionResponse = await chatResult.GetOpenAIStreamingFunctionResponseAsync();

if (functionResponse is not null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.

using System;
using Microsoft.SemanticKernel.AI.ChatCompletion;

namespace Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk;
Expand All @@ -14,7 +15,18 @@ public static class ChatResultExtensions
/// </summary>
/// <param name="chatResult"></param>
/// <returns>The <see cref="OpenAIFunctionResponse"/>, or null if no function was returned by the model.</returns>
[Obsolete("Obsoleted, please use GetOpenAIFunctionResponse instead")]
public static OpenAIFunctionResponse? GetFunctionResponse(this IChatResult chatResult)
{
return GetOpenAIFunctionResponse(chatResult);
}

/// <summary>
/// Retrieve the resulting function from the chat result.
/// </summary>
/// <param name="chatResult"></param>
/// <returns>The <see cref="OpenAIFunctionResponse"/>, or null if no function was returned by the model.</returns>
public static OpenAIFunctionResponse? GetOpenAIFunctionResponse(this IChatResult chatResult)
{
OpenAIFunctionResponse? functionResponse = null;
var functionCall = chatResult.ModelResult.GetResult<ChatModelResult>().Choice.Message.FunctionCall;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public static class ChatStreamingResultExtensions
/// </summary>
/// <param name="chatStreamingResult">Chat streaming result</param>
/// <returns>The <see cref="OpenAIFunctionResponse"/>, or null if no function was returned by the model.</returns>
public static async Task<OpenAIFunctionResponse?> GetStreamingFunctionResponseAsync(this IChatStreamingResult chatStreamingResult)
public static async Task<OpenAIFunctionResponse?> GetOpenAIStreamingFunctionResponseAsync(this IChatStreamingResult chatStreamingResult)
{
if (chatStreamingResult is not ChatStreamingResult)
{
throw new NotSupportedException($"Chat streaming result is not the {nameof(ChatStreamingResult)} supported type");
throw new NotSupportedException($"Chat streaming result is not OpenAI {nameof(ChatStreamingResult)} supported type");
}

StringBuilder arguments = new();
Expand Down

0 comments on commit 7d48210

Please sign in to comment.