Ollama2 UnitTest
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Ollama2FacadeTest.cs" />
|
||||
<Compile Include="OllamaFacadeTest.cs" />
|
||||
<Compile Include="OpenWebUIFacadeTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
54
AiCoreUnitTest/Ollama2FacadeTest.cs
Normal file
54
AiCoreUnitTest/Ollama2FacadeTest.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using AICore.Facade.LLM;
|
||||
using BeWo.Service.Core;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace AiCoreUnitTest
|
||||
{
|
||||
[TestClass]
|
||||
public class Ollama2FacadeTest
|
||||
{
|
||||
public OllamaApiClient Client { get; set; }
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
var url = "https://ai3.ownsoft.de";
|
||||
var key = "mu9ZPuUXJ4aVGLU1WL2RfPCeSMRmJREwyjVJBP7bHfSz8quZRqN7e7UwnwCDi8GZ";
|
||||
|
||||
Client = new OllamaApiClient(url, key, BS.Shared.AiModelSource.ollama2);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetModels()
|
||||
{
|
||||
var response = Client.GetAiModelle();
|
||||
|
||||
Assert.IsTrue(response?.Success);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessage()
|
||||
{
|
||||
// Build Payload
|
||||
var payload = new
|
||||
{
|
||||
model = "llama3:latest",
|
||||
messages = new[] {
|
||||
new {
|
||||
role = "user",
|
||||
message = "Say 'Hi'!"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var logger = ServiceLogger.GetRequestLogger();
|
||||
var response = Client.SendAiMessageRequest(payload, out string message, out string model, out int? duration, logger);
|
||||
|
||||
Assert.IsTrue(response?.Success);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,52 +5,52 @@ using System.Net;
|
||||
|
||||
namespace AiCoreUnitTest
|
||||
{
|
||||
[TestClass]
|
||||
public class OpenWebUIFacadeTest
|
||||
{
|
||||
public string OpenWebUIUrl { get; set; }
|
||||
public string OpenWebUIKey { get; set; }
|
||||
//[TestClass]
|
||||
//public class OpenWebUIFacadeTest
|
||||
//{
|
||||
// public string OpenWebUIUrl { get; set; }
|
||||
// public string OpenWebUIKey { get; set; }
|
||||
|
||||
[TestInitialize]
|
||||
public void TestInitialize()
|
||||
{
|
||||
OpenWebUIUrl = "https://owui1.ownsoft.de";
|
||||
OpenWebUIKey = "sk-7f5d8c418630448dbe31ab1c7e8b100a";
|
||||
}
|
||||
// [TestInitialize]
|
||||
// public void TestInitialize()
|
||||
// {
|
||||
// OpenWebUIUrl = "https://owui1.ownsoft.de";
|
||||
// OpenWebUIKey = "sk-7f5d8c418630448dbe31ab1c7e8b100a";
|
||||
// }
|
||||
|
||||
public OpenWebApiClient GetClient()
|
||||
=> new OpenWebApiClient(OpenWebUIUrl, OpenWebUIKey);
|
||||
// public OpenWebApiClient GetClient()
|
||||
// => new OpenWebApiClient(OpenWebUIUrl, OpenWebUIKey);
|
||||
|
||||
[TestMethod]
|
||||
public void GetModels()
|
||||
{
|
||||
var client = GetClient();
|
||||
// [TestMethod]
|
||||
// public void GetModels()
|
||||
// {
|
||||
// var client = GetClient();
|
||||
|
||||
var models = client.GetAiModelle();
|
||||
// var models = client.GetAiModelle();
|
||||
|
||||
Assert.IsNotNull(models);
|
||||
}
|
||||
// Assert.IsNotNull(models);
|
||||
// }
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessage()
|
||||
{
|
||||
var client = GetClient();
|
||||
// [TestMethod]
|
||||
// public void SendMessage()
|
||||
// {
|
||||
// var client = GetClient();
|
||||
|
||||
// Build Payload
|
||||
var payload = new
|
||||
{
|
||||
model = "llama3.2:latest",
|
||||
messages = new[] {
|
||||
new {
|
||||
role = "user",
|
||||
content = "Say Hi!"
|
||||
}
|
||||
}
|
||||
};
|
||||
// // Build Payload
|
||||
// var payload = new
|
||||
// {
|
||||
// model = "llama3.2:latest",
|
||||
// messages = new[] {
|
||||
// new {
|
||||
// role = "user",
|
||||
// content = "Say Hi!"
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
var response = client.SendAiMessageRequest(payload, out string message, out string model, out int? duration);
|
||||
// var response = client.SendAiMessageRequest(payload, out string message, out string model, out int? duration);
|
||||
|
||||
Assert.IsTrue(response?.Success);
|
||||
}
|
||||
}
|
||||
// Assert.IsTrue(response?.Success);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user