Files
BeWoPlaner/AiCoreUnitTest/OllamaFacadeTest.cs

54 lines
1.2 KiB
C#

using AICore.Facade.LLM;
using BeWo.Data.Security;
using BeWo.Service.Core;
using BS.Shared.Tests.Objects;
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 OllamaFacadeTest
{
public string OllamaUrl { get; set; }
public string OllamaKey { get; set; }
[TestInitialize]
public void TestInitialize()
{
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();
var logger = ServiceLogger.GetRequestLogger(out string id);
// Build Payload
var payload = AiTestObjects.GetExampleSendRequest(UserRightHelper.GetTenant(), id);
var response = client.SendAiMessageRequest(payload, out LLMResponse llm_response, logger);
Assert.IsTrue(response?.Success);
}
}
}