This commit is contained in:
2025-07-25 14:27:49 +02:00
parent 89b9c22b99
commit e286cb4109
54 changed files with 1594 additions and 579 deletions

90
AICore/AICore.csproj Normal file
View File

@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{69D70CA9-0DF9-419E-BFAF-F4539F129BD9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AICore</RootNamespace>
<AssemblyName>BeWo.Features.AICore</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=9.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.9.0.2\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.IO.Pipelines, Version=9.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Pipelines.9.0.2\lib\net462\System.IO.Pipelines.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=9.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.9.0.2\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=9.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.9.0.2\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Context\Core\ContextEntryMapperFactory.cs" />
<Compile Include="Context\Entry\BaseContextEntry.cs" />
<Compile Include="Context\EntryMapper\BaseContextEntryMapper.cs" />
<Compile Include="Context\Core\ContextSummaryFactory.cs" />
<Compile Include="Context\Summary\BaseContextSummary.cs" />
<Compile Include="Prompt\Core\AiUtils.cs" />
<Compile Include="Prompt\Factories\BaseAiPromptFactory.cs" />
<Compile Include="Prompt\Factories\JsonAiPromptFactory.cs" />
<Compile Include="Prompt\Models\AiConversationContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Prompt\SystemPrompts\system_prompt1.txt" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Prompt\SystemPrompts\system_prompt2.txt" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Prompt\SystemPrompts\system_prompt3.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Data\Data.csproj">
<Project>{B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}</Project>
<Name>Data</Name>
</ProjectReference>
<ProjectReference Include="..\ServiceUtils\ServiceUtils.csproj">
<Project>{EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}</Project>
<Name>ServiceUtils</Name>
</ProjectReference>
<ProjectReference Include="..\Shared\Shared.csproj">
<Project>{2f50b83d-a3f0-4ec4-979a-3f9b7e3d8ed4}</Project>
<Name>Shared</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,29 @@
using AICore.Context.Entry;
using AICore.Context.EntryMapper;
using BeWo.Data.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AICore.Context.Core
{
public static class ContextEntryMapperFactory
{
public static CustomerContextEntryMapper CustomerMapper { get; } = new CustomerContextEntryMapper();
public static EmployeeContextEntryMapper EmployeeMapper { get; } = new EmployeeContextEntryMapper();
public static PersonContextEntryMapper PersonMapper { get; } = new PersonContextEntryMapper();
public static OrganisationContextEntryMapper OrganisationMapper { get; } = new OrganisationContextEntryMapper();
public static SupportConceptContextEntryMapper SupportConceptMapper { get; } = new SupportConceptContextEntryMapper();
public static CustomerNavigationContextEntryMapper CustomerNavigationMapper { get; } = new CustomerNavigationContextEntryMapper();
public static EmployeeNavigationContextEntryMapper EmployeeNavigationMapper { get; } = new EmployeeNavigationContextEntryMapper();
public static PersonNavigationContextEntryMapper PersonNavigationMapper { get; } = new PersonNavigationContextEntryMapper();
public static OrganisationNavigationContextEntryMapper OrganisationNavigationMapper { get; } = new OrganisationNavigationContextEntryMapper();
public static SupportConceptNavigationContextEntryMapper SupportConceptNavigationMapper { get; } = new SupportConceptNavigationContextEntryMapper();
public static ServiceRecordContextEntryMapper ServiceRecordMapper { get; } = new ServiceRecordContextEntryMapper();
public static BaseContextEntryMapper<Customer, CustomerNavigationContextEntry> ServiceRecordCustomerMapper { get; } = new CustomerNavigationContextEntryMapper();
}
}

View File

@@ -0,0 +1,109 @@
using AICore.Context.Core;
using AICore.Context.Entry;
using AICore.Context.EntryMapper;
using AICore.Context.Summary;
using BeWo.Data.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AICore.Context.SummaryMapper
{
public static class ContextSummaryFactory
{
public static CustomerDetailContextSummary CreateCustomerDetailContextSummary(Customer customer)
{
var entry = ContextEntryMapperFactory.CustomerMapper.MapToNewContext(customer);
return new CustomerDetailContextSummary(entry);
}
public static EmployeeDetailContextSummary CreateEmployeeDetailContextSummary(Employee employee)
{
var entry = ContextEntryMapperFactory.EmployeeMapper.MapToNewContext(employee);
return new EmployeeDetailContextSummary(entry);
}
public static PersonDetailContextSummary CreatePersonDetailContextSummary(Person person)
{
var entry = ContextEntryMapperFactory.PersonMapper.MapToNewContext(person);
return new PersonDetailContextSummary(entry);
}
public static OrganisationDetailContextSummary CreateOrganisationDetailContextSummary(Organisation organisation)
{
var entry = ContextEntryMapperFactory.OrganisationMapper.MapToNewContext(organisation);
return new OrganisationDetailContextSummary(entry);
}
public static SupportConceptDetailContextSummary CreateSupportConceptDetailContextSummary(SupportConcept supportConcept)
{
var entry = ContextEntryMapperFactory.SupportConceptMapper.MapToNewContext(supportConcept);
return new SupportConceptDetailContextSummary(entry);
}
public static CustomerNavigationContextSummary CreateCustomerNavigationContextSummary(IEnumerable<Customer> customer)
{
var entry = ContextEntryMapperFactory.CustomerNavigationMapper.MapToNewContexts(customer);
return new CustomerNavigationContextSummary(entry);
}
public static EmployeeNavigationContextSummary CreateEmployeeNavigationContextSummary(IEnumerable<Employee> employee)
{
var entry = ContextEntryMapperFactory.EmployeeNavigationMapper.MapToNewContexts(employee);
return new EmployeeNavigationContextSummary(entry);
}
public static PersonNavigationContextSummary CreatePersonNavigationContextSummary(IEnumerable<Person >person)
{
var entry = ContextEntryMapperFactory.PersonNavigationMapper.MapToNewContexts(person);
return new PersonNavigationContextSummary(entry);
}
public static OrganisationNavigationContextSummary CreateOrganisationNavigationContextSummary(IEnumerable<Organisation >organisation)
{
var entry = ContextEntryMapperFactory.OrganisationNavigationMapper.MapToNewContexts(organisation);
return new OrganisationNavigationContextSummary(entry);
}
public static SupportConceptNavigationContextSummary CreateSupportConceptNavigationContextSummary(IEnumerable<SupportConcept> supportConcept)
{
var entry = ContextEntryMapperFactory.SupportConceptNavigationMapper.MapToNewContexts(supportConcept);
return new SupportConceptNavigationContextSummary(entry);
}
public static ServiceRecordNavigationContextSummary CreateServiceRecordNavigationContextSummary(IEnumerable<ServiceRecord> serviceRecords, Customer customer, string costBearer, string supportConcept)
{
var entries = ContextEntryMapperFactory.ServiceRecordMapper.MapToNewContexts(serviceRecords);
var customer_entry = ContextEntryMapperFactory.ServiceRecordCustomerMapper.MapToNewContext(customer);
return new ServiceRecordNavigationContextSummary(entries, customer_entry, costBearer, supportConcept);
}
public class ServiceRecordNavigationContextSummary : NavigationContextSummary<ServiceRecordContextEntry>
{
public CustomerNavigationContextEntry Customer { get; set; }
public string CostBearer { get; set; }
public string SupportConcept { get; set; }
public ServiceRecordNavigationContextSummary(IEnumerable<ServiceRecordContextEntry> serviceRecords, CustomerNavigationContextEntry customer, string costBearer, string supportConcept)
: base(serviceRecords)
{
Customer = customer;
CostBearer = costBearer;
SupportConcept = supportConcept;
}
}
}
}

View File

@@ -0,0 +1,131 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts.Compact;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace AICore.Context.Entry
{
public abstract class BaseContextEntry
{
}
public abstract class DetailContextEntry : BaseContextEntry
{
}
public class CustomerDetailContextEntry : DetailContextEntry
{
}
public class EmployeeDetailContextEntry : DetailContextEntry
{
}
public class PersonDetailContextEntry : DetailContextEntry
{
}
public class OrganisationDetailContextEntry : DetailContextEntry
{
}
public class SupportConceptDetailContextEntry : DetailContextEntry
{
}
public abstract class NavigationContextEntry : BaseContextEntry
{
}
public class CustomerNavigationContextEntry : NavigationContextEntry
{
[JsonPropertyName("Adresse")]
public string AddressString { get; set; }
[JsonPropertyName("Alias")]
public string CustomerAlias { get; set; }
[JsonPropertyName("Klient-ID")]
public long CustomerOid { get; set; }
[JsonPropertyName("Geburtstag")]
public string DateOfBirthString { get; set; }
[JsonPropertyName("EigenkapitalBeitrag")]
public decimal EquityContribution { get; set; }
[JsonPropertyName("Name")]
public string EquityConFullNametribution { get; set; }
[JsonPropertyName("Rechnungsadresse")]
public string InvoiceAddressString { get; set; }
}
public class EmployeeNavigationContextEntry : NavigationContextEntry {
[JsonPropertyName("Mitarbeiter-ID")]
public long EmployeeOid { get; set; }
[JsonPropertyName("Personalnummer")]
public string PersonnelNumber { get; set; }
[JsonPropertyName("Name")]
public string FirstNameLastName { get; set; }
}
public class PersonNavigationContextEntry : NavigationContextEntry {
public string AddressString { get; set; }
public DateTime Birthday { get; set; }
public long CustomerOid { get; set; }
public long EmployeeOid { get; set; }
public string FullName { get; set; }
public string Geschlecht { get; set; }
public string Function { get; set; }
}
public class OrganisationNavigationContextEntry : NavigationContextEntry {
public long OrganisationOid { get; set; }
public string Name { get; set; }
public string Name2 { get; set; }
public string DebitorNumber { get; set; }
public string BusinessPartnerId { get; set; }
public string AddressString { get; set; }
public string IKDatenannahmestelle { get; set; }
public string IKKostentrager { get; set; }
public string IKKrankenkasse { get; set; }
}
public class SupportConceptNavigationContextEntry : NavigationContextEntry {
public long SupportConceptOid { get; set; }
public string AddressString { get; set; }
public string AllCostBearerNames { get; set; }
public object CostBearer { get; set; }
public string CostBearerDetailStrings { get; set; }
public long CustomerOid { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
public class ServiceRecordContextEntry : NavigationContextEntry
{
public string ServiceRecordOid { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public decimal DurationInStunden { get; set; }
public string CategoryName { get; set; }
public string Name { get; set; }
public string Notice { get; set; }
public decimal DistanceInMeter { get; set; }
public DateTime InsertedOn { get; set; }
public decimal Betrag { get; set; }
public object InsUser { get; set; }
public object Employee { get; set; }
}
}

View File

@@ -0,0 +1,146 @@
using AICore.Context.Entry;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
using System;
using System.Collections.Generic;
using System.Linq;
namespace AICore.Context.EntryMapper
{
public abstract class BaseContextEntryMapper<TObject, TContext>
where TObject : class, new() where TContext : BaseContextEntry, new()
{
public virtual TContext MapToNewContext(TObject pObject)
{
return MergeWithObject(pObject, CreateNewContext());
}
public virtual TContext CreateNewContext()
{
return new TContext();
}
public virtual IEnumerable<TContext> MapToNewContexts(IEnumerable<TObject> pObjects)
{
if(pObjects is null || !pObjects.Any())
return Enumerable.Empty<TContext>();
return pObjects.Select(MapToNewContext);
}
public abstract TContext MergeWithObject(TObject pDataContract, TContext pContext);
}
public class CustomerContextEntryMapper : BaseContextEntryMapper<Customer, CustomerDetailContextEntry>
{
public override CustomerDetailContextEntry MergeWithObject(Customer pObject, CustomerDetailContextEntry pContext)
{
throw new NotImplementedException();
}
}
public class EmployeeContextEntryMapper : BaseContextEntryMapper<Employee, EmployeeDetailContextEntry>
{
public override EmployeeDetailContextEntry MergeWithObject(Employee pObject, EmployeeDetailContextEntry pContext)
{
throw new NotImplementedException();
}
}
public class PersonContextEntryMapper : BaseContextEntryMapper<Person, PersonDetailContextEntry>
{
public override PersonDetailContextEntry MergeWithObject(Person pObject, PersonDetailContextEntry pContext)
{
throw new NotImplementedException();
}
}
public class OrganisationContextEntryMapper : BaseContextEntryMapper<Organisation, OrganisationDetailContextEntry>
{
public override OrganisationDetailContextEntry MergeWithObject(Organisation pObject, OrganisationDetailContextEntry pContext)
{
throw new NotImplementedException();
}
}
public class SupportConceptContextEntryMapper : BaseContextEntryMapper<SupportConcept, SupportConceptDetailContextEntry>
{
public override SupportConceptDetailContextEntry MergeWithObject(SupportConcept pObject, SupportConceptDetailContextEntry pContext)
{
throw new NotImplementedException();
}
}
public class CustomerNavigationContextEntryMapper : BaseContextEntryMapper<Customer, CustomerNavigationContextEntry>
{
public override CustomerNavigationContextEntry MergeWithObject(Customer pObject, CustomerNavigationContextEntry pContext)
{
throw new NotImplementedException();
}
}
public class EmployeeNavigationContextEntryMapper : BaseContextEntryMapper<Employee, EmployeeNavigationContextEntry>
{
public override EmployeeNavigationContextEntry MergeWithObject(Employee pObject, EmployeeNavigationContextEntry pContext)
{
throw new NotImplementedException();
}
}
public class PersonNavigationContextEntryMapper : BaseContextEntryMapper<Person, PersonNavigationContextEntry>
{
public override PersonNavigationContextEntry MergeWithObject(Person pObject, PersonNavigationContextEntry pContext)
{
throw new NotImplementedException();
}
}
public class OrganisationNavigationContextEntryMapper : BaseContextEntryMapper<Organisation, OrganisationNavigationContextEntry>
{
public override OrganisationNavigationContextEntry MergeWithObject(Organisation pObject, OrganisationNavigationContextEntry pContext)
{
throw new NotImplementedException();
}
}
public class SupportConceptNavigationContextEntryMapper : BaseContextEntryMapper<SupportConcept, SupportConceptNavigationContextEntry>
{
public override SupportConceptNavigationContextEntry MergeWithObject(SupportConcept pObject, SupportConceptNavigationContextEntry pContext)
{
throw new NotImplementedException();
}
}
public class ServiceRecordContextEntryMapper : BaseContextEntryMapper<ServiceRecord, ServiceRecordContextEntry>
{
public override ServiceRecordContextEntry MergeWithObject(ServiceRecord pObject, ServiceRecordContextEntry pContext)
{
throw new NotImplementedException();
}
//public override Dictionary<string, object> ToJsonDictionary(ServiceRecordDC service_record)
//{
// var record_dict = new Dictionary<string, object>
// {
// { "Zeiteintrag-ID", service_record.ServiceRecordOid},
// { "Startdatum", service_record.Start },
// { "Enddatum", service_record.End },
// { "Dauer in Stunden", service_record.DurationInStunden },
// { "Leistungskategorie", service_record.ServiceDescription.Category.Name },
// { "Leistungsbeschreibung", service_record.ServiceDescription.Name },
// { "Dokumentation", service_record.Notice
// + "\n" + service_record.Notice2
// + "\n" + service_record.Notice3
// + "\n" + service_record.Notice4
// + "\n" + service_record.Notice5},
// { "Distanze in Meter", service_record.DistanceInMeter ?? 0 },
// { "Eingetragen am", service_record.InsertedOn },
// { "Betrag", service_record.Betrag },
// { "Eingetragen von", service_record.InsUser },
// { "Mitarbeiter", service_record.Employee }
// };
// return record_dict;
//}
}
}

View File

@@ -0,0 +1,115 @@
using AICore.Context.Entry;
using AICore.Context.EntryMapper;
using BeWo.Data.Entities;
using BS.Shared;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AICore.Context.Summary
{
public abstract class BaseContextSummary
{
}
public abstract class DetailContext<T> : BaseContextSummary where T : DetailContextEntry
{
public T DataContext { get; set; }
protected DetailContext(T dataContext)
{
DataContext = dataContext;
}
}
public abstract class NavigationContextSummary<T> : BaseContextSummary where T : NavigationContextEntry
{
public IEnumerable<T> DataContext { get; set; }
protected NavigationContextSummary(IEnumerable<T> dataContext)
{
DataContext = dataContext;
}
}
public class CustomerDetailContextSummary : DetailContext<CustomerDetailContextEntry>
{
public CustomerDetailContextSummary(CustomerDetailContextEntry customer) : base(customer) { }
}
public class EmployeeDetailContextSummary : DetailContext<EmployeeDetailContextEntry>
{
public EmployeeDetailContextSummary(EmployeeDetailContextEntry employee) : base(employee) { }
}
public class PersonDetailContextSummary : DetailContext<PersonDetailContextEntry>
{
public PersonDetailContextSummary(PersonDetailContextEntry person) : base(person) { }
}
public class OrganisationDetailContextSummary : DetailContext<OrganisationDetailContextEntry>
{
public OrganisationDetailContextSummary(OrganisationDetailContextEntry organisation) : base(organisation) { }
}
public class SupportConceptDetailContextSummary : DetailContext<SupportConceptDetailContextEntry>
{
public SupportConceptDetailContextSummary(SupportConceptDetailContextEntry supportConcept) : base(supportConcept) { }
}
public class CustomerNavigationContextSummary : NavigationContextSummary<CustomerNavigationContextEntry>
{
public CustomerNavigationContextSummary(IEnumerable<CustomerNavigationContextEntry> customers) : base(customers) { }
}
public class EmployeeNavigationContextSummary : NavigationContextSummary<EmployeeNavigationContextEntry>
{
public EmployeeNavigationContextSummary(IEnumerable<EmployeeNavigationContextEntry> employee) : base(employee) { }
}
public class PersonNavigationContextSummary : NavigationContextSummary<PersonNavigationContextEntry>
{
public PersonNavigationContextSummary(IEnumerable<PersonNavigationContextEntry> person) : base(person) { }
}
public class OrganisationNavigationContextSummary : NavigationContextSummary<OrganisationNavigationContextEntry>
{
public OrganisationNavigationContextSummary(IEnumerable<OrganisationNavigationContextEntry> organisation) : base(organisation) { }
}
public class SupportConceptNavigationContextSummary : NavigationContextSummary<SupportConceptNavigationContextEntry>
{
public SupportConceptNavigationContextSummary(IEnumerable<SupportConceptNavigationContextEntry> supportConcept) : base(supportConcept) { }
}
public class ServiceRecordNavigationContextSummary : NavigationContextSummary<ServiceRecordContextEntry>
{
public CustomerNavigationContextEntry Customer { get; set; }
public string CostBearer { get; set; }
public string SupportConcept { get; set; }
public ServiceRecordNavigationContextSummary(List<ServiceRecordContextEntry> serviceRecords, CustomerNavigationContextEntry customer, string costBearer, string supportConcept)
: base(serviceRecords)
{
Customer = customer;
CostBearer = costBearer;
SupportConcept = supportConcept;
}
//var customer = LoadEntity(bewoobjects, TableID.Customer, MapperFactory.CompactCustomerDC_Customer);
//var costbearer = LoadProperty(bewoobjects, TableID.CostBearer, MapperFactory.CompactOrganisationDC_Organisation, dc => dc.Name);
//var supportconcept = LoadProperty(bewoobjects, TableID.SupportConcept, MapperFactory.CompactSupportConceptDC_SupportConcept, dc => $"{dc.StartDate?.Date} - {dc.EndDate?.Date}");
//var records = LoadEntities(bewoobjects, TableID.ServiceRecord, MapperFactory.ServiceRecordDC_ServiceRecord);
//var result = new Dictionary<TableID, object>
// {
// { TableID.ServiceRecord, records },
// { TableID.Customer, customer },
// { TableID.CostBearer, costbearer },
// { TableID.SupportConcept, supportconcept }
// };
// return result;
}
}

View File

@@ -0,0 +1,16 @@
using BS.Shared;
using BS.Shared.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AICore.Prompt.Core
{
public static class AiUtils
{
}
}

View File

@@ -0,0 +1,306 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using AICore.Context.Summary;
using AICore.Context.SummaryMapper;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.ServiceUtils.Core;
using BS.Shared;
using BS.Shared.Exceptions;
using BS.Shared.Translation;
namespace AICore.Prompt.Factories
{
public abstract class BaseAiPromptFactory
{
public string CreateSystemInstructions(AiContextType uicontext, Dictionary<TableID, long[]> bewoobjects)
{
var sb = new StringBuilder();
sb.AppendLine(getCustomSystemPrompt());
sb.AppendLine($"Ich befinde mich aktuell in der \"{Translator.Translate(uicontext)}\" meiner Anwendung.");
sb.AppendLine("Es ist kein Filter gesetzt.");
if (bewoobjects is null || bewoobjects.Count == 0)
{
sb.AppendLine("Dir wurden keine Daten bereitgestellt.");
}
else
{
sb.AppendLine("Du erhälst folgendes:");
var parsed = LoadContext(uicontext, bewoobjects);
sb.AppendLine(parsed);
}
return sb.ToString();
}
private string LoadContext(AiContextType uicontext, Dictionary<TableID, long[]> bewoobjects)
{
var context = GetContext(uicontext, bewoobjects);
var parsed = Parse(uicontext, null);
return parsed;
}
protected virtual string Parse(AiContextType uicontext, Dictionary<TableID, object> data)
{
throw new NotImplementedException();
}
protected BaseContextSummary GetContext(AiContextType uicontext, Dictionary<TableID, long[]> bewoobjects)
{
switch (uicontext)
{
case AiContextType.SupportConcept:
case AiContextType.Customer:
case AiContextType.Person:
case AiContextType.Employee:
case AiContextType.Organisation:
return GetNavigationContext(uicontext, bewoobjects);
case AiContextType.ServiceRecord:
return GetServiceRecordsContext(bewoobjects);
case AiContextType.CustomerSingle:
case AiContextType.PersonSingle:
case AiContextType.EmployeeSingle:
return GetSingleContext(uicontext, bewoobjects);
default:
break;
}
throw BeWoNotImplementedException.CreateFromEnum(uicontext);
}
private BaseContextSummary GetNavigationContext(AiContextType uicontext, Dictionary<TableID, long[]> bewoobjects)
{
switch (uicontext)
{
case AiContextType.SupportConcept:
return new SupportConceptNavigationContextSummary(LoadEntities<SupportConcept>(bewoobjects, TableID.SupportConcept));
case AiContextType.Customer:
return new CustomerNavigationContextSummary(LoadEntities<Customer>(bewoobjects, TableID.Customer));
case AiContextType.Person:
return new PersonNavigationContextSummary(LoadEntities<Person>(bewoobjects, TableID.Person));
case AiContextType.Employee:
return new EmployeeNavigationContextSummary(LoadEntities<Employee>(bewoobjects, TableID.Employee));
case AiContextType.Organisation:
return new OrganisationNavigationContextSummary(LoadEntities<Organisation>(bewoobjects, TableID.Organisation));
}
throw BeWoNotImplementedException.CreateFromEnum(uicontext);
}
private BaseContextSummary GetServiceRecordsContext(Dictionary<TableID, long[]> bewoobjects)
{
var context = new ServiceRecordNavigationContext()
}
private BaseContextSummary GetSingleContext(AiContextType uicontext, Dictionary<TableID, long[]> bewoobjects)
{
switch (uicontext)
{
case AiContextType.CustomerSingle:
return new CustomerDetailContextSummary(LoadEntity<Customer>(bewoobjects, TableID.Customer));
case AiContextType.PersonSingle:
return new PersonDetailContextSummary(LoadEntity<Person>(bewoobjects, TableID.Person));
case AiContextType.EmployeeSingle:
return new EmployeeDetailContextSummary(LoadEntity<Employee>(bewoobjects, TableID.Employee));
default:
break;
}
throw BeWoNotImplementedException.CreateFromEnum(uicontext);
}
public Dictionary<TableID, object> LoadContext(int uicontext, Dictionary<TableID, long[]> bewoobjects)
{
var result = new Dictionary<TableID, object>();
switch (uicontext)
{
case 0: return LoadNavigationContext(TableID.SupportConcept, bewoobjects);
case 1: return LoadNavigationContext(TableID.Customer, bewoobjects);
case 2: return LoadNavigationContext(TableID.Person, bewoobjects);
case 3: return LoadNavigationContext(TableID.Employee, bewoobjects);
case 4: return LoadNavigationContext(TableID.Organisation, bewoobjects);
//case 5: return "Team Navigation";
//case 6: return "Dokumente Navigation";
//case 7: return "Benutzer Navigation";
//case 8: return "Benutzergruppe Navigation";
//case 9: return "Bericht Navigation";
//case 10: return "Planer Navigation";
//case 11: return "Wohnheim Navigation";
//case 12: return "Vertretungen Navigation";
//case 13: return "Kunden-Team Navigation";
//case 14: return "Terminplanung Navigation";
//case 15: return "Finanz Navigation";
//case 16: return "Verwaltung Navigation";
//case 17: return "KI-Gesprächs Navigation";
//case 18: return "KI-Gesprächs Popup Navigation";
case 19: return LoadServiceRecordsContext(bewoobjects);
case 20: return LoadSingleContext(TableID.Customer, bewoobjects);
//case 21: return "Person Einzelansicht Navigation";
//case 22: return "Mitarbeiter Einzelansicht Navigation";
default:
throw new NotImplementedException($"UI Kontext {uicontext} ist nicht implementiert.");
//Alternativ könnte man auch einen Standard-String zurückgeben,
//z.B. return "Unbekannter UI-Kontext";
}
}
private Dictionary<TableID, object> LoadNavigationContext(TableID tableid, Dictionary<TableID, long[]> bewoobjects)
{
IList<Dictionary<string, object>> entities;
switch (tableid)
{
case TableID.Person:
entities = LoadEntities(bewoobjects, tableid, MapperFactory.CompactPersonDC_Person);
break;
case TableID.Customer:
entities = LoadEntities(bewoobjects, tableid, MapperFactory.CompactCustomerDC_Customer);
break;
case TableID.Employee:
entities = LoadEntities(bewoobjects, tableid, MapperFactory.CompactEmployeeDC_Employee);
break;
case TableID.SupportConcept:
entities = LoadEntities(bewoobjects, tableid, MapperFactory.CompactSupportConceptDC_SupportConcept);
break;
case TableID.Organisation:
entities = LoadEntities(bewoobjects, tableid, MapperFactory.CompactOrganisationDC_Organisation, (entity, dc) =>
{
if (entity.Address != null)
{
dc.AddressLine1 = entity.Address.AddressLine1;
dc.Street = entity.Address.Street;
dc.PostalCode = entity.Address.PostalCode;
dc.Town = entity.Address.Town;
}
});
break;
default:
throw new NotImplementedException($"TableID {tableid} not implemented as navigation context");
}
var result = new Dictionary<TableID, List<Dictionary<string, object>>>
{
{ tableid, entities.ToList() }
};
return result;
}
private Dictionary<TableID, object> LoadSingleContext(TableID tableid, Dictionary<TableID, long[]> bewoobjects)
{
var result = new Dictionary<TableID, Dictionary<string, object>>();
Dictionary<string, object> entity;
switch (tableid)
{
case TableID.Person:
entity = LoadEntity(bewoobjects, tableid, MapperFactory.PersonDC_Person);
break;
case TableID.Customer:
entity = LoadEntity(bewoobjects, tableid, MapperFactory.CustomerDC_Customer);
break;
case TableID.Employee:
entity = LoadEntity(bewoobjects, tableid, MapperFactory.EmployeeDC_Employee);
break;
case TableID.SupportConcept:
entity = LoadEntity(bewoobjects, tableid, MapperFactory.SupportConceptDC_SupportConcept);
break;
//case TableID.Organisation:
// entity = LoadEntity(bewoobjects, tableid, MapperFactory.OrganisationDC_OrganisationMapper, (entity, dc) =>
// {
// if (entity.Address != null)
// {
// dc.AddressLine1 = entity.Address.AddressLine1;
// dc.Street = entity.Address.Street;
// dc.PostalCode = entity.Address.PostalCode;
// dc.Town = entity.Address.Town;
// }
// });
// break;
default:
throw new NotImplementedException($"TableID {tableid} not implemented as navigation context");
}
return result;
}
private TRet LoadProperty<TEntity, TRet>
(Dictionary<TableID, long[]> bewoobjects, TableID tid, Func<TEntity, TRet> getPropertyFunc)
where TEntity : BeWoEntityBase, new()
{
if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0)
return default;
var entity = DAOFactory.GenericDAO.GetByID<TEntity>(oids[0]);
var property = getPropertyFunc(entity);
return property;
}
private TEntity LoadEntity<TEntity>
(Dictionary<TableID, long[]> bewoobjects, TableID tid)
where TEntity : BeWoEntityBase, new()
{
if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0)
return null;
var entity = DAOFactory.GenericDAO.GetByID<TEntity>(oids[0]);
return entity;
}
private List<TEntity> LoadEntities<TEntity>
(Dictionary<TableID, long[]> bewoobjects, TableID tid)
where TEntity : BeWoEntityBase, new()
{
if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0)
return null;
var entities = DAOFactory.GenericDAO.GetByIDs<TEntity>(oids);
//if(afterLoad != null)
//{
// foreach( var entity in entities)
// {
// afterLoad(entity);
// }
//}
return entities;
}
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");
return File.ReadAllText(path);
}
}
}

View File

@@ -0,0 +1,10 @@
namespace AICore.Prompt.Factories
{
public class JsonAiPromptFactory : BaseAiPromptFactory
{
//protected override string Parse(int uicontext, object data)
//{
//}
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AICore.Prompt.Models
{
public class AiConversationContext
{
public string Name { get; set; }
public Dictionary<string, object> Filter { get; set; }
public AiConversationContext()
{
}
}
}

View File

@@ -10,4 +10,3 @@ WICHTIG:
---
### **Daten**
Du erhälst folgendes:

View File

@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("AICore")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AICore")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("69d70ca9-0df9-419e-bfaf-f4539f129bd9")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

71
AICore/app.config Normal file
View File

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.ObjectPool" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.11.0" newVersion="8.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Xml" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.WebEncoders" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.11.0" newVersion="8.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Composition.AttributedModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Composition.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Composition.TypedParts" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Composition.Hosting" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

42
AICore/packages.config Normal file
View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNetCore.Authentication" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Authentication.Abstractions" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Authentication.Core" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Cryptography.Internal" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.DataProtection" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.DataProtection.Abstractions" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Hosting.Abstractions" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Hosting.Server.Abstractions" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Http" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Http.Abstractions" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Http.Extensions" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Http.Features" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.WebUtilities" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="9.0.2" targetFramework="net472" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="8.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.2" targetFramework="net472" />
<package id="Microsoft.Extensions.Diagnostics.Abstractions" version="8.0.1" targetFramework="net472" />
<package id="Microsoft.Extensions.FileProviders.Abstractions" version="8.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Hosting.Abstractions" version="8.0.1" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="8.0.2" targetFramework="net472" />
<package id="Microsoft.Extensions.ObjectPool" version="8.0.11" targetFramework="net472" />
<package id="Microsoft.Extensions.Options" version="8.0.2" targetFramework="net472" />
<package id="Microsoft.Extensions.Primitives" version="8.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.WebEncoders" version="8.0.11" targetFramework="net472" />
<package id="Microsoft.Net.Http.Headers" version="2.3.0" targetFramework="net472" />
<package id="Microsoft.Win32.Registry" version="4.5.0" targetFramework="net472" />
<package id="System.Buffers" version="4.6.0" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="8.0.1" targetFramework="net472" />
<package id="System.IO.Pipelines" version="9.0.2" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Security.AccessControl" version="4.5.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Xml" version="8.0.2" targetFramework="net472" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="9.0.2" targetFramework="net472" />
<package id="System.Text.Json" version="9.0.2" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>

View File

@@ -61,12 +61,7 @@ namespace BeWo
Finance = 15,
Administration = 16,
AiConversation = 17,
AiConversationPopup = 18,
// Nur für AI Conversation Zuweisung
ServiceRecord = 19,
CustomerSingle = 20,
PersonSingle = 21,
EmployeeSingle = 22,
AiConversationPopup = 18
}
public partial class MainControl

View File

@@ -37,31 +37,14 @@ namespace BeWo.ViewModel
public string Displayname
{
get { return _Displayname; }
set
{
if (!AreDifferent(_Displayname, value))
return;
_Displayname = value;
StoreDirtyInformation(AreDifferent(DataContract.Displayname, value), nameof(Displayname));
FirePropertyChanged(nameof(Displayname));
FirePropertyChanged(nameof(Json));
}
set => SetProperty(ref _Displayname, value, nameof(Displayname), () => DataContract.Displayname);
}
[JsonProperty]
public DateTime Updated
{
get { return _Updated; }
set
{
if (!AreDifferent(Updated, value))
return;
_Updated = value;
StoreDirtyInformation(AreDifferent(DataContract.Updated, value), nameof(Updated));
FirePropertyChanged(nameof(Updated));
}
set => SetProperty(ref _Updated, value, nameof(Updated), () => DataContract.Updated);
}
public AiConversationMessageListVM Messages
@@ -90,6 +73,7 @@ namespace BeWo.ViewModel
public AiModelDC Modell => DataContract.Modell;
public string Context => DataContract.Context;
public Dictionary<TableID, long[]> ContextBeWoObjects => DataContract.ContextBeWoObjects;
public AiDataContextType Context_Type => DataContract.ContextType;
public UIContext UIContext => (UIContext)DataContract.UIContext;
protected override void InitByDataContract(AiConversationDC pDataContract)

View File

@@ -91,7 +91,7 @@ namespace BeWo.ViewModel.ListViewModel
Displayname = "Displayname Megamegalange Deluxe Op 3000",
Messages = messages_dc,
Modell = model,
UIContext = 19,
UIContext = AiContextType.ServiceRecord,
Updated = DateTime.Now,
};
@@ -117,7 +117,7 @@ namespace BeWo.ViewModel.ListViewModel
Created = DateTime.Now,
Displayname = "Dummy Num " + i.ToString(),
Modell = model,
UIContext = 19,
UIContext = AiContextType.ServiceRecord,
Updated = DateTime.Now,
};

View File

@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.33927.289
# Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Client", "Client", "{E7543C39-A44C-40C9-82C9-E7FAA2D9A852}"
EndProject
@@ -43,6 +43,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Translation", "Translation"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TranslationUnitTest", "TranslationUnitTest\TranslationUnitTest.csproj", "{83C43FEC-233D-49EF-BD23-BF842A3EBDF5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Features", "Features", "{830D2912-108B-4946-A3BE-CE4ECD50819F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AICore", "AICore\AICore.csproj", "{69D70CA9-0DF9-419E-BFAF-F4539F129BD9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceUtils", "ServiceUtils\ServiceUtils.csproj", "{EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
@@ -189,6 +195,30 @@ Global
{83C43FEC-233D-49EF-BD23-BF842A3EBDF5}.Release|Any CPU.Build.0 = Release|Any CPU
{83C43FEC-233D-49EF-BD23-BF842A3EBDF5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{83C43FEC-233D-49EF-BD23-BF842A3EBDF5}.Release|Mixed Platforms.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}.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
{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}.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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -207,6 +237,9 @@ Global
{7630915F-DFE4-45A4-A7B1-B6D19B0126C1} = {2F7893AD-34FC-40A2-838A-3D2D8596E9AC}
{B331128C-7E9F-4BDC-B509-A8DAE1B94E5C} = {CCD6B644-49E7-4A11-BD8F-607088A4AC83}
{83C43FEC-233D-49EF-BD23-BF842A3EBDF5} = {B331128C-7E9F-4BDC-B509-A8DAE1B94E5C}
{830D2912-108B-4946-A3BE-CE4ECD50819F} = {FEB0336B-F053-40B6-92DD-7DE56AB9408A}
{69D70CA9-0DF9-419E-BFAF-F4539F129BD9} = {830D2912-108B-4946-A3BE-CE4ECD50819F}
{EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57} = {FEB0336B-F053-40B6-92DD-7DE56AB9408A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5352BE53-F2FD-442F-85A8-4157599AA153}

View File

@@ -23,7 +23,8 @@ namespace BeWo.Data.Entities
public virtual string Context { get; set; }
public virtual long? ApplicationUserOid { get; set; }
public virtual IList<BeWoEntityReference> ContextBeWoObjects { get; set; }
public virtual int UIContext { get; set; }
public virtual AiContextType UIContext { get; set; }
public virtual AiDataContextType ContextType { get; set; }
public virtual IList<AiConversationMessage> Messages { get; set; }
}
}

View File

@@ -17,8 +17,9 @@
<property name="Created"/>
<property name="Updated"/>
<property name="Context"/>
<property name="UIContext"/>
<property name="UIContext" type="BS.Shared.AiContextType, BS.Shared"/>
<property name="ApplicationUserOid"/>
<property name="ContextType" type="BS.Shared.AiDataContextType, BS.Shared"/>
<many-to-one name="Modell"
column="Model"

View File

@@ -3,7 +3,6 @@ using System.IO;
using System.Linq;
using BeWo.Data.Entities;
using BeWo.Service.Core;
using BeWo.Service.Security;
using BS.Shared;

View File

@@ -255,7 +255,7 @@
<add name="AdminSecurityExtension" type="BeWo.Service.ServiceBehavior.AdminSecurityBehaviorExtension, BeWo.Service, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
<add name="AdminHibernateSessionExtension" type="BeWo.Service.ServiceBehavior.AdminHibernateBehaviorExtension, BeWo.Service, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
<add name="JsonErrorExtension" type="BeWo.Service.ServiceBehavior.JsonError.JsonErrorBehaviorExtension, BeWo.Service, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
<add name="WCFErrorExtension" type="BeWo.Service.ServiceBehavior.WCFError.WCFErrorBehaviorExtension, BeWo.Service, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
<add name="WCFErrorExtension" type="BeWo.Service.ServiceBehavior.WCFError.WCFErrorBehaviorExtension, BeWo.Service, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
</system.serviceModel>
@@ -307,11 +307,11 @@
<add key="SendMailModuleGkvSender" value="noreply@bewoplaner.de" />
<add key="SendMailModuleGkvReceiver" value="dakota.exchange@ownsoft.de" />
<add key="OpenWebUIUrl" value="https://owui1.ownsoft.de/"/>
<add key="AiSystemPromptPath" value="C:\BeWoPlaner\AI\systemPrompts\customSystemPrompt.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"/>
<add key="OpenWebUIUrl" value="https://owui1.ownsoft.de/" />
<add key="AiSystemPromptPath" value="C:\BeWoPlaner\AI\systemPrompts\customSystemPrompt.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" />
</appSettings>
<!-- <> <> <> Appsettings <> <> <> -->
<devExpress>
@@ -328,12 +328,76 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Composition.AttributedModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Composition.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Composition.TypedParts" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Composition.Hosting" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.ObjectPool" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.11.0" newVersion="8.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Xml" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.WebEncoders" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.11.0" newVersion="8.0.11.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -1,2 +1,5 @@
ALTER TABLE `aiconfig`
ADD COLUMN `Context_Type` INT NOT NULL DEFAULT 0 AFTER `Max_Gen_Len`;
ALTER TABLE `aiconversation`
ADD COLUMN `ContextType` INT NOT NULL DEFAULT 0 AFTER `Model`;

View File

@@ -12,7 +12,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
@@ -58,6 +58,34 @@
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.ObjectPool" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.11.0" newVersion="8.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Xml" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.WebEncoders" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.11.0" newVersion="8.0.11.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup></configuration>

View File

@@ -12,7 +12,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
@@ -58,6 +58,34 @@
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.ObjectPool" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.11.0" newVersion="8.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Xml" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.WebEncoders" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.11.0" newVersion="8.0.11.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup></configuration>

View File

@@ -26,6 +26,7 @@ namespace BeWo.Service.DCEntityMapper
pDataContract.Context = pEntity.Context;
pDataContract.ContextBeWoObjects = Parse(pEntity.ContextBeWoObjects);
pDataContract.UIContext = pEntity.UIContext;
pDataContract.ContextType = pEntity.ContextType;
if (pEntity.Messages is IList<AiConversationMessage> list && list.Any())
pDataContract.Messages = MapperFactory.AiConversationMessage.MapToNewDCs(list);
@@ -51,6 +52,7 @@ namespace BeWo.Service.DCEntityMapper
pEntity.Context = pDataContract.Context;
pEntity.UIContext = pDataContract.UIContext;
pEntity.ContextBeWoObjects = Parse(pDataContract.ContextBeWoObjects);
pEntity.ContextType = pDataContract.ContextType;
MapperFactory.AiConversationMessage.MergeWithEntitys(pDataContract.Messages, pEntity.Messages);

View File

@@ -68,21 +68,5 @@ namespace BeWo.Service.DCEntityMapper
{
return pDC.CustomerOid == pEntity.Oid;
}
public override Dictionary<string, object> ToJsonDictionary(CompactCustomerDC customer)
{
var record_dict = new Dictionary<string, object>
{
{"Adresse", customer.AddressString},
{"Alias", customer.CustomerAlias},
{"Klient-ID", customer.CustomerOid},
{"Geburtstag", customer.DateOfBirthString},
{"EigenkapitalBeitrag", customer.EquityContribution},
{"Name", customer.FullName},
{"Rechnungsadresse", customer.InvoiceAddressString}
};
return record_dict;
}
}
}

View File

@@ -35,17 +35,5 @@ namespace BeWo.Service.DCEntityMapper
{
return pDC.EmployeeOid == pEntity.Oid;
}
public override Dictionary<string, object> ToJsonDictionary(CompactEmployeeDC pDC)
{
var dict = new Dictionary<string, object>()
{
{"Mitarbeiter-ID", pDC.EmployeeOid },
{"Personalnummer", pDC.PersonnelNumber },
{"Name", pDC.FirstNameLastName },
};
return dict;
}
}
}

View File

@@ -63,23 +63,5 @@ namespace BeWo.Service.DCEntityMapper
// dc.CostRatePeriods = new List<CostRatePeriodDC>();
// return dc;
//}
public override Dictionary<string, object> ToJsonDictionary(CompactOrganisationDC pDC)
{
var jsonObject = new Dictionary<string, object>()
{
{"Organisation-ID", pDC.OrganisationOid },
{"Name", pDC.Name },
{"Abteilung", pDC.Name2 },
{"Kundennummer", pDC.DebitorNumber },
{"Geschäftspartnernummer", pDC.BusinessPartnerId },
{"Adress", pDC.AddressString },
{"IKDatenannahmestelle", pDC.IKDatenannahmestelle },
{"IKKostentrager", pDC.IKKostentrager },
{"IKKrankenkasse", pDC.IKKrankenkasse},
};
return jsonObject;
}
}
}

View File

@@ -60,21 +60,5 @@ namespace BeWo.Service.DCEntityMapper
{
return pDC.PersonOid == pEntity.Oid;
}
public override Dictionary<string, object> ToJsonDictionary(CompactPersonDC pDC)
{
var jsonObject = new Dictionary<string, object>()
{
{"Adresse", pDC.AddressString },
{"Geburtstag", pDC.Birthday },
{"Klient-ID", pDC.CustomerOid },
{"Mitarbeiter-ID", pDC.EmployeeOid },
{"Name", pDC.FullName },
{"Geschlecht", pDC.Geschlecht.ToString() },
{"Funktion", pDC.Function },
};
return jsonObject;
}
}
}

View File

@@ -69,24 +69,5 @@ namespace BeWo.Service.DCEntityMapper
{
return pDC.SupportConceptOid == pEntity.Oid;
}
public override Dictionary<string, object> ToJsonDictionary(CompactSupportConceptDC pDC)
{
var customer = MapperFactory.CompactCustomerDC_Customer.ToJsonDictionary(pDC.Customer);
var jsonObject = new Dictionary<string, object>()
{
{"Hilfeplan-ID", pDC.SupportConceptOid },
{"Adresse", pDC.AddressString },
{"Kostentraegernamen", pDC.AllCostBearerNames},
{"Kostentraeger", pDC.CostBearer },
{"Kostentraeger Details", pDC.CostBearerDetailStrings },
{"Klient", customer },
{"Startdatum", pDC.StartDate },
{"Enddatum", pDC.EndDate }
};
return jsonObject;
}
}
}

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using BeWo.Data.Entities;
using BeWo.Service.Core;
using BS.Shared.DataContracts;

View File

@@ -266,30 +266,5 @@ namespace BeWo.Service.DCEntityMapper
return pDC.ServiceRecordOid == pEntity.Oid;
}
public override Dictionary<string, object> ToJsonDictionary(ServiceRecordDC service_record)
{
var record_dict = new Dictionary<string, object>
{
{ "Zeiteintrag-ID", service_record.ServiceRecordOid},
{ "Startdatum", service_record.Start },
{ "Enddatum", service_record.End },
{ "Dauer in Stunden", service_record.DurationInStunden },
{ "Leistungskategorie", service_record.ServiceDescription.Category.Name },
{ "Leistungsbeschreibung", service_record.ServiceDescription.Name },
{ "Dokumentation", service_record.Notice
+ "\n" + service_record.Notice2
+ "\n" + service_record.Notice3
+ "\n" + service_record.Notice4
+ "\n" + service_record.Notice5},
{ "Distanze in Meter", service_record.DistanceInMeter ?? 0 },
{ "Eingetragen am", service_record.InsertedOn },
{ "Betrag", service_record.Betrag },
{ "Eingetragen von", service_record.InsUser },
{ "Mitarbeiter", service_record.Employee }
};
return record_dict;
}
}
}

View File

@@ -12,7 +12,6 @@ using BS.Shared.Services;
using BeWo.Data;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.Core;
using BeWo.Service.DCEntityMapper;
namespace BeWo.Service.Invoicing

View File

@@ -1,7 +1,6 @@
using BeWo.Data;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.Core;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Plugins;
using BS.Shared.DataContracts;

View File

@@ -7,7 +7,6 @@ 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;

View File

@@ -6,10 +6,10 @@ using System.Linq;
using System.Net;
using System.ServiceModel;
using System.Text;
using AICore.Prompt.Factories;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Data.Security;
using BeWo.Service.AI;
using BeWo.Service.Core;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Invoicing;
@@ -112,15 +112,21 @@ namespace BeWo.Service.Plugins
public AiConversationDC CreateAiConversation(AiConversationDC conversation, long modell_oid)
{
var conv = createAiConversation(conversation.UIContext, conversation.ContextBeWoObjects, modell_oid);
var config = GetAiConfig();
var conv = createAiConversation(conversation.UIContext, conversation.ContextBeWoObjects, modell_oid, config.Context_Type);
var conv_dc = MapperFactory.AiConversation.MapToNewDC(conv);
return conv_dc;
}
public AiConversationDC CreateAiConversationWithMessage(AiConversationDC conversation, long modell_oid, string message)
{
var conv = createAiConversation(conversation.UIContext, conversation.ContextBeWoObjects, modell_oid);
var config = GetAiConfig();
var new_messages = sendNewMessage(conv, message);
var conv = createAiConversation(conversation.UIContext, conversation.ContextBeWoObjects, modell_oid, config.Context_Type);
var new_messages = sendNewMessage(conv, message, config);
var conv_dc = MapperFactory.AiConversation.MapToNewDC(conv);
@@ -265,11 +271,12 @@ namespace BeWo.Service.Plugins
return models;
}
private AiConversation createAiConversation(int uicontext, Dictionary<TableID, long[]> context, long modell_oid)
private AiConversation createAiConversation(int uicontext, Dictionary<TableID, long[]> context, long modell_oid, AiDataContextType context_Type)
{
var current_user = UserRightHelper.GetLoggedInUserWithOid();
var factory = getFactory(context_Type);
var system_prompt = AiPromptFactory.CreateSystemInstructions(uicontext, context);
var system_prompt = factory.CreateSystemInstructions(uicontext, context);
var conv = new AiConversation();
conv.Created = DateTime.Now;
@@ -278,6 +285,7 @@ namespace BeWo.Service.Plugins
conv.Messages = new List<AiConversationMessage>();
conv.Modell = DAOFactory.GenericDAO.LoadByID<AiModel>(modell_oid);
conv.UIContext = uicontext;
conv.ContextType = context_Type;
conv.Updated = DateTime.Now;
conv.ApplicationUserOid = current_user.Oid;
@@ -294,10 +302,19 @@ namespace BeWo.Service.Plugins
return conv;
}
private AiConversationMessageDC[] sendNewMessage(AiConversation conv, string message)
private BaseAiPromptFactory getFactory(AiDataContextType context_Type)
{
if (context_Type == AiDataContextType.json)
return new JsonAiPromptFactory();
throw new NotImplementedException($"AiDataContextType {context_Type} not implemented.");
}
private AiConversationMessageDC[] sendNewMessage(AiConversation conv, string message, AiConfigDC config = null)
{
// Hole Config
var config = GetAiConfig();
if (config == null)
config = GetAiConfig();
var configModelName = config.SelectedModel.ModelName;
// Build Payload
@@ -308,7 +325,7 @@ namespace BeWo.Service.Plugins
};
// Check Token Size
if(!checkTokenSize(conv.Messages, configModelName))
if (!checkTokenSize(conv.Messages, configModelName))
{
throw new Exception();
}

View File

@@ -4,7 +4,6 @@ using System.IO;
using System.Linq;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.Core;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.MessageContracts;
using BS.Shared;

View File

@@ -6,7 +6,6 @@ using BeWo.Data;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.Configuration;
using BeWo.Service.Core;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.MessageContracts;
using BS.Shared;

View File

@@ -6,7 +6,6 @@ using BeWo.Data;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Data.Security;
using BeWo.Service.Core;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.MessageContracts;
using BS.Shared;
@@ -15,7 +14,6 @@ using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
using BS.Shared.Services;
using Utils = BeWo.Service.Core.Utils;
namespace BeWo.Service.Plugins

View File

@@ -556,7 +556,6 @@
<Compile Include="ServiceImplementations\ValueListServiceImp.cs" />
<Compile Include="Configuration\AppSettings.cs" />
<Compile Include="ServiceProxy\OpenWebApiClient.cs" />
<Compile Include="AI\AiPromptFactory.cs" />
<Compile Include="ServiceUtils\DistanceCalculator\AddressRouteManager.cs" />
<Compile Include="ServiceUtils\DistanceCalculator\AddressRouteMatrix.cs" />
<Compile Include="ServiceUtils\DistanceCalculator\GoogleDistanceMatrixAPI.cs" />
@@ -576,6 +575,10 @@
<Compile Include="XAMLInformation\InfoViaXAMLManager.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AICore\AICore.csproj">
<Project>{69D70CA9-0DF9-419E-BFAF-F4539F129BD9}</Project>
<Name>AICore</Name>
</ProjectReference>
<ProjectReference Include="..\Dakota\Dakota.csproj">
<Project>{47331732-dd96-4075-869f-83aa9f3f9937}</Project>
<Name>Dakota</Name>
@@ -620,15 +623,6 @@
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="AI\system_prompt1.txt" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="AI\system_prompt2.txt" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="AI\system_prompt3.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -1,94 +1,30 @@
using BeWo.Data;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Data.Security;
using BeWo.Service.AI;
using BeWo.Service.Core;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Plugins;
using BeWo.Service.Plugins;
using BeWo.Service.ServiceContracts;
using BeWo.Service.ServiceProxy;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Feature.AI;
using BS.Shared.Exceptions;
using BS.Shared.Extensions;
using DevExpress.Drawing.Internal.Interop;
using DevExpress.Entity.Model.Metadata;
using DevExpress.XtraCharts.Native;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Security.Cryptography;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Interop;
namespace BeWo.Service.ServiceImplementations
{
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
public class AiEnhancedServiceImp : IAiEnhancedService
{
public AiConfigDC GetAiConfig()
{
var p = PluginLoader.FindClass<AiService2>();
return p.GetAiConfig();
}
public AiConfigDC UpdateAiConfig(AiConfigDC toUpdate)
{
var p = PluginLoader.FindClass<AiService2>();
return p.UpdateAiConfig(toUpdate);
}
public AiConfigDC GetAiConfig() => GetAiService().GetAiConfig();
public AiConfigDC UpdateAiConfig(AiConfigDC toUpdate) => GetAiService().UpdateAiConfig(toUpdate);
public IEnumerable<AiModelDC> GetAiModels() => GetAiService().GetAiModels();
public IEnumerable<AiConversationDC> GetAiConversations(int uicontext, long? oid) => GetAiService().GetAiConversations(uicontext, oid);
public AiConversationDC CreateAiConversation(AiConversationDC conversation, long modell_oid) => GetAiService().CreateAiConversation(conversation, modell_oid);
public AiConversationDC CreateAiConversationWithMessage(AiConversationDC conversation, long modell_oid, string message) => GetAiService().CreateAiConversationWithMessage(conversation, modell_oid, message);
public AiConversationDC CloneAiConversation(long conversation_oid, long? last_message_oid) => GetAiService().CloneAiConversation(conversation_oid, last_message_oid);
public long UpdateAiConversationDisplayname(long oid, long version, string displayname) => GetAiService().UpdateAiConversationDisplayname(oid, version, displayname);
public void DeleteAiConversation(long conversation_oid) => GetAiService().DeleteAiConversation(conversation_oid);
public IEnumerable<AiModelDC> GetAiModels()
public AiConversationMessageDC[] SendNewMessage(long conversation, string message) => GetAiService().SendNewMessage(conversation, message);
private AiService2 GetAiService()
{
var p = PluginLoader.FindClass<AiService2>();
return p.GetAiModels();
}
public IEnumerable<AiConversationDC> GetAiConversations(int uicontext, long? oid)
{
var p = PluginLoader.FindClass<AiService2>();
return p.GetAiConversations(uicontext, oid);
}
public AiConversationDC CreateAiConversation(AiConversationDC conversation, long modell_oid)
{
var p = PluginLoader.FindClass<AiService2>();
return p.CreateAiConversation(conversation, modell_oid);
}
public AiConversationDC CreateAiConversationWithMessage(AiConversationDC conversation, long modell_oid, string message)
{
var p = PluginLoader.FindClass<AiService2>();
return p.CreateAiConversationWithMessage(conversation, modell_oid, message);
}
public AiConversationDC CloneAiConversation(long conversation_oid, long? last_message_oid)
{
var p = PluginLoader.FindClass<AiService2>();
return p.CloneAiConversation(conversation_oid, last_message_oid);
}
public long UpdateAiConversationDisplayname(long oid, long version, string displayname)
{
var p = PluginLoader.FindClass<AiService2>();
return p.UpdateAiConversationDisplayname(oid, version, displayname);
}
public void DeleteAiConversation(long conversation_oid)
{
var p = PluginLoader.FindClass<AiService2>();
p.DeleteAiConversation(conversation_oid);
}
public AiConversationMessageDC[] SendNewMessage(long conversation, string message)
{
var p = PluginLoader.FindClass<AiService2>();
return p.SendNewMessage(conversation, message);
var plugin = PluginLoader.FindClass<AiService2>();
return plugin;
}
}
}

View File

@@ -1,311 +0,0 @@
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.Core;
using BeWo.Service.DCEntityMapper;
using BS.Shared;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using DevExpress.PivotGrid.OLAP.Mdx;
using DevExpress.XtraRichEdit.Commands;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace BeWo.Service.AI
{
public static class AiPromptFactory
{
public static string CreateSystemInstructions(int uicontext, Dictionary<TableID, long[]> bewoobjects)
{
if (bewoobjects is null || bewoobjects.Count == 0)
return getCustomSystemPrompt();
//return getSystemPrompt(3);
var data = getContextData(uicontext, bewoobjects);
var text = JsonConvert.SerializeObject(data);
var system_prompt = getCustomSystemPrompt();
//var system_prompt = getSystemPrompt(2);
var result = system_prompt + text;
return result;
}
/// <summary>
/// SupportConcept = 0,
/// Customer = 1,
/// Person = 2,
/// Employee = 3,
/// Organisation = 4,
/// Team = 5,
/// Dokumente = 6,
/// User = 7,
/// UserGroup = 8,
/// Report = 9,
/// Scheduler = 10,
/// Wohnheim = 11,
/// Vertretungen = 12,
/// CustomerTeam = 13,
/// Scheduling = 14,
/// Finance = 15,
/// Administration = 16,
/// AiConversation = 17,
/// AiConversationPopup = 18,
/// // Nur für AI Conversation Zuweisung
/// ServiceRecord = 19,
/// CustomerSingle = 20,
/// PersonSingle = 21,
/// EmployeeSingle = 22,
/// </summary>
/// <param name="uicontext"></param>
/// <param name="bewoobjects"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
private static Dictionary<string, object> getContextData(int uicontext, Dictionary<TableID, long[]> bewoobjects)
{
switch (uicontext)
{
case 0: return createSupportConceptNavigationContext(bewoobjects);
case 1: return createCustomerNavigationContext(bewoobjects);
case 2: return createPersonNavigationContext(bewoobjects);
case 3: return createEmployeeNavigationContext(bewoobjects);
case 4: return createOrganisationNavigationContext(bewoobjects);
case 5: break;
case 6: break;
case 7: break;
case 8: break;
case 9: break;
case 10: break;
case 11: break;
case 12: break;
case 13: break;
case 14: break;
case 15: break;
case 16: break;
case 17: break;
case 18: break;
case 19: return createServiceRecordContext(bewoobjects);
case 20: return createCustomerContext(bewoobjects);
case 21: break;
case 22: break;
}
throw new NotImplementedException("UI Context unknown");
}
#region Navigation
private static Dictionary<string, object> createSupportConceptNavigationContext(Dictionary<TableID, long[]> bewoobjects)
{
var supports = LoadEntities(bewoobjects, TableID.SupportConcept, MapperFactory.CompactSupportConceptDC_SupportConcept);
var dict = new Dictionary<string, object>
{
{ "Aktuelle Ansicht", "Hilfeplan Navigation" },
{ "Aktueller Ansichtsfilter", "Funktion noch nicht verfügbar" },
{ "Hilfeplanliste", (object)supports ?? "keine Hilfepläne sichtbar" }
};
return dict;
}
private static Dictionary<string, object> createCustomerNavigationContext(Dictionary<TableID, long[]> bewoobjects)
{
var klienten = LoadEntities(bewoobjects, TableID.Customer, MapperFactory.CompactCustomerDC_Customer);
var dict = new Dictionary<string, object>
{
{ "Aktuelle Ansicht", "Klienten Navigation" },
{ "Aktueller Ansichtsfilter", "Funktion noch nicht verfügbar" },
{ "Klientenliste", (object)klienten ?? "keine Klienten sichtbar" }
};
return dict;
}
private static Dictionary<string, object> createPersonNavigationContext(Dictionary<TableID, long[]> bewoobjects)
{
var personen = LoadEntities(bewoobjects, TableID.Person, MapperFactory.CompactPersonDC_Person);
var dict = new Dictionary<string, object>
{
{ "Aktuelle Ansicht", "Personen Navigation" },
{ "Aktueller Ansichtsfilter", "Funktion noch nicht verfügbar" },
{ "Personenliste", (object)personen ?? "keine Personen sichtbar" }
};
return dict;
}
private static Dictionary<string, object> createEmployeeNavigationContext(Dictionary<TableID, long[]> bewoobjects)
{
var mitarbeiter = LoadEntities(bewoobjects, TableID.Employee, MapperFactory.CompactEmployeeDC_Employee);
var dict = new Dictionary<string, object>
{
{ "Aktuelle Ansicht", "Mitarbeiter Navigation" },
{ "Aktueller Ansichtsfilter", "Funktion noch nicht verfügbar" },
{ "Mitarbeiterliste", (object)mitarbeiter ?? "keine Mitarbeiter sichtbar" }
};
return dict;
}
private static Dictionary<string, object> createOrganisationNavigationContext(Dictionary<TableID, long[]> bewoobjects)
{
Action<Organisation, CompactOrganisationDC> loadAddress = (entity, dc) =>
{
if (entity.Address != null)
{
dc.AddressLine1 = entity.Address.AddressLine1;
dc.Street = entity.Address.Street;
dc.PostalCode = entity.Address.PostalCode;
dc.Town = entity.Address.Town;
}
};
var orgas = LoadEntities(bewoobjects, TableID.Organisation, MapperFactory.CompactOrganisationDC_Organisation, loadAddress);
var dict = new Dictionary<string, object>
{
{ "Aktuelle Ansicht", "Organisation Navigation" },
{ "Aktueller Ansichtsfilter", "Funktion noch nicht verfügbar" },
{ "Organisationsliste", (object)orgas ?? "keine Organisationen sichtbar" }
};
return dict;
}
private static Dictionary<string, object> createServiceRecordContext(Dictionary<TableID, long[]> bewoobjects)
{
var customer = LoadEntity(bewoobjects, TableID.Customer, MapperFactory.CompactCustomerDC_Customer);
var costbearer = LoadProperty(bewoobjects, TableID.CostBearer, MapperFactory.CompactOrganisationDC_Organisation, dc => dc.Name);
var supportconcept = LoadProperty(bewoobjects, TableID.SupportConcept, MapperFactory.CompactSupportConceptDC_SupportConcept, dc => $"{dc.StartDate?.Date} - {dc.EndDate?.Date}");
var records = LoadEntities(bewoobjects, TableID.ServiceRecord, MapperFactory.ServiceRecordDC_ServiceRecord);
var sub_dict = new Dictionary<string, object>()
{
{ "Klient", customer },
{ "Kostenträger", costbearer },
{ "Hilfeplan", supportconcept }
};
var dict = new Dictionary<string, object>
{
{ "Aktuelle Ansicht", "Zeiterfassung" },
{ "Aktueller Ansichtsfilter", "Funktion noch nicht verfügbar" },
{ "Auswahl", sub_dict},
{ "Zeiterfassungen", records }
};
return dict;
}
#endregion
#region SinglePage
private static Dictionary<string, object> createCustomerContext(Dictionary<TableID, long[]> bewoobjects)
{
var klient = LoadEntity(bewoobjects, TableID.Customer, MapperFactory.CustomerDC_Customer);
var dict = new Dictionary<string, object>
{
{ "Aktuelle Ansicht", "Klienten Daten" },
{ "Klient", klient }
};
return dict;
}
#endregion
#region LOAD Methods
private static object LoadProperty<TEntity, TDC>
(Dictionary<TableID, long[]> bewoobjects, TableID tid, AbstractIDCEntityMapper<TEntity, TDC> mapper, Func<TDC, object> getPropertyFunc)
where TDC : class, new() where TEntity : BeWoEntityBase, new()
{
if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0)
return null;
var entity = DAOFactory.GenericDAO.GetByID<TEntity>(oids[0]);
var dc = mapper.MapToNewDC(entity);
var property = getPropertyFunc(dc);
return property;
}
private static Dictionary<string, object> LoadEntity<TEntity, TDC>
(Dictionary<TableID, long[]> bewoobjects, TableID tid, AbstractIDCEntityMapper<TEntity, TDC> mapper)
where TDC : class, new() where TEntity : BeWoEntityBase, new()
{
if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0)
return null;
var entity = DAOFactory.GenericDAO.GetByID<TEntity>(oids[0]);
var dict = mapper.ToJsonDictionary(entity);
return dict;
}
private static IList<Dictionary<string, object>> LoadEntities<TEntity, TDC>
(Dictionary<TableID, long[]> bewoobjects, TableID tid, AbstractIDCEntityMapper<TEntity, TDC> mapper)
where TDC : class, new() where TEntity : BeWoEntityBase, new()
{
if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0)
return null;
var entities = DAOFactory.GenericDAO.GetByIDs<TEntity>(oids);
var dcs = mapper.MapToNewDCs(entities);
var dict = mapper.ToJsonDictionary(dcs);
return dict;
}
private static IList<Dictionary<string, object>> LoadEntities<TEntity, TDC>
(Dictionary<TableID, long[]> bewoobjects, TableID tid, AbstractIDCEntityMapper<TEntity, TDC> mapper, Action<TEntity, TDC> afterDC)
where TDC : class, new() where TEntity : BeWoEntityBase, new()
{
if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0)
return null;
var entities = DAOFactory.GenericDAO.GetByIDs<TEntity>(oids);
var dcs = new List<TDC>();
foreach (var entity in entities)
{
var dc = mapper.MapToNewDC(entity);
afterDC(entity, dc);
dcs.Add(dc);
}
var dict = mapper.ToJsonDictionary(dcs);
return dict;
}
#endregion
private static string getSystemPrompt(int i)
{
var assembly = Assembly.GetExecutingAssembly();
var resourceName = $"BeWo.Service.AI.system_prompt{i}.txt";
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
{
string result = reader.ReadToEnd();
return result;
}
}
private static string getCustomSystemPrompt()
{
var path = MergedConfig.GetSetting("AiSystemPromptPath");
return File.ReadAllText(path);
}
}
}

View File

@@ -62,6 +62,34 @@
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.2" newVersion="9.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.ObjectPool" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.11.0" newVersion="8.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Xml" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.WebEncoders" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.11.0" newVersion="8.0.11.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup></configuration>

View File

@@ -0,0 +1,27 @@
using System;
using System.Configuration;
using System.IO;
using System.Xml;
namespace BeWo.ServiceUtils.Core
{
public static class MergedConfig
{
public static string GetSetting(string key)
{
// 1. Versuche, aus AppSettings.local.config zu lesen
var localConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web.Secrets.config");
if (File.Exists(localConfigPath))
{
var xml = new XmlDocument();
xml.Load(localConfigPath);
var node = xml.SelectSingleNode($"/appSettings/add[@key='{key}']");
if (node is XmlElement element)
return element.GetAttribute("value");
}
// 2. Fallback: Standard-AppSettings
return ConfigurationManager.AppSettings[key];
}
}
}

View File

@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("ServiceUtils")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ServiceUtils")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("ec2349fb-7fe0-4ad1-b28b-a7a27af80a57")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BeWo.ServiceUtils</RootNamespace>
<AssemblyName>BeWo.ServiceUtils</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Core\MergedConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -1380,4 +1380,33 @@ namespace BS.Shared
csv,
tsv
}
public enum AiContextType
{
SupportConcept = 0,
Customer = 1,
Person = 2,
Employee = 3,
Organisation = 4,
Team = 5,
Dokumente = 6,
User = 7,
UserGroup = 8,
Report = 9,
Scheduler = 10,
Wohnheim = 11,
Vertretungen = 12,
CustomerTeam = 13,
Scheduling = 14,
Finance = 15,
Administration = 16,
//AiConversation = 17,
//AiConversationPopup = 18,
ServiceRecord = 19,
CustomerSingle = 20,
PersonSingle = 21,
EmployeeSingle = 22,
OrganisationSingle = 23,
SupportConceptSingle = 24,
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Wohnhilfe;
using BS.Shared.Exceptions;
using BS.Shared.Extensions;
using BS.Shared.Translation;
@@ -31,8 +32,11 @@ namespace BS.Shared.Core
public static Dictionary<UserRightType, String> UserRightType2Translations;
public static Dictionary<Enum, string> Wohnhilfe2Translation;
public static Dictionary<Enum, string> Gkv2Translation;
public static Dictionary<Enum, string> Ai2Translation;
public static Dictionary<ValueListEntryType, String> ValueListEntryType2Header;
public static Dictionary<ValueListEntryType, String> ValueListEntryTypeTranslations;
@@ -59,14 +63,20 @@ namespace BS.Shared.Core
public static Dictionary<SubstitutionNeed, string> SubstitutionNeedTranslations;
public static List<Dictionary<Enum, string>> TempTranslations;
static EnumTranslations()
{
InitUserRightTranslation();
TempTranslations = new List<Dictionary<Enum, string>>()
{
(Gkv2Translation = GetGkvTranslation()),
(Ai2Translation = GetAiTranslations())
};
InitUserRightTranslation();
InitWohnhilfeEnums();
InitGkvTranslation();
#region FamilyStatusTranslations
FamilyStatusTranslations = new Dictionary<object, String>
{
@@ -653,8 +663,17 @@ namespace BS.Shared.Core
BehinderungsartTranslations.DoForEach(p => AllTranslations.AddAndIgnoreDuplicates(p.Key, p.Value));
MerkzeichenTranslations.DoForEach(p => AllTranslations.AddAndIgnoreDuplicates(p.Key, p.Value));
Wohnhilfe2Translation?.DoForEach(kv => AllTranslations.Add(kv.Key, kv.Value));
Gkv2Translation?.DoForEach(kv => AllTranslations.Add(kv.Key, kv.Value));
}
InitTemp(TempTranslations);
}
static void InitTemp(List<Dictionary<Enum, string>> list)
{
foreach (var dict in list)
{
dict?.DoForEach(kv => AllTranslations.Add(kv.Key, kv.Value));
}
}
private static void InitUserRightTranslation()
{
@@ -1111,17 +1130,32 @@ namespace BS.Shared.Core
Wohnhilfe2Translation = dict;
}
private static void InitGkvTranslation()
private static Dictionary<Enum, string> GetGkvTranslation()
{
var dict = new Dictionary<Enum, string>();
var dict = new Dictionary<Enum, string>();
dict.Add(GkvVerfahrensstufe.Test, "Test");
dict.Add(GkvVerfahrensstufe.Erprobung, "Erprobung");
dict.Add(GkvVerfahrensstufe.Echt, "Echt");
Gkv2Translation = dict;
dict.Add(GkvVerfahrensstufe.Test, "Test");
dict.Add(GkvVerfahrensstufe.Erprobung, "Erprobung");
dict.Add(GkvVerfahrensstufe.Echt, "Echt");
return dict;
}
}
private static Dictionary<Enum, string> GetAiTranslations()
{
var dict = new Dictionary<Enum, string>();
dict.Add(AiContextType.SupportConcept, "Hilfeplan Navigation");
dict.Add(AiContextType.Customer, "Klienten Navigation");
dict.Add(AiContextType.Person, "Personen Navigation");
dict.Add(AiContextType.Employee, "Mitarbeiter Navigation");
dict.Add(AiContextType.Organisation, "Organisationen Navigation");
dict.Add(AiContextType.ServiceRecord, "Zeiterfassung");
dict.Add(AiContextType.CustomerSingle, "Klienten Ansicht");
dict.Add(AiContextType.EmployeeSingle, "Personen Ansicht");
dict.Add(AiContextType.PersonSingle, "Mitarbeiter Ansicht");
return dict;
}
}
}

View File

@@ -27,7 +27,8 @@ namespace BS.Shared.DataContracts.Feature.AI
[DataMember] public AiModelDC Modell { get; set; }
[DataMember] public string Context { get; set; }
[DataMember] public Dictionary<TableID, long[]> ContextBeWoObjects { get; set; } = new Dictionary<TableID, long[]>();
[DataMember] public int UIContext { get; set; }
[DataMember] public AiContextType UIContext { get; set; }
[DataMember] public AiDataContextType ContextType { get; set; }
[DataMember] public List<AiConversationMessageDC> Messages { get; set; }
}
}

View File

@@ -0,0 +1,36 @@
using BS.Shared.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace BS.Shared.Exceptions
{
public class BeWoNotImplementedException : NotImplementedException
{
public BeWoNotImplementedException() : base()
{
}
public BeWoNotImplementedException(string message) : base(message)
{
}
public BeWoNotImplementedException(string message, Exception inner) : base(message, inner)
{
}
protected BeWoNotImplementedException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
public static BeWoNotImplementedException CreateFromEnum(Enum value)
{
var type = value.GetType().Name;
return new BeWoNotImplementedException($"{type} {value} ist nicht implementiert.");
}
}
}

View File

@@ -385,6 +385,7 @@
<Compile Include="DataContracts\Reports\AuslastungAnalysisSupportConceptDC.cs" />
<Compile Include="DataContracts\ServiceRecordHistoryDC.cs" />
<Compile Include="DataContracts\SupportPinDC.cs" />
<Compile Include="Exceptions\BeWoNotImplementedException.cs" />
<Compile Include="Exceptions\BeWoInvalidOperationException.cs" />
<Compile Include="Exceptions\GkvException.cs" />
<Compile Include="Extensions\ApiResponseExtension.cs" />