123 lines
2.9 KiB
C#
123 lines
2.9 KiB
C#
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.ServiceContracts;
|
|
using BeWo.Service.ServiceProxy;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.MikePHPContracts;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.ServiceModel;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BeWo.Service.ServiceImplementations
|
|
{
|
|
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
|
|
public class OperationsEnhancedServiceImp : IOperationsEnhancedService
|
|
{
|
|
public object Method1(object input, object input2)
|
|
{
|
|
if (input is int i)
|
|
{
|
|
if (i == 1)
|
|
{
|
|
return new AiSettingDC();
|
|
}
|
|
if (i == 2)
|
|
{
|
|
return new List<AiConversationDC>();
|
|
}
|
|
if (i == 3)
|
|
{
|
|
return ServiceFacade.MikePHPScriptFacade.GetAiModelle();
|
|
}
|
|
}
|
|
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public object Method2(object input, object input2)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public object Method3(object input, object input2)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public object Method4(object input, object input2)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public List<AiModelDC> GetAiModels()
|
|
{
|
|
return ServiceFacade.MikePHPScriptFacade.GetAiModelle();
|
|
}
|
|
|
|
public AiConversationMessageDC SendNewMessage(AiConversationDC conversation, string context, string input)
|
|
{
|
|
var model = conversation.Modell;
|
|
|
|
var dc = new AiConversationMessageDC();
|
|
|
|
dc.Prompt = input;
|
|
dc.Model = model;
|
|
dc.TimeStamp = DateTime.Now;
|
|
|
|
var result = ServiceFacade.MikePHPScriptFacade.SendAiRequestComplex(dc);
|
|
|
|
var test = result.GetResponseData();
|
|
|
|
var req = new AiMessageRequest2();
|
|
|
|
req.ApiData = new List<AiMessageRequestData>();
|
|
|
|
foreach (var endpoint in test.Endpoints) {
|
|
if (string.IsNullOrEmpty(endpoint))
|
|
continue;
|
|
|
|
List<string> data = new List<string>();
|
|
if(endpoint == "get_klienten")
|
|
{
|
|
var dat = new CustomerServiceImp().GetAllCompactCustomers();
|
|
data = dat.Select(JsonConvert.SerializeObject).ToList();
|
|
}
|
|
else if (endpoint == "get_mitarbeiter")
|
|
{
|
|
var dat = new EmployeeServiceImp().GetAllCompactEmployees();
|
|
data = dat.Select(JsonConvert.SerializeObject).ToList();
|
|
}
|
|
else if (endpoint == "get_personen")
|
|
{
|
|
var dat = new CustomerServiceImp().GetAllActivePersonsCompact();
|
|
data = dat.Select(JsonConvert.SerializeObject).ToList();
|
|
}
|
|
else if (endpoint == "get_arbeitsverträge")
|
|
{
|
|
throw new Exception();
|
|
}
|
|
|
|
if (data.Count > 0)
|
|
{
|
|
req.ApiData.Add(new AiMessageRequestData() { Data = data, Name = endpoint });
|
|
}
|
|
}
|
|
|
|
dc.ApiMethods = string.Join(",", req.ApiData.Select(x => x.Name));
|
|
|
|
var input2 = JsonConvert.SerializeObject(req);
|
|
|
|
var result1 = ServiceFacade.MikePHPScriptFacade.SendAiRequest(dc, input2);
|
|
|
|
|
|
dc.Result = result1.Response;
|
|
|
|
return dc;
|
|
}
|
|
}
|
|
}
|