Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,6 @@ public void ItAddOrNotOrganizationIdAttributeWhenProvided()
Assert.False(clientCoreWithoutOrgId.Attributes.ContainsKey(ClientCore.OrganizationKey));
}

[Fact]
public void ItThrowsIfModelIdIsNotProvided()
{
// Act & Assert
Assert.Throws<ArgumentException>(() => new ClientCore(" ", "apikey"));
Assert.Throws<ArgumentException>(() => new ClientCore("", "apikey"));
Assert.Throws<ArgumentNullException>(() => new ClientCore(null!));
}

[Fact]
public void ItThrowsWhenNotUsingCustomEndpointAndApiKeyIsNotProvided()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.AudioToText;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Embeddings;
using Microsoft.SemanticKernel.Services;
using Microsoft.SemanticKernel.TextToAudio;
Expand Down Expand Up @@ -132,4 +133,15 @@ public void ItCanAddAudioToTextServiceWithOpenAIClient()
// Assert
Assert.Equal("model", service.Attributes[AIServiceExtensions.ModelIdKey]);
}

[Fact]
public void ItCanAddFileService()
{
// Arrange
var sut = Kernel.CreateBuilder();

// Act
var service = sut.AddOpenAIFiles("key").Build()
.GetRequiredService<OpenAIFileService>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft. All rights reserved.

using Microsoft.SemanticKernel.Connectors.OpenAI;
using Xunit;

namespace SemanticKernel.Connectors.OpenAI.UnitTests.Extensions;

public class OpenAIFileUploadExecutionSettingsTests
{
[Fact]
public void ItCanCreateOpenAIFileUploadExecutionSettings()
{
// Arrange
var fileName = "file.txt";
var purpose = OpenAIFilePurpose.FineTune;

// Act
var settings = new OpenAIFileUploadExecutionSettings(fileName, purpose);

// Assert
Assert.Equal(fileName, settings.FileName);
Assert.Equal(purpose, settings.Purpose);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.AudioToText;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Embeddings;
using Microsoft.SemanticKernel.Services;
using Microsoft.SemanticKernel.TextToAudio;
Expand Down Expand Up @@ -133,4 +134,16 @@ public void ItCanAddAudioToTextServiceWithOpenAIClient()
// Assert
Assert.Equal("model", service.Attributes[AIServiceExtensions.ModelIdKey]);
}

[Fact]
public void ItCanAddFileService()
{
// Arrange
var sut = new ServiceCollection();

// Act
var service = sut.AddOpenAIFiles("key")
.BuildServiceProvider()
.GetRequiredService<OpenAIFileService>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ public void ConstructorWithApiKeyWorksCorrectly(bool includeLoggerFactory)
Assert.Equal("model-id", service.Attributes["ModelId"]);
}

[Fact]
public void ItThrowsIfModelIdIsNotProvided()
{
// Act & Assert
Assert.Throws<ArgumentException>(() => new OpenAIAudioToTextService(" ", "apikey"));
Assert.Throws<ArgumentException>(() => new OpenAIAudioToTextService(" ", openAIClient: new("apikey")));
Assert.Throws<ArgumentException>(() => new OpenAIAudioToTextService("", "apikey"));
Assert.Throws<ArgumentException>(() => new OpenAIAudioToTextService("", openAIClient: new("apikey")));
Assert.Throws<ArgumentNullException>(() => new OpenAIAudioToTextService(null!, "apikey"));
Assert.Throws<ArgumentNullException>(() => new OpenAIAudioToTextService(null!, openAIClient: new("apikey")));
}

[Theory]
[InlineData(true)]
[InlineData(false)]
Expand Down
Loading