Promptbausteine auswählen und absenden
This commit is contained in:
@@ -7,8 +7,6 @@
|
||||
// der Code erneut generiert wird.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using BS.Shared.DataContracts.Feature.AI;
|
||||
|
||||
namespace BeWo.ServiceProxy
|
||||
{
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
@@ -56,23 +54,30 @@ namespace BeWo.ServiceProxy
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/SendNewMessage", ReplyAction="http://tempuri.org/IAiEnhancedService/SendNewMessageResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/SendNewMessageBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
System.Collections.Generic.List<AiConversationMessageDC> SendNewMessage(long conversation, string message);
|
||||
System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationMessageDC> SendNewMessage(long conversation, string message);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/GetAiPromptbausteine", ReplyAction="http://tempuri.org/IAiEnhancedService/GetAiPromptbausteineResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/GetAiPromptbausteineBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
System.Collections.Generic.List<AiPromptbausteinTreeDC> GetAiPromptbausteine();
|
||||
System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinTreeDC> GetAiPromptbausteine();
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/CreateAiPromptbausteine", ReplyAction="http://tempuri.org/IAiEnhancedService/CreateAiPromptbausteineResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/CreateAiPromptbausteineBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
System.Collections.Generic.List<AiPromptbausteinTreeDC> CreateAiPromptbausteine(System.Collections.Generic.List<AiPromptbausteinTreeDC> aiPromptbausteinDC);
|
||||
System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinTreeDC> CreateAiPromptbausteine(System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinTreeDC> aiPromptbausteinDC);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteine", ReplyAction="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteineResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteineBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
System.Collections.Generic.Dictionary<long, long> UpdateAiPromptbausteine(System.Collections.Generic.List<AiPromptbausteinTreeDC> aiPromptbausteinDCs);
|
||||
System.Collections.Generic.Dictionary<long, long> UpdateAiPromptbausteine(System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinTreeDC> aiPromptbausteinDCs);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteine", ReplyAction="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteineResponse")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteineBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
void DeleteAiPromptbausteine(System.Collections.Generic.Dictionary<long, long> oid2version);
|
||||
|
||||
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/ExecuteAiFunctionServiceRecordDocumentation" +
|
||||
"", ReplyAction="http://tempuri.org/IAiEnhancedService/ExecuteAiFunctionServiceRecordDocumentation" +
|
||||
"Response")]
|
||||
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/ExecuteAiFunctionServiceRecordDocumentation" +
|
||||
"BeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
|
||||
BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords.AiFunctionDocResponse ExecuteAiFunctionServiceRecordDocumentation(BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords.AiFunctionDocRequest request);
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||
@@ -154,22 +159,22 @@ namespace BeWo.ServiceProxy
|
||||
base.Channel.DeleteAiConversation(conversation_oid);
|
||||
}
|
||||
|
||||
public System.Collections.Generic.List<AiConversationMessageDC> SendNewMessage(long conversation, string message)
|
||||
public System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationMessageDC> SendNewMessage(long conversation, string message)
|
||||
{
|
||||
return base.Channel.SendNewMessage(conversation, message);
|
||||
}
|
||||
|
||||
public System.Collections.Generic.List<AiPromptbausteinTreeDC> GetAiPromptbausteine()
|
||||
public System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinTreeDC> GetAiPromptbausteine()
|
||||
{
|
||||
return base.Channel.GetAiPromptbausteine();
|
||||
}
|
||||
|
||||
public System.Collections.Generic.List<AiPromptbausteinTreeDC> CreateAiPromptbausteine(System.Collections.Generic.List<AiPromptbausteinTreeDC> aiPromptbausteinDC)
|
||||
public System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinTreeDC> CreateAiPromptbausteine(System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinTreeDC> aiPromptbausteinDC)
|
||||
{
|
||||
return base.Channel.CreateAiPromptbausteine(aiPromptbausteinDC);
|
||||
}
|
||||
|
||||
public System.Collections.Generic.Dictionary<long, long> UpdateAiPromptbausteine(System.Collections.Generic.List<AiPromptbausteinTreeDC> aiPromptbausteinDCs)
|
||||
public System.Collections.Generic.Dictionary<long, long> UpdateAiPromptbausteine(System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinTreeDC> aiPromptbausteinDCs)
|
||||
{
|
||||
return base.Channel.UpdateAiPromptbausteine(aiPromptbausteinDCs);
|
||||
}
|
||||
@@ -178,5 +183,10 @@ namespace BeWo.ServiceProxy
|
||||
{
|
||||
base.Channel.DeleteAiPromptbausteine(oid2version);
|
||||
}
|
||||
|
||||
public BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords.AiFunctionDocResponse ExecuteAiFunctionServiceRecordDocumentation(BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords.AiFunctionDocRequest request)
|
||||
{
|
||||
return base.Channel.ExecuteAiFunctionServiceRecordDocumentation(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1723,8 +1723,8 @@
|
||||
<Button
|
||||
x:Name="btn_AiPromptbaustein"
|
||||
Padding="0"
|
||||
Content="{StaticResource AiDesignsIconKIFunktionWeissGruen}"
|
||||
Command="{Binding OpenAiPromptSelectionCommand}"/>
|
||||
Command="{Binding OpenAiPromptSelectionCommand}"
|
||||
Content="{StaticResource AiDesignsIconKIFunktionWeissGruen}" />
|
||||
</StackPanel>
|
||||
|
||||
<Button
|
||||
|
||||
@@ -2117,6 +2117,7 @@ namespace BeWo.View.Detail.Zeiterfassung
|
||||
}
|
||||
|
||||
srListBox.ItemsSource = list;
|
||||
ViewModel.CurrentVisibleVMs = list;
|
||||
//###Bars
|
||||
var selected = srGridControl.CurrentItem;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
@@ -98,6 +99,8 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
|
||||
public ICommand OpenAiPromptSelectionCommand { get; set; }
|
||||
|
||||
public IList<ServiceRecordVM> VisibleSerivceRecords { get; set; }
|
||||
|
||||
public ServiceRecordListVM(
|
||||
Dictionary<ServiceCategoryDC, List<ServiceDescriptionDC>> pCategory2Services,
|
||||
IEnumerable<ValueListEntryDC> pAllGoalCategories,
|
||||
@@ -168,12 +171,18 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
|
||||
vm.PromptAccepted += PromptAccepted;
|
||||
|
||||
OpenAiPromptSelectionCommand = new DelegateCommand(() => {
|
||||
OpenAiPromptSelectionCommand = new DelegateCommand(() =>
|
||||
{
|
||||
BeWoApp.MainControl.WindowService.ShowAiPromptbausteinSelectionWindow(vm);
|
||||
}, () => SelectedCustomerNode is object);
|
||||
}
|
||||
|
||||
public string AktuellerDokutext { get; set; }
|
||||
public IEnumerable<ServiceRecordVM> CurrentVisibleVMs { get; set; }
|
||||
public string AktuellerDokutext
|
||||
{
|
||||
get => PrototypeVM.Notice;
|
||||
set => PrototypeVM.Notice = value;
|
||||
}
|
||||
|
||||
private void PromptAccepted(object sender, AiPromptbausteinTreeVM prompt)
|
||||
{
|
||||
@@ -191,18 +200,67 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
var support_concept_version = support_concept.SupportConceptVersion;
|
||||
|
||||
// 1.3 Aktuelles Doku Feld
|
||||
var doku_feld = PrototypeVM.Notice;
|
||||
var doku_feld = AktuellerDokutext;
|
||||
|
||||
// 1.4 Sichtbaren Zeiterfassungseinträge
|
||||
var service_records = CurrentVisibleVMs;
|
||||
var sr_refs = service_records.Select(x => new BeWoRefDC(x.DataContract.ServiceRecordOid.Value, x.DataContract.ServiceRecordVersion));
|
||||
|
||||
// 1.5 Costbearer
|
||||
var costbearer = SelectedCustomerNode.SupportConceptTreeNodeDC.CostBearer;
|
||||
var cb_oid = costbearer.CostBearerOid.Value;
|
||||
var cb_ver = costbearer.CostBearerVersion;
|
||||
|
||||
// Service Aufruf
|
||||
var req = new AiFunctionDocRequest()
|
||||
{
|
||||
AiPromptbaustein = new BeWoRefDC(prompt_oid, prompt_version),
|
||||
SupportConcept = new BeWoRefDC(support_concept_oid, support_concept_version),
|
||||
ServiceRecords = sr_refs,
|
||||
CostBearer = new BeWoRefDC(cb_oid, cb_ver),
|
||||
Dokumentation = doku_feld,
|
||||
};
|
||||
|
||||
// Ergebnis
|
||||
AktuellerDokutext = "Ergebnis";
|
||||
ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.ExecuteAiFunctionServiceRecordDocumentation(req),
|
||||
callback =>
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine("AI Antwort:");
|
||||
sb.AppendLine(callback.Result);
|
||||
|
||||
sb.AppendLine();
|
||||
sb.AppendLine(AktuellerDokutext);
|
||||
|
||||
AktuellerDokutext = sb.ToString();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public Dictionary<TableID, long[]> GetVisibleInformationReferences(IEnumerable<ServiceRecordVM> selected_records)
|
||||
{
|
||||
var current = SelectedCustomerNode;
|
||||
var hello = current?.SupportConceptTreeNodeDC;
|
||||
var sr = ServiceRecordsForSelectedCustomer;
|
||||
|
||||
if (current is null)
|
||||
return null;
|
||||
|
||||
var oids = new List<long>();
|
||||
foreach (var record in selected_records)
|
||||
{
|
||||
oids.Add(record.DataContract.ServiceRecordOid ?? -1);
|
||||
}
|
||||
|
||||
var rtn = new Dictionary<TableID, long[]>()
|
||||
{
|
||||
{TableID.Customer, new long[]{ hello.Customer.CustomerOid } },
|
||||
{TableID.SupportConcept, new long[]{ hello.SupportConcept.SupportConceptOid } },
|
||||
{TableID.CostBearer, new long[]{ hello.CostBearer.CostBearerOid ?? -1 } },
|
||||
{TableID.ServiceRecord, oids.ToArray() }
|
||||
};
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
//CB EINKOMMENTIEREN
|
||||
@@ -1965,31 +2023,5 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
public Dictionary<TableID, long[]> GetVisibleInformationReferences(IEnumerable<ServiceRecordVM> selected_records)
|
||||
{
|
||||
var current = SelectedCustomerNode;
|
||||
var hello = current?.SupportConceptTreeNodeDC;
|
||||
var sr = ServiceRecordsForSelectedCustomer;
|
||||
|
||||
if (current is null)
|
||||
return null;
|
||||
|
||||
var oids = new List<long>();
|
||||
foreach (var record in selected_records)
|
||||
{
|
||||
oids.Add(record.DataContract.ServiceRecordOid ?? -1);
|
||||
}
|
||||
|
||||
var rtn = new Dictionary<TableID, long[]>()
|
||||
{
|
||||
{TableID.Customer, new long[]{ hello.Customer.CustomerOid } },
|
||||
{TableID.SupportConcept, new long[]{ hello.SupportConcept.SupportConceptOid } },
|
||||
{TableID.CostBearer, new long[]{ hello.CostBearer.CostBearerOid ?? -1 } },
|
||||
{TableID.ServiceRecord, oids.ToArray() }
|
||||
};
|
||||
|
||||
return rtn;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -935,7 +935,7 @@ namespace BeWo.ViewModel
|
||||
|
||||
internal static void CreateAiPromptbausteinListAsync(Action<AiPromptbausteinListVM> rtn_viewmodel)
|
||||
{
|
||||
//ServiceFacade.DoOperationsServiceAsync(x => x.GetAiPrompt(), cb =>
|
||||
//ServiceFacade.DoOperationsServiceAsync(x => x.(), cb =>
|
||||
//{
|
||||
// var list = new AiPromptbausteinListVM(cb);
|
||||
// rtn_viewmodel(list);
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace BeWo.ViewModel.View.AI
|
||||
|
||||
public void Send()
|
||||
{
|
||||
PromptAccepted?.Invoke(this, SelectedNode);
|
||||
|
||||
CloseDialogCommand.Execute(null);
|
||||
|
||||
PromptAccepted?.Invoke(this, SelectedNode);
|
||||
}
|
||||
|
||||
public void UpdateVMList(AiPromptbausteinTreeListVM new_list)
|
||||
|
||||
@@ -307,7 +307,8 @@
|
||||
|
||||
<add key="OpenWebUIUrl" value="https://owui1.ownsoft.de" />
|
||||
<add key="OllamaUrl" value="https://w2.ownchat.de" />
|
||||
<add key="AiSystemPromptPath" value="C:\BeWoPlaner\AI\systemPrompts\customSystemPrompt.txt" />
|
||||
<add key="AiConversationSystemPromptPath" value="C:\BeWoPlaner\AI\systemPrompts\customSystemPrompt.txt" />
|
||||
<add key="AiFunctionSystemPromptPath" value="C:\BeWoPlaner\AI\systemPrompts\customFunctionSystemPrompt.txt" />
|
||||
<add key="AiServiceLogFilePath" value="C:\BeWoPlaner\logs2\server\aiservice.log.txt" />
|
||||
<add key="AiServiceLastRequestEnabled" value="true" />
|
||||
<add key="AiServiceLastRequestFilePath" value="C:\BeWoPlaner\logs2\server\lastairequest.json" />
|
||||
|
||||
@@ -90,25 +90,28 @@
|
||||
<Compile Include="Context\SummaryParser\CsvContextSummaryParser.cs" />
|
||||
<Compile Include="Context\SummaryParser\JsonContextSummaryParser.cs" />
|
||||
<Compile Include="Context\Summary\BaseContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Detail\CustomerDetailContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\CustomerNavigationContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Detail\DetailContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Detail\EmployeeDetailContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\EmployeeNavigationContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\NavigationContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Detail\OrganisationDetailContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\OrganisationNavigationContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Detail\PersonDetailContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\PersonNavigationContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\ServiceRecordNavigationContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Detail\SupportConceptDetailContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\SupportConceptNavigationContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Detail\CustomerDetailCS.cs" />
|
||||
<Compile Include="Context\Summary\Function\BaseFunctionContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Function\ServiceRecordDocumantationFCS.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\CustomerNavigationCS.cs" />
|
||||
<Compile Include="Context\Summary\Detail\BaseDetailContextSummary.cs" />
|
||||
<Compile Include="Context\Summary\Detail\EmployeeDetailCS.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\EmployeeNavigationCS.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\BaseNavigationCS.cs" />
|
||||
<Compile Include="Context\Summary\Detail\OrganisationDetailCS.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\OrganisationNavigationCS.cs" />
|
||||
<Compile Include="Context\Summary\Detail\PersonDetailCS.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\PersonNavigationCS.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\ServiceRecordNavigationCS.cs" />
|
||||
<Compile Include="Context\Summary\Detail\SupportConceptDetailCS.cs" />
|
||||
<Compile Include="Context\Summary\Navigation\SupportConceptNavigationCS.cs" />
|
||||
<Compile Include="Facade\DefaultErrorExtractor.cs" />
|
||||
<Compile Include="Facade\LLM\BaseLLMApiClient.cs" />
|
||||
<Compile Include="Facade\LLM\OllamaApiClient.cs" />
|
||||
<Compile Include="Facade\LLM\OpenWebApiClient.cs" />
|
||||
<Compile Include="Prompt\Core\AiFunctionSystemMessageBuilder.cs" />
|
||||
<Compile Include="Prompt\Core\AiUtils.cs" />
|
||||
<Compile Include="Prompt\Core\AiPromptBuilder.cs" />
|
||||
<Compile Include="Prompt\Core\AiConversationSystemMessageBuilder.cs" />
|
||||
<Compile Include="Prompt\Models\AiConversationContext.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using AICore.Context.Core;
|
||||
using AICore.Context.Summary;
|
||||
using AICore.Context.Summary.Detail;
|
||||
using AICore.Context.Summary.Function;
|
||||
using AICore.Context.Summary.Navigation;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords;
|
||||
using BS.Shared.Exceptions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -15,85 +17,97 @@ namespace AICore.Context.Core
|
||||
public static class AiContextSummaryFactory
|
||||
{
|
||||
public static BaseContextSummary CreateServiceRecordNavigationContextSummary(IEnumerable<ServiceRecordDC> serviceRecords,
|
||||
CompactCustomerDC customer, CompactSupportConceptDC supportConcept)
|
||||
CompactCustomerDC customer, CompactCostBearerDC costBearer, CompactSupportConceptDC supportConcept)
|
||||
{
|
||||
var entries = ContextEntryMapperFactory.ServiceRecordMapper.MapToNewContexts(serviceRecords);
|
||||
var customer_entry = ContextEntryMapperFactory.ServiceRecordCustomerMapper.MapToNewContext(customer);
|
||||
|
||||
var costbearer_str = supportConcept.CostBearer;
|
||||
var costbearer_str = costBearer.OrganisationName;
|
||||
var supportconcept_str = $"{supportConcept.StartDate?.Date} - {supportConcept.EndDate?.Date}";
|
||||
|
||||
return new ServiceRecordNavigationContextSummary(entries, customer_entry, costbearer_str, supportconcept_str);
|
||||
return new ServiceRecordNavigationCS(entries, customer_entry, costbearer_str, supportconcept_str);
|
||||
}
|
||||
|
||||
public static BaseContextSummary CreateCustomerDetailContextSummary(CustomerDC customer)
|
||||
{
|
||||
var entry = ContextEntryMapperFactory.CustomerMapper.MapToNewContext(customer);
|
||||
|
||||
return new CustomerDetailContextSummary(entry);
|
||||
return new CustomerDetailCS(entry);
|
||||
}
|
||||
|
||||
public static BaseContextSummary CreateEmployeeDetailContextSummary(EmployeeDC employee)
|
||||
{
|
||||
var entry = ContextEntryMapperFactory.EmployeeMapper.MapToNewContext(employee);
|
||||
|
||||
return new EmployeeDetailContextSummary(entry);
|
||||
return new EmployeeDetailCS(entry);
|
||||
}
|
||||
|
||||
public static BaseContextSummary CreatePersonDetailContextSummary(PersonDC person)
|
||||
{
|
||||
var entry = ContextEntryMapperFactory.PersonMapper.MapToNewContext(person);
|
||||
|
||||
return new PersonDetailContextSummary(entry);
|
||||
return new PersonDetailCS(entry);
|
||||
}
|
||||
|
||||
public static BaseContextSummary CreateOrganisationDetailContextSummary(OrganisationDC organisation)
|
||||
{
|
||||
var entry = ContextEntryMapperFactory.OrganisationMapper.MapToNewContext(organisation);
|
||||
|
||||
return new OrganisationDetailContextSummary(entry);
|
||||
return new OrganisationDetailCS(entry);
|
||||
}
|
||||
|
||||
public static BaseContextSummary CreateSupportConceptDetailContextSummary(SupportConceptDC supportConcept)
|
||||
{
|
||||
var entry = ContextEntryMapperFactory.SupportConceptMapper.MapToNewContext(supportConcept);
|
||||
|
||||
return new SupportConceptDetailContextSummary(entry);
|
||||
return new SupportConceptDetailCS(entry);
|
||||
}
|
||||
|
||||
public static BaseContextSummary CreateCustomerNavigationContextSummary(IEnumerable<CompactCustomerDC> customer)
|
||||
{
|
||||
var entry = ContextEntryMapperFactory.CustomerNavigationMapper.MapToNewContexts(customer);
|
||||
|
||||
return new CustomerNavigationContextSummary(entry);
|
||||
return new CustomerNavigationCS(entry);
|
||||
}
|
||||
|
||||
public static BaseContextSummary CreateEmployeeNavigationContextSummary(IEnumerable<CompactEmployeeDC> employee)
|
||||
{
|
||||
var entry = ContextEntryMapperFactory.EmployeeNavigationMapper.MapToNewContexts(employee);
|
||||
|
||||
return new EmployeeNavigationContextSummary(entry);
|
||||
return new EmployeeNavigationCS(entry);
|
||||
}
|
||||
|
||||
public static BaseContextSummary CreatePersonNavigationContextSummary(IEnumerable<CompactPersonDC> person)
|
||||
{
|
||||
var entry = ContextEntryMapperFactory.PersonNavigationMapper.MapToNewContexts(person);
|
||||
|
||||
return new PersonNavigationContextSummary(entry);
|
||||
return new PersonNavigationCS(entry);
|
||||
}
|
||||
|
||||
public static BaseContextSummary CreateOrganisationNavigationContextSummary(IEnumerable<CompactOrganisationDC> organisation)
|
||||
{
|
||||
var entry = ContextEntryMapperFactory.OrganisationNavigationMapper.MapToNewContexts(organisation);
|
||||
|
||||
return new OrganisationNavigationContextSummary(entry);
|
||||
return new OrganisationNavigationCS(entry);
|
||||
}
|
||||
|
||||
public static BaseContextSummary CreateSupportConceptNavigationContextSummary(IEnumerable<CompactSupportConceptDC> supportConcept)
|
||||
{
|
||||
var entry = ContextEntryMapperFactory.SupportConceptNavigationMapper.MapToNewContexts(supportConcept);
|
||||
|
||||
return new SupportConceptNavigationContextSummary(entry);
|
||||
return new SupportConceptNavigationCS(entry);
|
||||
}
|
||||
|
||||
public static BaseContextSummary CreateServiceRecordDocumentationFunction(IEnumerable<ServiceRecordDC> serviceRecords,
|
||||
CompactCustomerDC customer, CompactCostBearerDC costBearer, CompactSupportConceptDC supportConcept, string doku)
|
||||
{
|
||||
var entries = ContextEntryMapperFactory.ServiceRecordMapper.MapToNewContexts(serviceRecords);
|
||||
var customer_entry = ContextEntryMapperFactory.ServiceRecordCustomerMapper.MapToNewContext(customer);
|
||||
|
||||
var costbearer_str = costBearer.OrganisationName;
|
||||
var supportconcept_str = $"{supportConcept.StartDate?.Date} - {supportConcept.EndDate?.Date}";
|
||||
|
||||
return new ServiceRecordDocumantationFCS(entries, customer_entry, costbearer_str, supportconcept_str, doku);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace AICore.Context.Summary.Detail
|
||||
{
|
||||
internal abstract class DetailContextSummary<TEntry> : BaseContextSummary where TEntry : DetailContextEntry
|
||||
internal abstract class BaseDetailContextSummary<TEntry> : BaseContextSummary where TEntry : DetailContextEntry
|
||||
{
|
||||
internal TEntry DataContext { get; set; }
|
||||
|
||||
protected DetailContextSummary(TEntry dataContext)
|
||||
protected BaseDetailContextSummary(TEntry dataContext)
|
||||
{
|
||||
DataContext = dataContext;
|
||||
Context = dataContext;
|
||||
@@ -0,0 +1,9 @@
|
||||
using AICore.Context.Entry.Detail;
|
||||
|
||||
namespace AICore.Context.Summary.Detail
|
||||
{
|
||||
internal class CustomerDetailCS : BaseDetailContextSummary<CustomerDetailContextEntry>
|
||||
{
|
||||
internal CustomerDetailCS(CustomerDetailContextEntry customer) : base(customer) { }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using AICore.Context.Entry.Detail;
|
||||
|
||||
namespace AICore.Context.Summary.Detail
|
||||
{
|
||||
internal class CustomerDetailContextSummary : DetailContextSummary<CustomerDetailContextEntry>
|
||||
{
|
||||
internal CustomerDetailContextSummary(CustomerDetailContextEntry customer) : base(customer) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using AICore.Context.Entry.Detail;
|
||||
|
||||
namespace AICore.Context.Summary.Detail
|
||||
{
|
||||
internal class EmployeeDetailCS : BaseDetailContextSummary<EmployeeDetailContextEntry>
|
||||
{
|
||||
internal EmployeeDetailCS(EmployeeDetailContextEntry employee) : base(employee) { }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using AICore.Context.Entry.Detail;
|
||||
|
||||
namespace AICore.Context.Summary.Detail
|
||||
{
|
||||
internal class EmployeeDetailContextSummary : DetailContextSummary<EmployeeDetailContextEntry>
|
||||
{
|
||||
internal EmployeeDetailContextSummary(EmployeeDetailContextEntry employee) : base(employee) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using AICore.Context.Entry.Detail;
|
||||
|
||||
namespace AICore.Context.Summary.Detail
|
||||
{
|
||||
internal class OrganisationDetailCS : BaseDetailContextSummary<OrganisationDetailContextEntry>
|
||||
{
|
||||
internal OrganisationDetailCS(OrganisationDetailContextEntry organisation) : base(organisation) { }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using AICore.Context.Entry.Detail;
|
||||
|
||||
namespace AICore.Context.Summary.Detail
|
||||
{
|
||||
internal class OrganisationDetailContextSummary : DetailContextSummary<OrganisationDetailContextEntry>
|
||||
{
|
||||
internal OrganisationDetailContextSummary(OrganisationDetailContextEntry organisation) : base(organisation) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using AICore.Context.Entry.Detail;
|
||||
|
||||
namespace AICore.Context.Summary.Detail
|
||||
{
|
||||
internal class PersonDetailCS : BaseDetailContextSummary<PersonDetailContextEntry>
|
||||
{
|
||||
internal PersonDetailCS(PersonDetailContextEntry person) : base(person) { }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using AICore.Context.Entry.Detail;
|
||||
|
||||
namespace AICore.Context.Summary.Detail
|
||||
{
|
||||
internal class PersonDetailContextSummary : DetailContextSummary<PersonDetailContextEntry>
|
||||
{
|
||||
internal PersonDetailContextSummary(PersonDetailContextEntry person) : base(person) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using AICore.Context.Entry.Detail;
|
||||
|
||||
namespace AICore.Context.Summary.Detail
|
||||
{
|
||||
internal class SupportConceptDetailCS : BaseDetailContextSummary<SupportConceptDetailContextEntry>
|
||||
{
|
||||
internal SupportConceptDetailCS(SupportConceptDetailContextEntry supportConcept) : base(supportConcept) { }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using AICore.Context.Entry.Detail;
|
||||
|
||||
namespace AICore.Context.Summary.Detail
|
||||
{
|
||||
internal class SupportConceptDetailContextSummary : DetailContextSummary<SupportConceptDetailContextEntry>
|
||||
{
|
||||
internal SupportConceptDetailContextSummary(SupportConceptDetailContextEntry supportConcept) : base(supportConcept) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AICore.Context.Summary.Function
|
||||
{
|
||||
internal abstract class BaseFunctionContextSummary : BaseContextSummary
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using AICore.Context.Entry.Navigation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AICore.Context.Summary.Function
|
||||
{
|
||||
internal class ServiceRecordDocumantationFCS : BaseFunctionContextSummary
|
||||
{
|
||||
internal IEnumerable<ServiceRecordContextEntry> ServiceRecords { get; set; }
|
||||
internal CustomerNavigationContextEntry Customer { get; set; }
|
||||
internal string CostBearer { get; set; }
|
||||
internal string SupportConcept { get; set; }
|
||||
internal string Dokutext { get; set; }
|
||||
|
||||
internal ServiceRecordDocumantationFCS(IEnumerable<ServiceRecordContextEntry> serviceRecords, CustomerNavigationContextEntry customer, string costBearer, string supportConcept, string dokutext)
|
||||
: base()
|
||||
{
|
||||
Context = this;
|
||||
ServiceRecords = serviceRecords;
|
||||
Customer = customer;
|
||||
CostBearer = costBearer;
|
||||
SupportConcept = supportConcept;
|
||||
Dokutext = dokutext;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,11 @@ using AICore.Context.Entry.Navigation;
|
||||
|
||||
namespace AICore.Context.Summary.Navigation
|
||||
{
|
||||
internal abstract class NavigationContextSummary<TEntry> : BaseContextSummary where TEntry : NavigationContextEntry
|
||||
internal abstract class BaseNavigationCS<TEntry> : BaseContextSummary where TEntry : NavigationContextEntry
|
||||
{
|
||||
internal IEnumerable<TEntry> DataContext { get; set; }
|
||||
|
||||
protected NavigationContextSummary(IEnumerable<TEntry> dataContext)
|
||||
protected BaseNavigationCS(IEnumerable<TEntry> dataContext)
|
||||
{
|
||||
DataContext = dataContext;
|
||||
Context = dataContext;
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using AICore.Context.Entry.Navigation;
|
||||
|
||||
namespace AICore.Context.Summary.Navigation
|
||||
{
|
||||
internal class CustomerNavigationCS : BaseNavigationCS<CustomerNavigationContextEntry>
|
||||
{
|
||||
internal CustomerNavigationCS(IEnumerable<CustomerNavigationContextEntry> customers) : base(customers) { }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using AICore.Context.Entry.Navigation;
|
||||
|
||||
namespace AICore.Context.Summary.Navigation
|
||||
{
|
||||
internal class CustomerNavigationContextSummary : NavigationContextSummary<CustomerNavigationContextEntry>
|
||||
{
|
||||
internal CustomerNavigationContextSummary(IEnumerable<CustomerNavigationContextEntry> customers) : base(customers) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using AICore.Context.Entry.Navigation;
|
||||
|
||||
namespace AICore.Context.Summary.Navigation
|
||||
{
|
||||
internal class EmployeeNavigationCS : BaseNavigationCS<EmployeeNavigationContextEntry>
|
||||
{
|
||||
internal EmployeeNavigationCS(IEnumerable<EmployeeNavigationContextEntry> employee) : base(employee) { }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using AICore.Context.Entry.Navigation;
|
||||
|
||||
namespace AICore.Context.Summary.Navigation
|
||||
{
|
||||
internal class EmployeeNavigationContextSummary : NavigationContextSummary<EmployeeNavigationContextEntry>
|
||||
{
|
||||
internal EmployeeNavigationContextSummary(IEnumerable<EmployeeNavigationContextEntry> employee) : base(employee) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using AICore.Context.Entry.Navigation;
|
||||
|
||||
namespace AICore.Context.Summary.Navigation
|
||||
{
|
||||
internal class OrganisationNavigationCS : BaseNavigationCS<OrganisationNavigationContextEntry>
|
||||
{
|
||||
internal OrganisationNavigationCS(IEnumerable<OrganisationNavigationContextEntry> organisation) : base(organisation) { }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using AICore.Context.Entry.Navigation;
|
||||
|
||||
namespace AICore.Context.Summary.Navigation
|
||||
{
|
||||
internal class OrganisationNavigationContextSummary : NavigationContextSummary<OrganisationNavigationContextEntry>
|
||||
{
|
||||
internal OrganisationNavigationContextSummary(IEnumerable<OrganisationNavigationContextEntry> organisation) : base(organisation) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using AICore.Context.Entry.Navigation;
|
||||
|
||||
namespace AICore.Context.Summary.Navigation
|
||||
{
|
||||
internal class PersonNavigationCS : BaseNavigationCS<PersonNavigationContextEntry>
|
||||
{
|
||||
internal PersonNavigationCS(IEnumerable<PersonNavigationContextEntry> person) : base(person) { }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using AICore.Context.Entry.Navigation;
|
||||
|
||||
namespace AICore.Context.Summary.Navigation
|
||||
{
|
||||
internal class PersonNavigationContextSummary : NavigationContextSummary<PersonNavigationContextEntry>
|
||||
{
|
||||
internal PersonNavigationContextSummary(IEnumerable<PersonNavigationContextEntry> person) : base(person) { }
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ using System.Collections.Generic;
|
||||
|
||||
namespace AICore.Context.Summary.Navigation
|
||||
{
|
||||
internal class ServiceRecordNavigationContextSummary : NavigationContextSummary<ServiceRecordContextEntry>
|
||||
internal class ServiceRecordNavigationCS : BaseNavigationCS<ServiceRecordContextEntry>
|
||||
{
|
||||
internal CustomerNavigationContextEntry Customer { get; set; }
|
||||
internal string CostBearer { get; set; }
|
||||
internal string SupportConcept { get; set; }
|
||||
|
||||
internal ServiceRecordNavigationContextSummary(IEnumerable<ServiceRecordContextEntry> serviceRecords, CustomerNavigationContextEntry customer, string costBearer, string supportConcept)
|
||||
internal ServiceRecordNavigationCS(IEnumerable<ServiceRecordContextEntry> serviceRecords, CustomerNavigationContextEntry customer, string costBearer, string supportConcept)
|
||||
: base(serviceRecords)
|
||||
{
|
||||
Customer = customer;
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using AICore.Context.Entry.Navigation;
|
||||
|
||||
namespace AICore.Context.Summary.Navigation
|
||||
{
|
||||
internal class SupportConceptNavigationCS : BaseNavigationCS<SupportConceptNavigationContextEntry>
|
||||
{
|
||||
internal SupportConceptNavigationCS(IEnumerable<SupportConceptNavigationContextEntry> supportConcept) : base(supportConcept) { }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using AICore.Context.Entry.Navigation;
|
||||
|
||||
namespace AICore.Context.Summary.Navigation
|
||||
{
|
||||
internal class SupportConceptNavigationContextSummary : NavigationContextSummary<SupportConceptNavigationContextEntry>
|
||||
{
|
||||
internal SupportConceptNavigationContextSummary(IEnumerable<SupportConceptNavigationContextEntry> supportConcept) : base(supportConcept) { }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using AICore.Context.Entry;
|
||||
using AICore.Context.Summary;
|
||||
using AICore.Context.Summary.Function;
|
||||
using AICore.Context.Summary.Navigation;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Exceptions;
|
||||
@@ -38,17 +39,29 @@ namespace AICore.Context.SummaryParser
|
||||
{
|
||||
return ToCsvString(value);
|
||||
}
|
||||
else if (context is ServiceRecordNavigationContextSummary summary)
|
||||
|
||||
var sb = new StringBuilder();
|
||||
if (context is ServiceRecordNavigationCS summary)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"Hilfeplan:{summary.SupportConcept}");
|
||||
sb.AppendLine($"Kostenträger:{summary.CostBearer}");
|
||||
sb.AppendLine("Klient:");
|
||||
sb.AppendLine("Klient (csv):");
|
||||
sb.Append(ToCsvString(summary.Customer));
|
||||
sb.AppendLine("Zeiterfassungseinträge:");
|
||||
sb.AppendLine(ToCsvString(summary.DataContext));
|
||||
return sb.ToString();
|
||||
}
|
||||
else if (context is ServiceRecordDocumantationFCS fcs)
|
||||
{
|
||||
sb.AppendLine($"Hilfeplan:{fcs.SupportConcept}");
|
||||
sb.AppendLine($"Kostenträger:{fcs.CostBearer}");
|
||||
sb.AppendLine("Klient (csv):");
|
||||
sb.Append(ToCsvString(fcs.Customer));
|
||||
sb.AppendLine("Zeiterfassungseinträge (csv):");
|
||||
sb.AppendLine(ToCsvString(fcs.ServiceRecords));
|
||||
sb.AppendLine($"Dokutext:{fcs.Dokutext}");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
throw BeWoNotImplementedException.CreateFromEnum(uicontext);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ using System.Text.Json;
|
||||
|
||||
namespace AICore.Prompt.Core
|
||||
{
|
||||
public class AiPromptBuilder
|
||||
public class AiConversationSystemMessageBuilder
|
||||
{
|
||||
public string CreateSystemInstructions(AiContextType uicontext, BaseContextSummary context, AiDataContextType aiDataContextType)
|
||||
{
|
||||
@@ -70,22 +70,9 @@ namespace AICore.Prompt.Core
|
||||
throw BeWoNotImplementedException.CreateFromEnum(aiDataContextType);
|
||||
}
|
||||
|
||||
private string getSystemPrompt(int i)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var resourceName = $"AICore.Prompt.SystemPrompts.system_prompt{i}.txt";
|
||||
|
||||
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
string result = reader.ReadToEnd();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private string getCustomSystemPrompt()
|
||||
{
|
||||
var path = MergedConfig.GetSetting("AiSystemPromptPath");
|
||||
var path = MergedConfig.GetSetting("AiConversationSystemPromptPath");
|
||||
|
||||
return File.ReadAllText(path);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using AICore.Context.Summary;
|
||||
using AICore.Context.Summary.Function;
|
||||
using AICore.Context.SummaryParser;
|
||||
using BeWo.ServerUtils.Core;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AICore.Prompt.Core
|
||||
{
|
||||
public class AiFunctionSystemMessageBuilder
|
||||
{
|
||||
public string CreateServiceRecordDocumentationSystemInstructions(AiFunctionType functionType, BaseContextSummary context)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine(getCustomSystemPrompt());
|
||||
|
||||
sb.AppendLine("### **Allgemein**");
|
||||
sb.AppendLine($"- Aktuelle Zeit: {DateTime.Now}");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("### **Ansicht**");
|
||||
sb.AppendLine($"- Ich befinde mich aktuell in der \"{EnumTranslations.Ai2Translation[AiContextType.ServiceRecord]}\" meiner Anwendung.");
|
||||
sb.AppendLine($"- Es ist kein Filter gesetzt.");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("### **Daten**");
|
||||
|
||||
if (context?.Context is null)
|
||||
{
|
||||
sb.AppendLine("Dir wurden keine Daten bereitgestellt.");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendLine("Du erhälst folgende Daten:");
|
||||
|
||||
var parser = new CsvContextSummaryParser();
|
||||
var parsed = parser.Parse(AiContextType.ServiceRecord, context);
|
||||
|
||||
sb.AppendLine(parsed);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string getCustomSystemPrompt()
|
||||
{
|
||||
var path = MergedConfig.GetSetting("AiFunctionSystemPromptPath");
|
||||
|
||||
return File.ReadAllText(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,16 @@
|
||||
using BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords;
|
||||
using AICore.Prompt.Core;
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BeWo.Service.ServiceProxy;
|
||||
using BeWo.Service.ServiceUtils;
|
||||
using BS.Shared;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Feature.AI;
|
||||
using BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords;
|
||||
using DevExpress.DataAccess.Native.Web;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp.Validation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -12,22 +24,65 @@ namespace BeWo.Service.Plugins
|
||||
public AiFunctionDocResponse ExecuteAiFunctionServiceRecordDocumentation(AiFunctionDocRequest request)
|
||||
{
|
||||
// Request valideren
|
||||
ValidateDocRequest(request);
|
||||
|
||||
// Request auswerten
|
||||
|
||||
// DB Daten holen
|
||||
|
||||
// DB Daten prüfen
|
||||
|
||||
// Anfrage zusammensetzen
|
||||
var context = AiFunctionContextLoader.LoadServiceRecordDocumentationContext(request);
|
||||
|
||||
var factory = new AiFunctionSystemMessageBuilder();
|
||||
var system_prompt = factory.CreateServiceRecordDocumentationSystemInstructions(AiFunctionType.ServiceRecordDocumentation, context);
|
||||
|
||||
var user_prompt = request.AiPromptbaustein;
|
||||
var user_prompt_oid = user_prompt.Oid;
|
||||
var user_prompt_ver = user_prompt.Version;
|
||||
|
||||
var predefined = new PredefinedAiPromptbausteine();
|
||||
var prompts = predefined.GetAllPromptbausteine();
|
||||
var prompt = prompts.First(x => x.Oid == user_prompt_oid).Prompt;
|
||||
|
||||
// Anfrage abschicken
|
||||
var result = getResult(system_prompt, prompt);
|
||||
|
||||
// Response auswerten
|
||||
|
||||
// Eigene Response erstellen
|
||||
var response = new AiFunctionDocResponse();
|
||||
response.Result = result;
|
||||
|
||||
throw new System.NotImplementedException();
|
||||
return response;
|
||||
}
|
||||
|
||||
private string getResult(string system, string user_prompt)
|
||||
{
|
||||
var payload = new
|
||||
{
|
||||
model = "gemma3_12b-max-context:latest",
|
||||
messages = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
role = "System",
|
||||
content = system
|
||||
},
|
||||
new
|
||||
{
|
||||
role = "User",
|
||||
content = user_prompt
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var response = ServiceFacade.OllamaApiClient.SendAiMessageRequest(payload, out string message, out string model, out int? duration);
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private void ValidateDocRequest(AiFunctionDocRequest request)
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,16 @@ namespace BeWo.Service.Plugins
|
||||
{
|
||||
public IEnumerable<AiPromptbausteinTreeDC> GetAiPromptbausteine()
|
||||
{
|
||||
var dc = new AiPromptbausteinTreeDC();
|
||||
//var dc = new AiPromptbausteinTreeDC();
|
||||
|
||||
//dc.Oid = 1;
|
||||
//dc.IsParent = false;
|
||||
//dc.Version = 1;
|
||||
//dc.Text = "Beispiel";
|
||||
|
||||
return new List<AiPromptbausteinTreeDC> { dc };
|
||||
var predefined = new PredefinedAiPromptbausteine();
|
||||
|
||||
return predefined.GetFullPromptbausteineTree();
|
||||
}
|
||||
|
||||
public IEnumerable<AiPromptbausteinTreeDC> CreateAiPromptbausteine(IEnumerable<AiPromptbausteinTreeDC> aiPromptbausteinDC)
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace BeWo.Service.Plugins
|
||||
{
|
||||
var current_user = UserRightHelper.GetLoggedInUserWithOid();
|
||||
|
||||
var factory = new AiPromptBuilder();
|
||||
var factory = new AiConversationSystemMessageBuilder();
|
||||
|
||||
var context_loaded = AiContextLoader.LoadContext(uicontext, context_reference);
|
||||
var system_prompt = factory.CreateSystemInstructions(uicontext, context_loaded, context_Type);
|
||||
|
||||
@@ -560,6 +560,8 @@
|
||||
<Compile Include="ServiceImplementations\ValueListServiceImp.cs" />
|
||||
<Compile Include="Configuration\AppSettings.cs" />
|
||||
<Compile Include="ServiceProxy\ServiceFacade.cs" />
|
||||
<Compile Include="ServiceUtils\DataContractLoader.cs" />
|
||||
<Compile Include="ServiceUtils\AiFunctionContextLoader.cs" />
|
||||
<Compile Include="ServiceUtils\DistanceCalculator\AddressRouteManager.cs" />
|
||||
<Compile Include="ServiceUtils\DistanceCalculator\AddressRouteMatrix.cs" />
|
||||
<Compile Include="ServiceUtils\DistanceCalculator\GoogleDistanceMatrixAPI.cs" />
|
||||
|
||||
@@ -15,7 +15,5 @@ namespace BeWo.Service.ServiceProxy
|
||||
|
||||
public static OpenWebApiClient OpenWebApiClient => _OpenWebApiClient.Value;
|
||||
public static OllamaApiClient OllamaApiClient => _OllamaApiClient.Value;
|
||||
|
||||
public static BaseLLMApiClient ActiveAiClient => OllamaApiClient;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +105,9 @@ namespace BeWo.Service.ServiceUtils
|
||||
var customer = loadCompactCustomerDC(context_reference);
|
||||
var serviceRecords = loadServiceRecordDCs(context_reference);
|
||||
var supportConcept = loadSupportConceptDC(context_reference);
|
||||
var costBearer = supportConcept.CostBearerList.First(x => x.CostBearerOid == context_reference[TableID.CostBearer][0]);
|
||||
|
||||
return AiContextSummaryFactory.CreateServiceRecordNavigationContextSummary(serviceRecords, customer, supportConcept);
|
||||
return AiContextSummaryFactory.CreateServiceRecordNavigationContextSummary(serviceRecords, customer, costBearer, supportConcept);
|
||||
}
|
||||
|
||||
private static bool oidsContainsOid(long[] oids, long oid)
|
||||
|
||||
38
Service/ServiceUtils/AiFunctionContextLoader.cs
Normal file
38
Service/ServiceUtils/AiFunctionContextLoader.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using AICore.Context.Summary;
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BS.Shared;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AICore.Context.Core;
|
||||
|
||||
namespace BeWo.Service.ServiceUtils
|
||||
{
|
||||
public class AiFunctionContextLoader
|
||||
{
|
||||
public static BaseContextSummary LoadServiceRecordDocumentationContext(AiFunctionDocRequest request)
|
||||
{
|
||||
var srs = request.ServiceRecords;
|
||||
var srs_loaded = DataContractLoader.LoadServiceRecordDCs(srs);
|
||||
|
||||
var sc_ref = request.SupportConcept;
|
||||
var sc_loaded = DataContractLoader.LoadSupportConceptDC(sc_ref);
|
||||
|
||||
var customer_loaded = sc_loaded.Customer;
|
||||
var costbearer_loaded = sc_loaded.CostBearerList.First(x => request.CostBearer.Oid == x.Oid);
|
||||
|
||||
var doku = request.Dokumentation;
|
||||
|
||||
var context = AiContextSummaryFactory.CreateServiceRecordDocumentationFunction(srs_loaded, customer_loaded, costbearer_loaded, sc_loaded, doku);
|
||||
|
||||
return context;
|
||||
}
|
||||
}
|
||||
}
|
||||
75
Service/ServiceUtils/DataContractLoader.cs
Normal file
75
Service/ServiceUtils/DataContractLoader.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BeWo.Service.Core;
|
||||
|
||||
namespace BeWo.Service.ServiceUtils
|
||||
{
|
||||
public static class DataContractLoader
|
||||
{
|
||||
//public static CompactCustomerDC LoadCompactCustomerDC(BeWoRefDC beWoRef)
|
||||
// => LoadDataContact<CompactCustomerDC_Customer, Customer, CompactCustomerDC>(MapperFactory.CompactCustomerDC_Customer, beWoRef);
|
||||
public static CompactSupportConceptDC LoadSupportConceptDC(BeWoRefDC beWoRef)
|
||||
=> LoadDataContact<CompactSupportConceptDC_SupportConcept, SupportConcept, CompactSupportConceptDC>(MapperFactory.CompactSupportConceptDC_SupportConcept, beWoRef);
|
||||
public static IEnumerable<ServiceRecordDC> LoadServiceRecordDCs(IEnumerable<BeWoRefDC> beWoRefs)
|
||||
=> LoadDataContacts<ServiceRecordDC_ServiceRecord, ServiceRecord, ServiceRecordDC>(MapperFactory.ServiceRecordDC_ServiceRecord, beWoRefs);
|
||||
|
||||
private static IEnumerable<TDC> LoadDataContacts<TMapper, TEntity, TDC>(TMapper mapper, IEnumerable<BeWoRefDC> beWoRefs, bool checkVersion = true)
|
||||
where TMapper : AbstractIDCEntityMapper<TEntity, TDC>
|
||||
where TEntity : BeWoEntityBase, new()
|
||||
where TDC : class, new()
|
||||
{
|
||||
var entities = LoadEntitiesByRef<TEntity>(beWoRefs, checkVersion);
|
||||
var dcs = mapper.MapToNewDCs(entities);
|
||||
|
||||
return dcs;
|
||||
}
|
||||
|
||||
private static TDC LoadDataContact<TMapper, TEntity, TDC>(TMapper mapper, BeWoRefDC beWoRef, bool checkVersion = true)
|
||||
where TMapper : AbstractIDCEntityMapper<TEntity, TDC>
|
||||
where TEntity : BeWoEntityBase, new()
|
||||
where TDC : class, new()
|
||||
{
|
||||
var entity = LoadEntityByRef<TEntity>(beWoRef, checkVersion);
|
||||
var dc = mapper.MapToNewDC(entity);
|
||||
|
||||
return dc;
|
||||
}
|
||||
|
||||
private static IEnumerable<TEntity> LoadEntitiesByRef<TEntity>(IEnumerable<BeWoRefDC> beWoRefs, bool checkVersion = true)
|
||||
where TEntity : BeWoEntityBase, new()
|
||||
{
|
||||
var tid = GetTableID<TEntity>();
|
||||
var entities = beWoRefs.Select(x => LoadEntityByRef<TEntity>(x, checkVersion));
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
private static TEntity LoadEntityByRef<TEntity>(BeWoRefDC beWoRef, bool checkVersion = true)
|
||||
where TEntity : BeWoEntityBase, new()
|
||||
{
|
||||
var tid = GetTableID<TEntity>();
|
||||
var oid = beWoRef.Oid;
|
||||
var entity = DAOFactory.GenericDAO.LoadByID<TEntity>(oid);
|
||||
|
||||
if (checkVersion)
|
||||
ServiceLogic.ConcurrencyCheck(beWoRef.Version, entity);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
private static TableID GetTableID<TEntity>()
|
||||
where TEntity : BeWoEntityBase, new()
|
||||
{
|
||||
return new TEntity().Tid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1420,6 +1420,11 @@ namespace BS.Shared
|
||||
SupportConceptDetail = 24,
|
||||
}
|
||||
|
||||
public enum AiFunctionType
|
||||
{
|
||||
ServiceRecordDocumentation
|
||||
}
|
||||
|
||||
public enum AiModelSource
|
||||
{
|
||||
openwebui,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
using System.ServiceModel.ComIntegration;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
|
||||
namespace BS.Shared.DataContracts.Feature.AI
|
||||
@@ -21,4 +21,107 @@ namespace BS.Shared.DataContracts.Feature.AI
|
||||
[DataMember] public ActivationTypeId ActivationType { get; set; }
|
||||
[DataMember] public List<AiPromptbausteinTreeDC> Children { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class PredefinedAiPromptbausteine
|
||||
{
|
||||
public AiPromptbausteinTreeDC Zeiterfassung { get; set; }
|
||||
public AiPromptbausteinTreeDC Zeiterfassung_Doku { get; set; }
|
||||
public AiPromptbausteinTreeDC Zeiterfassung_Doku_1 { get; set; }
|
||||
public AiPromptbausteinTreeDC Zeiterfassung_Doku_2 { get; set; }
|
||||
public AiPromptbausteinTreeDC Zeiterfassung_Conversation { get; set; }
|
||||
public AiPromptbausteinTreeDC Zeiterfassung_Conversation_1 { get; set; }
|
||||
public AiPromptbausteinTreeDC Zeiterfassung_Conversation_2 { get; set; }
|
||||
|
||||
public PredefinedAiPromptbausteine()
|
||||
{
|
||||
Zeiterfassung_Conversation_1 = new AiPromptbausteinTreeDC()
|
||||
{
|
||||
Oid = 7,
|
||||
Version = 1,
|
||||
Name = "Problemzusammenfassung",
|
||||
Prompt = "Nenne mir die 3 größten Probleme des Klienten"
|
||||
};
|
||||
|
||||
Zeiterfassung_Conversation_2 = new AiPromptbausteinTreeDC()
|
||||
{
|
||||
Oid = 6,
|
||||
Version = 1,
|
||||
Name = "Zielezusammenfassung",
|
||||
Prompt = "Fasse mir alle erreichten Ziele des Klienten zusammen"
|
||||
};
|
||||
|
||||
Zeiterfassung_Doku_1 = new AiPromptbausteinTreeDC()
|
||||
{
|
||||
Oid = 5,
|
||||
Version = 1,
|
||||
Name = "Vollständiger Text",
|
||||
Prompt = "Erstelle aus dem vorliegenden Text einen fließenden Text."
|
||||
};
|
||||
|
||||
Zeiterfassung_Doku_2 = new AiPromptbausteinTreeDC()
|
||||
{
|
||||
Oid = 4,
|
||||
Version = 1,
|
||||
Name = "Stichpunkte",
|
||||
Prompt = "Übersetze den vorliegenden Text in Stichpunkte"
|
||||
};
|
||||
|
||||
Zeiterfassung_Conversation = new AiPromptbausteinTreeDC()
|
||||
{
|
||||
Oid = 3,
|
||||
Version = 1,
|
||||
Name = "Konversation",
|
||||
Prompt = "Kategorie der Zeiterfassung->Konversation",
|
||||
IsKategorie = true,
|
||||
Children = new List<AiPromptbausteinTreeDC>
|
||||
{
|
||||
Zeiterfassung_Conversation_1,
|
||||
Zeiterfassung_Conversation_2
|
||||
}
|
||||
};
|
||||
|
||||
Zeiterfassung_Doku = new AiPromptbausteinTreeDC()
|
||||
{
|
||||
Oid = 2,
|
||||
Version = 1,
|
||||
Name = "Dokumentation",
|
||||
Prompt = "Kategorie der Zeiterfassung->Dokumentation",
|
||||
IsKategorie = true,
|
||||
Children = new List<AiPromptbausteinTreeDC>
|
||||
{
|
||||
Zeiterfassung_Doku_1,
|
||||
Zeiterfassung_Doku_2
|
||||
}
|
||||
};
|
||||
|
||||
Zeiterfassung = new AiPromptbausteinTreeDC()
|
||||
{
|
||||
Oid = 1,
|
||||
Version = 1,
|
||||
Name = "Zeiterfassung",
|
||||
Prompt = "Kategorie der Zeiterfassung",
|
||||
IsKategorie = true,
|
||||
Children = new List<AiPromptbausteinTreeDC>
|
||||
{
|
||||
Zeiterfassung_Doku,
|
||||
Zeiterfassung_Conversation,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public IEnumerable<AiPromptbausteinTreeDC> GetFullPromptbausteineTree()
|
||||
{
|
||||
return new List<AiPromptbausteinTreeDC> { Zeiterfassung };
|
||||
}
|
||||
|
||||
public IEnumerable<AiPromptbausteinTreeDC> GetAllPromptbausteine()
|
||||
{
|
||||
return new List<AiPromptbausteinTreeDC>()
|
||||
{
|
||||
Zeiterfassung, Zeiterfassung_Conversation, Zeiterfassung_Conversation_1, Zeiterfassung_Conversation_2,
|
||||
Zeiterfassung_Doku, Zeiterfassung_Doku_1, Zeiterfassung_Doku_2
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,17 @@ namespace BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords
|
||||
[DataContract]
|
||||
public class AiFunctionDocRequest
|
||||
{
|
||||
[DataMember]
|
||||
public BeWoRefDC AiPromptbaustein { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public BeWoRefDC SupportConcept { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public BeWoRefDC AiPromptbaustein { get; set; }
|
||||
public BeWoRefDC CostBearer { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public IEnumerable<BeWoRefDC> ServiceRecords { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string Dokumentation { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user