Files
BeWoPlaner/Service/Plugins/AiFunctionService.cs

124 lines
3.5 KiB
C#

using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.ServiceProxy;
using BeWo.Service.ServiceUtils;
using BS.Shared;
using BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords;
using DevExpress.DataAccess.Native.Web;
using RestSharp.Validation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AICore.Prompt.SystemPrompts;
using DevExpress.XtraCharts.Native;
using System.IO;
using BS.Shared.Interface;
using System.Text.Json;
using BS.Shared.Core;
using BeWo.Data.Security;
using BS.Shared.Exceptions;
namespace BeWo.Service.Plugins
{
//public class AiFunctionService
//{
// //public AiFunctionDocResponse ExecuteAiFunctionServiceRecordDocumentation(AiFunctionDocRequest request)
// //{
// // // Request valideren
// // ValidateDocRequest(request);
// // // Request auswerten
// // // DB Daten holen
// // // DB Daten prüfen
// // // Anfrage zusammensetzen
// // var prompt_baustein_ref = request.AiPromptbausteinPrompt;
// // var prompt_baustein_ref_oid = prompt_baustein_ref.Oid;
// // var prompt_baustein_ref_ver = prompt_baustein_ref.Version;
// // if (prompt_baustein_ref_oid <= 0)
// // throw new BeWoNotImplementedException();
// // var prompt_baustein = DAOFactory.GenericDAO.LoadByID<AiPromptbausteinPrompt>(prompt_baustein_ref_oid);
// // ServiceLogic.ConcurrencyCheck(prompt_baustein_ref_ver, prompt_baustein);
// // var context = AiFunctionContextLoader.LoadServiceRecordDocumentationContext(request, prompt_baustein.SamplesCount);
// // var configPath = ConfigReader.GetConfigPath(SpecialConfig.CustomFunctionPreSystemPrompt);
// // var factory = new AiFunctionSystemPromptBuilder(configPath);
// // var system_prompt = factory.CreateServiceRecordDocumentationSystemPrompt(context);
// // // Anfrage abschicken
// // var result = getResult(system_prompt, prompt_baustein.Prompt);
// // // Response auswerten
// // // Eigene Response erstellen
// // var response = new AiFunctionDocResponse();
// // response.Result = result;
// // return response;
// //}
// //private string getResult(string system, string user_prompt)
// //{
// // var models = ServiceFacade.Ollama2ApiClient.GetAiModelle();
// // var model = models.Data.FirstOrDefault(x => x.ModelName == "gemma3_12b_max_context:latest");
// // if (model == null)
// // throw new NotImplementedException();
// // if (user_prompt == null)
// // user_prompt = string.Empty;
// // var messages = new List<string>()
// // {
// // system, user_prompt
// // };
// // if(model.Value > -1)
// // {
// // if(!AiUtils.CheckUserAllMessageContextSize(messages, model.ModelName, model.Value, out var error))
// // {
// // throw new BeWoNotImplementedException(error);
// // }
// // }
// // var logger = ServiceLogger.GetRequestLogger(out string id);
// // var payload = new
// // {
// // model = "gemma3_12b_max_context:latest",
// // messages = new[]
// // {
// // new
// // {
// // role = "System",
// // content = system
// // },
// // new
// // {
// // role = "User",
// // content = user_prompt
// // },
// // },
// // customerid = UserRightHelper.GetTenant(),
// // requestid = id
// // };
// // var response = ServiceFacade.Ollama2ApiClient.SendAiMessageRequest(payload, out string message, out string model2, out int? duration, logger);
// // return message;
// //}
// //private void ValidateDocRequest(AiFunctionDocRequest request)
// //{
// // //throw new NotImplementedException();
// //}
//}
}