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

.Net: Small improvements in Structured Outputs #9906

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Renamed chat response format helper class
  • Loading branch information
dmytrostruk committed Dec 9, 2024
commit db2273209b27c664e0a337738c06bc98784ad027
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
namespace SemanticKernel.Connectors.OpenAI.UnitTests.Helpers;

/// <summary>
/// Unit tests for <see cref="OpenAIChatResponseFormatHelper"/> class.
/// Unit tests for <see cref="OpenAIChatResponseFormatBuilder"/> class.
/// </summary>
public sealed class OpenAIChatResponseFormatHelperTests
public sealed class OpenAIChatResponseFormatBuilderTests
{
private readonly JsonSerializerOptions _options = new();

public OpenAIChatResponseFormatHelperTests()
public OpenAIChatResponseFormatBuilderTests()
{
this._options.Converters.Add(new BinaryDataJsonConverter());
}
Expand All @@ -33,7 +33,7 @@ public void GetJsonSchemaResponseFormatReturnsChatResponseFormatByDefault(
var jsonElement = jsonDocument.RootElement;

// Act
var chatResponseFormat = OpenAIChatResponseFormatHelper.GetJsonSchemaResponseFormat(jsonElement);
var chatResponseFormat = OpenAIChatResponseFormatBuilder.GetJsonSchemaResponseFormat(jsonElement);
var responseFormat = this.GetResponseFormat(chatResponseFormat);

// Assert
Expand Down Expand Up @@ -79,7 +79,7 @@ public void GetJsonSchemaResponseFormatThrowsExceptionWhenSchemaDoesNotExist()
var jsonElement = jsonDocument.RootElement;

// Act & Assert
Assert.Throws<ArgumentException>(() => OpenAIChatResponseFormatHelper.GetJsonSchemaResponseFormat(jsonElement));
Assert.Throws<ArgumentException>(() => OpenAIChatResponseFormatBuilder.GetJsonSchemaResponseFormat(jsonElement));
}

public static TheoryData<string, string, bool?> ChatResponseFormatJson => new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,10 @@ protected virtual ChatCompletionOptions CreateChatCompletionOptions(
}
}

return OpenAIChatResponseFormatHelper.GetJsonSchemaResponseFormat(formatElement);
return OpenAIChatResponseFormatBuilder.GetJsonSchemaResponseFormat(formatElement);

case Type formatObjectType:
return OpenAIChatResponseFormatHelper.GetJsonSchemaResponseFormat(formatObjectType);
return OpenAIChatResponseFormatBuilder.GetJsonSchemaResponseFormat(formatObjectType);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
namespace Microsoft.SemanticKernel.Connectors.OpenAI;

/// <summary>
/// Helper class to process <see cref="ChatResponseFormat"/> object.
/// Helper class to build <see cref="ChatResponseFormat"/> object.
/// </summary>
internal static class OpenAIChatResponseFormatHelper
internal static class OpenAIChatResponseFormatBuilder
{
/// <summary>
/// <see cref="JsonSchemaMapperConfiguration"/> for JSON schema format for structured outputs.
Expand Down