diff --git a/AiCoreUnitTest/AiCoreUnitTest.csproj b/AiCoreUnitTest/AiCoreUnitTest.csproj new file mode 100644 index 000000000..ef40b1a70 --- /dev/null +++ b/AiCoreUnitTest/AiCoreUnitTest.csproj @@ -0,0 +1,89 @@ + + + + + + Debug + AnyCPU + {68C1F8EA-7828-4E46-8F04-91105C55860E} + Library + Properties + AiCoreUnitTest + AiCoreUnitTest + v4.7.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + + + + {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE} + Data + + + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9} + AICore + + + {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF} + Service + + + {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4} + Shared + + + + + + + Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}". + + + + + + \ No newline at end of file diff --git a/AiCoreUnitTest/Ollama2FacadeTest.cs b/AiCoreUnitTest/Ollama2FacadeTest.cs new file mode 100644 index 000000000..c9fb6fe4f --- /dev/null +++ b/AiCoreUnitTest/Ollama2FacadeTest.cs @@ -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 = "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); + } + } +} diff --git a/AiCoreUnitTest/OllamaFacadeTest.cs b/AiCoreUnitTest/OllamaFacadeTest.cs new file mode 100644 index 000000000..7948d1b22 --- /dev/null +++ b/AiCoreUnitTest/OllamaFacadeTest.cs @@ -0,0 +1,62 @@ +using AICore.Facade.LLM; +using BeWo.Data.Security; +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 OllamaFacadeTest + { + public string OllamaUrl { get; set; } + public string OllamaKey { get; set; } + + [TestInitialize] + public void TestInitialize() + { + OllamaUrl = "https://w2.ownchat.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(); + + // Build Payload + var payload = new + { + model = "llama3:latest", + messages = new[] { + new { + role = "user", + message = "Say 'Hi'!" + } + }, + customerid = UserRightHelper.GetTenant() + }; + + var logger = ServiceLogger.GetRequestLogger(); + var response = client.SendAiMessageRequest(payload, out string message, out string model, out int? duration, logger); + + Assert.IsTrue(response?.Success); + } + } +} diff --git a/AiCoreUnitTest/OpenWebUIFacadeTest.cs b/AiCoreUnitTest/OpenWebUIFacadeTest.cs new file mode 100644 index 000000000..e460ea5ca --- /dev/null +++ b/AiCoreUnitTest/OpenWebUIFacadeTest.cs @@ -0,0 +1,56 @@ +using AICore.Facade.LLM; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Net; + +namespace AiCoreUnitTest +{ + //[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"; + // } + + // public OpenWebApiClient GetClient() + // => new OpenWebApiClient(OpenWebUIUrl, OpenWebUIKey); + + // [TestMethod] + // public void GetModels() + // { + // var client = GetClient(); + + // var models = client.GetAiModelle(); + + // Assert.IsNotNull(models); + // } + + // [TestMethod] + // public void SendMessage() + // { + // var client = GetClient(); + + // // 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); + + // Assert.IsTrue(response?.Success); + // } + //} +} diff --git a/AiCoreUnitTest/Properties/AssemblyInfo.cs b/AiCoreUnitTest/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..e6db92c1a --- /dev/null +++ b/AiCoreUnitTest/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("AiCoreUnitTest")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AiCoreUnitTest")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("68c1f8ea-7828-4e46-8f04-91105c55860e")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/AiCoreUnitTest/app.config b/AiCoreUnitTest/app.config new file mode 100644 index 000000000..6afd7c217 --- /dev/null +++ b/AiCoreUnitTest/app.config @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AiCoreUnitTest/packages.config b/AiCoreUnitTest/packages.config new file mode 100644 index 000000000..36cbc3e9e --- /dev/null +++ b/AiCoreUnitTest/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/BeWo.sln b/BeWo.sln index 5896d25d3..6f5aa1aad 100644 --- a/BeWo.sln +++ b/BeWo.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30523.141 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Client", "Client", "{E7543C39-A44C-40C9-82C9-E7FAA2D9A852}" EndProject @@ -601,6 +601,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MalteserJohanniterJohannesh EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dakota", "Dakota\Dakota.csproj", "{47331732-DD96-4075-869F-83AA9F3F9937}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Components", "Components", "{7C7F1E62-B72D-419B-98A5-26A307456638}" + ProjectSection(SolutionItems) = preProject + Server\Components\README.txt = Server\Components\README.txt + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerUtils", "Server\Components\ServerUtils\ServerUtils.csproj", "{EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AICore", "Server\Components\AICore\AICore.csproj", "{69D70CA9-0DF9-419E-BFAF-F4539F129BD9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET @@ -4796,6 +4805,38 @@ Global {47331732-DD96-4075-869F-83AA9F3F9937}.Release|Mixed Platforms.Build.0 = Release|Any CPU {47331732-DD96-4075-869F-83AA9F3F9937}.Release|x86.ActiveCfg = Release|Any CPU {47331732-DD96-4075-869F-83AA9F3F9937}.Release|x86.Build.0 = Release|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Debug|.NET.ActiveCfg = Debug|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Debug|.NET.Build.0 = Debug|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Debug|x86.ActiveCfg = Debug|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Debug|x86.Build.0 = Debug|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Release|.NET.ActiveCfg = Release|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Release|.NET.Build.0 = Release|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Release|Any CPU.Build.0 = Release|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Release|x86.ActiveCfg = Release|Any CPU + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}.Release|x86.Build.0 = Release|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Debug|.NET.ActiveCfg = Debug|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Debug|.NET.Build.0 = Debug|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Debug|x86.ActiveCfg = Debug|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Debug|x86.Build.0 = Debug|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Release|.NET.ActiveCfg = Release|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Release|.NET.Build.0 = Release|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Release|Any CPU.Build.0 = Release|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Release|x86.ActiveCfg = Release|Any CPU + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -5092,6 +5133,9 @@ Global {AD3876F3-40C0-47CF-BA36-687139903F87} = {D8A691C5-146D-4613-86CC-438F02FE9106} {28331CB1-17FD-4B58-A837-E0249CAAC535} = {D8A691C5-146D-4613-86CC-438F02FE9106} {47331732-DD96-4075-869F-83AA9F3F9937} = {FEB0336B-F053-40B6-92DD-7DE56AB9408A} + {7C7F1E62-B72D-419B-98A5-26A307456638} = {FEB0336B-F053-40B6-92DD-7DE56AB9408A} + {EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57} = {7C7F1E62-B72D-419B-98A5-26A307456638} + {69D70CA9-0DF9-419E-BFAF-F4539F129BD9} = {7C7F1E62-B72D-419B-98A5-26A307456638} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {FBE985BB-9F0F-4DBB-8F94-ABC37A803FF9} diff --git a/BeWo/AI/AiChatController.cs b/BeWo/AI/AiChatController.cs deleted file mode 100644 index 437ac29a5..000000000 --- a/BeWo/AI/AiChatController.cs +++ /dev/null @@ -1,46 +0,0 @@ -using BeWo.AI.View; -using BeWo.View; -using BeWo.View.Windows; -using BS.Shared; -using BS.Shared.Translation; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeWo.AI -{ - class AiChatController - { - private static void CreateAiChatWindow(AiChatView view, double height, double width) - { - var beWoWindow = BeWoWindowBuilder.GetBeWoWindow(Translator.Translate("Frage unsere KI"), view, height, width); - - view.CloseButtonClicked += () => beWoWindow.Close(); - - beWoWindow.ShowDialog(); - } - - public static void ShowAiChatViewForServiceRecords(long c2sOid, DateTime start, DateTime end, double height, double width) - { - var ctrl = new AiChatView(); - ctrl.InitServiceRecordQuery(c2sOid, start, end); - CreateAiChatWindow(ctrl, height, width); - } - - public static void ShowAiChatViewForSingleCustomer(long customerOid, double height, double width) - { - var ctrl = new AiChatView(); - ctrl.InitSingleCustomerQuery(customerOid); - CreateAiChatWindow(ctrl, height, width); - } - - public static void ShowAiChatViewForObjects(TableID tableId, double height, double width) - { - var ctrl = new AiChatView(); - ctrl.InitObjectQuery(tableId); - CreateAiChatWindow(ctrl, height, width); - } - } -} diff --git a/BeWo/AI/View/AiChatView.xaml b/BeWo/AI/View/AiChatView.xaml deleted file mode 100644 index f58bfce2b..000000000 --- a/BeWo/AI/View/AiChatView.xaml +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - - - - - - - - - - -