Files
BeWoPlaner/AiCoreUnitTest/OllamaFacadeTest.cs

54 lines
1.2 KiB
C#
Raw Normal View History

using AICore.Facade.LLM;
2026-02-19 14:32:37 +01:00
using BeWo.Data.Security;
2025-12-02 15:40:12 +01:00
using BeWo.Service.Core;
2026-07-24 12:21:11 +02:00
using BS.Shared.Tests.Objects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
2025-12-02 15:40:12 +01:00
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
using System;
using System.Net;
2025-12-02 15:40:12 +01:00
using System.Runtime.InteropServices;
namespace AiCoreUnitTest
{
[TestClass]
public class OllamaFacadeTest
{
public string OllamaUrl { get; set; }
public string OllamaKey { get; set; }
[TestInitialize]
public void TestInitialize()
{
2026-06-29 13:56:01 +02:00
OllamaUrl = "https://ai2.ownsoft.de";
OllamaKey = "mu9ZPuUXJ4aVGLU1WL2RfPCeSMRmJREwyjVJBP7bHfSz8quZRqN7e7UwnwCDi8GZ";
}
public OllamaApiClient GetClient()
=> new OllamaApiClient(OllamaUrl, OllamaKey);
[TestMethod]
public void GetModels()
{
var client = GetClient();
var response = client.GetAiModelle();
Assert.IsTrue(response?.Success);
}
[TestMethod]
public void SendMessage()
{
var client = GetClient();
2026-03-09 13:51:33 +01:00
var logger = ServiceLogger.GetRequestLogger(out string id);
// Build Payload
2026-07-24 12:21:11 +02:00
var payload = AiTestObjects.GetExampleSendRequest(UserRightHelper.GetTenant(), id);
var response = client.SendAiMessageRequest(payload, out LLMResponse llm_response, logger);
Assert.IsTrue(response?.Success);
}
}
}