Files
BeWoPlaner/AiCoreUnitTest/Ollama2FacadeTest.cs
2025-12-03 11:06:45 +01:00

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 = "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);
}
}
}