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
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- master
env:
APP_NAME: Vivet.AI
VERSION: 0.9.0-preview
VERSION: 0.10.0-preview
NUGET_HOST: https://api.nuget.org/v3/index.json
NUGET_APIKEY: ${{ secrets.NUGET_APIKEY }}
jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Vivet.AI.Extensions;
using Vivet.AI.Extensions.Consts;
using Vivet.AI.Hosting.HealthChecks.Extensions;

namespace IntegrationTests.Vivet.AI.Hosting.HealthChecks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Vivet.AI.Extensions;
using Vivet.AI.Extensions.Consts;
using Vivet.AI.Hosting.HealthChecks.Extensions;

namespace IntegrationTests.Vivet.AI.Hosting.HealthChecks;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ImageToText;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Vivet.AI.Extensions.Consts;
using Vivet.AI.Hosting.HealthChecks.Extensions;

namespace IntegrationTests.Vivet.AI.Hosting.HealthChecks;

[TestClass]
public class ImageExtractionModelHealthCheckTests : BaseTests
{
private const string FAKE_IMAGE_EXTRACTION_SERVICE_ID = "FAKE_IMAGE_EXTRACTION_SERVICE";

private HealthCheckService HealthCheckService => this.ServiceProvider.GetRequiredService<HealthCheckService>();

[TestInitialize]
public override void TestSetup()
{
base.TestSetup();

this.services
.AddKeyedSingleton<IImageToTextService>(FAKE_IMAGE_EXTRACTION_SERVICE_ID, new FakeImageToTextService())
.AddKeyedSingleton(FAKE_IMAGE_EXTRACTION_SERVICE_ID, new PromptExecutionSettings())
.AddHealthChecks()
.AddImageExtractionModelCheck(FAKE_IMAGE_EXTRACTION_SERVICE_ID, FAKE_IMAGE_EXTRACTION_SERVICE_ID);
}

[TestMethod]
public async Task CheckHealthWhenIsHealthyTest()
{
var healthReport = await this.HealthCheckService.CheckHealthAsync();

var entry = healthReport.Entries[ServiceIds.VISION_SERVICE_ID];
Assert.AreEqual(HealthStatus.Healthy, entry.Status, entry.Description);
}

[TestMethod]
public async Task CheckHealthkWhenIsUnhealthyTest()
{
var report = await this.HealthCheckService.CheckHealthAsync();
var entry = report.Entries[FAKE_IMAGE_EXTRACTION_SERVICE_ID];

Assert.AreEqual(HealthStatus.Unhealthy, entry.Status);
}


private sealed class FakeImageToTextService : IImageToTextService
{
// ReSharper disable NotNullOrRequiredMemberIsNotInitialized
// ReSharper disable UnassignedGetOnlyAutoProperty
public IReadOnlyDictionary<string, object> Attributes { get; }
// ReSharper restore UnassignedGetOnlyAutoProperty
// ReSharper restore NotNullOrRequiredMemberIsNotInitialized

public Task<IReadOnlyList<TextContent>> GetTextContentsAsync(ImageContent content, PromptExecutionSettings executionSettings = null, Kernel kernel = null, CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.AudioToText;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Vivet.AI.Extensions.Consts;
using Vivet.AI.Hosting.HealthChecks.Extensions;

namespace IntegrationTests.Vivet.AI.Hosting.HealthChecks;

[TestClass]
public class TranscriptionModelHealthCheckTests : BaseTests
{
private const string FAKE_TRANSCRIPTION_SERVICE_ID = "FAKE_TRANSCRIPTION_SERVICE";

private HealthCheckService HealthCheckService => this.ServiceProvider.GetRequiredService<HealthCheckService>();

[TestInitialize]
public override void TestSetup()
{
base.TestSetup();

this.services
.AddKeyedSingleton<IAudioToTextService>(FAKE_TRANSCRIPTION_SERVICE_ID, new FakeAudioToTextService())
.AddKeyedSingleton(FAKE_TRANSCRIPTION_SERVICE_ID, new PromptExecutionSettings())
.AddHealthChecks()
.AddTranscriptionModelCheck(FAKE_TRANSCRIPTION_SERVICE_ID, FAKE_TRANSCRIPTION_SERVICE_ID);
}

[TestMethod]
public async Task CheckHealthWhenIsHealthyTest()
{
var healthReport = await this.HealthCheckService.CheckHealthAsync();

var entry = healthReport.Entries[ServiceIds.TRANSCRIPTION_SERVICE_ID];
Assert.AreEqual(HealthStatus.Healthy, entry.Status, entry.Description);
}

[TestMethod]
public async Task CheckHealthkWhenIsUnhealthyTest()
{
var report = await this.HealthCheckService.CheckHealthAsync();
var entry = report.Entries[FAKE_TRANSCRIPTION_SERVICE_ID];

Assert.AreEqual(HealthStatus.Unhealthy, entry.Status);
}


private sealed class FakeAudioToTextService : IAudioToTextService
{
// ReSharper disable NotNullOrRequiredMemberIsNotInitialized
// ReSharper disable UnassignedGetOnlyAutoProperty
public IReadOnlyDictionary<string, object> Attributes { get; }
// ReSharper restore UnassignedGetOnlyAutoProperty
// ReSharper restore NotNullOrRequiredMemberIsNotInitialized

public Task<IReadOnlyList<TextContent>> GetTextContentsAsync(AudioContent content, PromptExecutionSettings executionSettings = null, Kernel kernel = null, CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
}
}
43 changes: 21 additions & 22 deletions .tests/IntegrationTests.Vivet.AI/Services/AgentsServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading.Tasks;
using Vivet.AI.Services.Interfaces;
Expand All @@ -13,29 +12,29 @@ public class AgentsServiceTests : BaseTests
{
private IAgentsService AgentsService => this.ServiceProvider.GetRequiredService<IAgentsService>();

private sealed class OrderStatusPlugin
{
[KernelFunction]
// ReSharper disable UnusedMember.Local
public string CheckOrderStatus(string orderId) => $"Order {orderId} is shipped and will arrive in 2-3 days.";
// ReSharper restore UnusedMember.Local
}
//private sealed class OrderStatusPlugin
//{
// [KernelFunction]
// // ReSharper disable UnusedMember.Local
// public string CheckOrderStatus(string orderId) => $"Order {orderId} is shipped and will arrive in 2-3 days.";
// // ReSharper restore UnusedMember.Local
//}

private sealed class OrderReturnPlugin
{
[KernelFunction]
// ReSharper disable UnusedMember.Local
public string ProcessReturn(string orderId, string reason) => $"Return for order {orderId} has been processed successfully. {reason}";
// ReSharper restore UnusedMember.Local
}
//private sealed class OrderReturnPlugin
//{
// [KernelFunction]
// // ReSharper disable UnusedMember.Local
// public string ProcessReturn(string orderId, string reason) => $"Return for order {orderId} has been processed successfully. {reason}";
// // ReSharper restore UnusedMember.Local
//}

private sealed class OrderRefundPlugin
{
[KernelFunction]
// ReSharper disable UnusedMember.Local
public string ProcessReturn(string orderId, string reason) => $"Refund for order {orderId} has been processed successfully. {reason}";
// ReSharper restore UnusedMember.Local
}
//private sealed class OrderRefundPlugin
//{
// [KernelFunction]
// // ReSharper disable UnusedMember.Local
// public string ProcessReturn(string orderId, string reason) => $"Refund for order {orderId} has been processed successfully. {reason}";
// // ReSharper restore UnusedMember.Local
//}

[TestMethod]
public async Task InvokeWhenOrchestrationSequentialTest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public async Task ChatWhenBlobsTest()
Question = QUESTION,
Blobs = new List<BaseBlobMetadata>
{
new ImageBlob
new ImageBlobMetadata
{
Data = new BlobDataBase64
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public async Task IndexImageTest()
{
TenantId = this.tenantId,
ScopeId = scopeId,
Blob = new ImageBlob
Blob = new ImageBlobMetadata
{
Data = new BlobDataBase64
{
Expand Down Expand Up @@ -251,7 +251,7 @@ public async Task IndexImageWhenMetadataRetievalTest()
{
TenantId = this.tenantId,
ScopeId = scopeId,
Blob = new ImageBlob
Blob = new ImageBlobMetadata
{
Data = new BlobDataBase64
{
Expand Down Expand Up @@ -837,7 +837,7 @@ public async Task SearchWhenBlobTest()
{
TenantId = this.tenantId,
ScopeId = scopeId,
Blob = new ImageBlob
Blob = new ImageBlobMetadata
{
Data = new BlobDataBase64
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public async Task IndexWhenBlobImageTest()
Language = this.language,
Blobs = new List<BaseBlobMetadata>
{
new ImageBlob
new ImageBlobMetadata
{
Data = new BlobDataBase64
{
Expand Down Expand Up @@ -336,7 +336,7 @@ public async Task IndexWhenBlobImageAndMetadataTest()
Language = this.language,
Blobs = new List<BaseBlobMetadata>
{
new ImageBlob
new ImageBlobMetadata
{
Data = new BlobDataBase64
{
Expand Down Expand Up @@ -390,7 +390,7 @@ public async Task IndexWhenBlobImageAndUseMetadataRetievalIsFalseThrowsAiExcepti
ThreadId = threadId,
Blobs = new List<BaseBlobMetadata>
{
new ImageBlob
new ImageBlobMetadata
{
Data = new BlobDataBase64
{
Expand Down Expand Up @@ -793,7 +793,7 @@ public async Task SearchWhenBlobTest()
Language = this.language,
Blobs = new List<BaseBlobMetadata>
{
new ImageBlob
new ImageBlobMetadata
{
Data = new BlobDataBase64
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Vivet.AI.Services.Interfaces;
using Vivet.AI.Services.Models.Blobs;
using Vivet.AI.Services.Models.Blobs.Data;
using Vivet.AI.Services.Models.MimeTypes;
using Vivet.AI.Services.Requests.Metadata;
using Vivet.AI.Services.Requests.Metadata.Models;

namespace IntegrationTests.Vivet.AI.Services;

Expand Down
142 changes: 142 additions & 0 deletions .tests/IntegrationTests.Vivet.AI/Services/TranscriptionServiceTests.cs

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions .tests/IntegrationTests.Vivet.AI/Services/VisionServiceTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading.Tasks;
using Vivet.AI.Services.Interfaces;
using Vivet.AI.Services.Models.Blobs;
using Vivet.AI.Services.Models.Blobs.Data;
using Vivet.AI.Services.Models.MimeTypes;
using Vivet.AI.Services.Requests.Vision;

namespace IntegrationTests.Vivet.AI.Services;

[TestClass]
public class VisionServiceTests : BaseTests
{
private IVisionService VisionService => this.ServiceProvider.GetRequiredService<IVisionService>();

[TestMethod]
public async Task ExtractTextWhenImageTest()
{
const string BASE_64 = "iVBORw0KGgoAAAANSUhEUgAAALwAAAA4CAYAAABHaJJlAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAUxSURBVHhe7ZuLUSMxEESdAjGQAjkQAjGQAhmQARkQARGQAAmQATlw1Vc1rnafZqy1d42P6Velwl5p9Rm1RiP5bvdtTCN2+sCY34wFb1phwZtWWPCmFRa8aYUFb1phwZtWWPCmFRa8aYUFb1phwZtWWPCmFRa8aYUFb1phwZtWWPCmFRa8acWvF/zd3d33brf7m56eng7y8D3yUM4s5+3tbW/Dm5ub78/PTy1S8vj4uH8fn7fm1ws+jIl0f39/kIfvnG+W8/z8fGDD9/d3LVLCc6DzswWbzvLt7e3U6n19fd2Xg5f4+PjQIidzTYLHuLi9l5cXLbLn4eHhwCaVkHgceO+SWPAEG6IazLlGq6j68NOCz8T59fV1UA5Jw7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PUqjOo7lB9Xc6dXnsVS1sxb/heCBbvlZWuKpKsGDkRfSBG+7JHZnskWlYwB6VRpJ/zkBM2Mz2GC0WLVMxrG5yxYqEjw+L8yqnbX4d5ZXhLfekdcK9L+JZQKCMVGPbukwFCZXjQ24rB7uOEzIDlUQGt7TEABtcphwKrro0F+NdYMlZYORzWBjhFOjhRVUdmNY0Kh31B/0Qa9WsVBgO170eo7Ygk0Fb8y1YcGbVljwphUWvGmFBW9aYcGbVljwphUWvGmFBW9aYcGbVljwphUWvGmFBW9aYcGbVljwphUWvGmFBW9aYcGbVvwB+JN0WaoiXJoAAAAASUVORK5CYII=";
const string EXPECTED = "Hello World";

var response = await this.VisionService
.ExtractText(new ImageTextExtractionRequest
{
Blob = new ImageBlob
{
Data = new BlobDataBase64
{
Base64 = BASE_64
},
MimeType = ImageMimeType.Png
}
});

Assert.IsNotNull(response);

var transcribedText = response.Texts.FirstOrDefault();
Assert.IsNotNull(transcribedText);
Assert.AreEqual(EXPECTED, transcribedText.Content);
Assert.AreEqual("english", transcribedText.Language);
}

[TestMethod]
public async Task ExtractTextWhenDocumentTest()
{
await Task.CompletedTask;

Assert.Inconclusive();
}

[TestMethod]
public async Task ExtractImagesWhenVideoTest()
{
await Task.CompletedTask;

Assert.Inconclusive();
}

[TestMethod]
public async Task ExtractImagesWhenDocumentTest()
{
await Task.CompletedTask;

Assert.Inconclusive();
}
}
Loading
Loading