55 lines
1.2 KiB
C#
55 lines
1.2 KiB
C#
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 = "gemma3:12b",
|
|
messages = new[] {
|
|
new {
|
|
role = "user",
|
|
message = "why is the sky blue?"
|
|
}
|
|
}
|
|
};
|
|
|
|
var logger = ServiceLogger.GetRequestLogger();
|
|
var response = Client.SendAiMessageRequest(payload, out string message, out string model, out int? duration, logger);
|
|
|
|
Assert.IsTrue(response?.Success);
|
|
}
|
|
}
|
|
}
|