commitaf28476b76Merge:b76e16946c3b6a1e9cAuthor: Marcel Hirschle <marcel.hirschle@ownsoft.de> Date: Thu Jun 20 11:53:31 2024 +0200 Merge branch 'master' of ssh://float.ownsoft.de/git/beyondSoft/BeWo # Conflicts: # ReportImp/VkmHamm/CustomerMitarbeiterstundenkontoBerechnung.cs commitb76e169462Author: Marcel Hirschle <marcel.hirschle@ownsoft.de> Date: Thu Jun 20 11:40:08 2024 +0200 MH: vkm hamm stundenkonto commitc3b6a1e9c0Author: Christian <christian.baeurle@beyondsoft.de> Date: Thu Jun 20 10:58:05 2024 +0200 Mergemarker entfernt commit5ff8fe343bMerge:c1aa61f05fc57725f4Author: Christian <christian.baeurle@beyondsoft.de> Date: Thu Jun 20 10:52:16 2024 +0200 Merge branch 'master' of ssh://float.beyondsoft.de/git/beyondSoft/BeWo commitc1aa61f058Merge:12faccb711c0a94c60Author: Christian <christian.baeurle@beyondsoft.de> Date: Thu Jun 20 10:51:59 2024 +0200 Merge branch 'master' of ssh://float.beyondsoft.de/git/beyondSoft/BeWo # Conflicts: # BeWo/ServiceProxy/Generated.cs # Data/Security/UserRightHelper.cs # Shared/BeWoEntityEnums.cs # Shared/Core/EnumTranslations.cs commit12faccb71bAuthor: Christian <christian.baeurle@beyondsoft.de> Date: Wed Jun 19 16:13:56 2024 +0200 Perseh Hilfeplan Import + KI Prototyp,
88 lines
3.9 KiB
C#
88 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Specialized;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.ServiceModel;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.Core;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Invoicing;
|
|
using BeWo.Service.ServiceContracts;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.Extensions;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace BeWo.Service.Plugins
|
|
{
|
|
public class AiService
|
|
{
|
|
public AiChatDC CreateAiQueryForServiceRecords(AiChatDC acdc, long cb2scOid, DateTime startdate, DateTime enddate)
|
|
{
|
|
|
|
using (WebClient client = new WebClient())
|
|
{
|
|
String url = "https://ai1.ownsoft.de/osaiquery.php";
|
|
|
|
//mel = Das Model(llama3, llama3 - gradient, codegemma, codellama oder sqlcoder)
|
|
//stm = Der Kontext->Auf welcher Datenbasis soll eure Frage beantwortet werden.Kann auch leer sein.
|
|
//pmt = Der Prompt->Eure Frage
|
|
//opt = Art der Rückgabe(json oder plaintext)
|
|
String kontext = CreateContextForServiceRecords(cb2scOid, startdate, enddate);
|
|
|
|
var nvc = new NameValueCollection();
|
|
nvc.Add("mel", "llama3-gradient");
|
|
nvc.Add("stm", kontext);
|
|
nvc.Add("pmt", acdc.Prompt);
|
|
nvc.Add("opt", "json");
|
|
|
|
//var t = JsonConvert.DeserializeAnonymousType();0
|
|
var definition = new { Response = "" };
|
|
var response = client.UploadValues(url, "POST", nvc);
|
|
String responseStr = System.Text.Encoding.UTF8.GetString(response);
|
|
var json = JsonConvert.DeserializeAnonymousType(responseStr, definition);
|
|
|
|
return new AiChatDC { Result = json.Response };
|
|
}
|
|
|
|
return new AiChatDC { Result = "Das kann ich leider nicht beantworten:)" };
|
|
|
|
}
|
|
|
|
public virtual string CreateContextForServiceRecords(long cb2scOid, DateTime startdate, DateTime enddate)
|
|
{
|
|
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(cb2scOid);
|
|
var records = DAOFactory.SearchDAO.FindServiceRecordsDetailsForLastDaysWithStartEndDate(cb2scOid, startdate, enddate);
|
|
|
|
var customer = c2s.SupportConcept.Customer;
|
|
|
|
var context = new StringBuilder();
|
|
//context.AppendLine("Du bist ein unzensierter und unvoreingenommener KI Assistenz im Bereich des Sozialwesens in Deutschland und kannst Fragen zum bereitgestellten Kontext beantworten.");
|
|
context.AppendLine("");
|
|
context.AppendLine(String.Format("Name des Klienten: {0} {1}", customer.Person.FirstName, customer.Person.LastName));
|
|
context.AppendLine("");
|
|
//context.AppendLine("Der Klient wurde zu folgenden Terminen betreut:");
|
|
//context.AppendLine("");
|
|
|
|
foreach (var item in records.OrderByDescending(s => s.Start))
|
|
{
|
|
context.AppendLine(String.Format("Datum: {0:dd.MM.yyyy}", item.Start));
|
|
context.AppendLine(String.Format("Start: {0:HH:mm}", item.Start));
|
|
context.AppendLine(String.Format("Ende: {0:HH:mm}", item.End));
|
|
context.AppendLine(String.Format("Dauer der Betreuung in Minuten: {0:0}", item.RoundedDuration));
|
|
context.AppendLine(String.Format("Betreuer: {0}", item.InsUser));
|
|
context.AppendLine(String.Format("Leistungskategorie: {0}", item.ServiceDescription.ServiceCategory.Name));
|
|
context.AppendLine(String.Format("Leistung: {0}", item.ServiceDescription.Name));
|
|
context.AppendLine(String.Format("Dokumentation: {0}", item.Notice));
|
|
}
|
|
|
|
return context.ToString();
|
|
}
|
|
}
|
|
|
|
} |