Merge Konflikte gelöst

This commit is contained in:
2026-07-09 17:01:05 +02:00
parent 906310d04b
commit 44afdc0e20
26 changed files with 398 additions and 639 deletions

View File

@@ -125,7 +125,6 @@
<Compile Include="Prompt\SystemPrompts\AiFunctionSystemPromptBuilder.cs" />
<Compile Include="Prompt\SystemPrompts\AiConversationSystemPromptBuilder.cs" />
<Compile Include="Prompt\Models\AiConversationContext.cs" />
<Compile Include="Prompt\SystemPrompts\AiGenericSystemPromptBuilder.cs" />
<Compile Include="Prompt\SystemPrompts\BaseSystemPromptBuilder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@@ -1,7 +1,6 @@
using AICore.Context.Summary;
using AICore.Prompt.SystemPrompts;
using BS.Shared;
using BS.Shared.DataContracts.Feature.AI;
using BS.Shared.Exceptions;
using System;
using System.Collections.Generic;
@@ -14,27 +13,25 @@ namespace AICore.Prompt
{
public class AiSystemPromptFactory
{
public static string BuildContext(AiActionType actionType, string prompt_path, AiViewContextDC view_context, BaseContextSummary context, AiDataContextType context_type)
public static string BuildContext(AiActionType actionType, string prompt_path, BaseContextSummary context, AiDataContextType context_type)
{
switch (actionType)
{
case AiActionType.ServiceRecord:
break;
case AiActionType.ServiceRecordConversation:
var factory = new AiConversationSystemPromptBuilder(prompt_path);
var prompt = factory.CreateSystemPrompt(actionType, context, context_type);
return prompt;
case AiActionType.ServiceRecordDocumentation:
return BuildGenericContext(actionType, prompt_path, view_context, context, context_type);
var factory2 = new AiFunctionSystemPromptBuilder(prompt_path);
var prompt2 = factory2.CreateServiceRecordDocumentationSystemPrompt(context);
return prompt2;
default:
break;
}
throw BeWoNotImplementedException.CreateFromEnum(actionType);
}
public static string BuildGenericContext(AiActionType actionType, string prompt_path, AiViewContextDC view_context, BaseContextSummary context, AiDataContextType context_type)
{
var factory = new AiGenericSystemPromptBuilder(prompt_path);
return factory.CreateSystemPrompt(actionType, view_context, context, context_type);
}
}
}

View File

@@ -2,7 +2,6 @@
using AICore.Context.SummaryParser;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts.Feature.AI;
using BS.Shared.Exceptions;
using BS.Shared.Translation;
using System;
@@ -15,74 +14,66 @@ using System.Text.Json;
namespace AICore.Prompt.SystemPrompts
{
//internal class AiConversationSystemPromptBuilder : BaseSystemPromptBuilder
//{
// public AiConversationSystemPromptBuilder(string prompt_path) : base(prompt_path) {
internal class AiConversationSystemPromptBuilder : BaseSystemPromptBuilder
{
public AiConversationSystemPromptBuilder(string prompt_path) : base(prompt_path) {
// }
}
// public string CreateSystemPrompt(AiActionType actionType, AiViewContextDC view_context, BaseContextSummary context, AiDataContextType aiDataContextType)
// {
// var currentDateTime = DateTime.Now;
// var moduleName = Translations[actionType];
// var filter = view_context.Filter is string filter_str
// ? $"Es ist folgender Filter gesetzt: {filter_str}"
// : "Es ist kein Filter gesetzt.";
public string CreateSystemPrompt(AiActionType actionType, BaseContextSummary context, AiDataContextType aiDataContextType)
{
var sb = new StringBuilder();
// var context =
sb.AppendLine(getCustomSystemPrompt());
sb.AppendLine();
sb.AppendLine();
sb.AppendLine("---");
sb.AppendLine();
sb.AppendLine("### **Allgemein**");
sb.AppendLine($"- Aktuelle Zeit: {DateTime.Now}");
sb.AppendLine();
sb.AppendLine("### **Ansicht**");
sb.AppendLine($"- Ich befinde mich aktuell in der \"{Translations[actionType]}\" meiner Anwendung.");
sb.AppendLine($"- Es ist kein Filter gesetzt.");
sb.AppendLine();
sb.AppendLine("### **Daten**");
// var sb = new StringBuilder();
if (context?.Context is null)
{
sb.AppendLine("Dir wurden keine Daten bereitgestellt.");
}
else
{
sb.AppendLine("Du erhälst folgende Daten:");
// sb.AppendLine(getCustomSystemPrompt());
// sb.AppendLine();
// sb.AppendLine();
// sb.AppendLine("---");
// sb.AppendLine();
// sb.AppendLine("### **Allgemein**");
// sb.AppendLine($"- Aktuelle Zeit: {DateTime.Now}");
// sb.AppendLine();
// sb.AppendLine("### **Ansicht**");
// sb.AppendLine($"- Ich befinde mich aktuell in der \"{Translations[actionType]}\" meiner Anwendung.");
// sb.AppendLine();
// sb.AppendLine("### **Daten**");
var parser = GetParser(aiDataContextType);
var parsed = parser.Parse(actionType, context);
// if (context?.Context is null)
// {
// sb.AppendLine("Dir wurden keine Daten bereitgestellt.");
// }
// else
// {
// sb.AppendLine("Du erhälst folgende Daten:");
sb.AppendLine(parsed);
}
// var parser = GetParser(aiDataContextType);
// var parsed = parser.Parse(actionType, context);
return sb.ToString();
}
// sb.AppendLine(parsed);
// }
private BaseContextSummaryParser GetParser(AiDataContextType aiDataContextType)
{
switch (aiDataContextType)
{
case AiDataContextType.json:
return new JsonContextSummaryParser();
case AiDataContextType.csv:
return new CsvContextSummaryParser();
case AiDataContextType.tsv:
return new CsvContextSummaryParser("\t");
case AiDataContextType.csv2:
return new CsvContextSummaryParser(";", true);
case AiDataContextType.tsv2:
return new CsvContextSummaryParser("\t", true);
default:
break;
}
// return sb.ToString();
// }
// private BaseContextSummaryParser GetParser(AiDataContextType aiDataContextType)
// {
// switch (aiDataContextType)
// {
// case AiDataContextType.json:
// return new JsonContextSummaryParser();
// case AiDataContextType.csv:
// return new CsvContextSummaryParser();
// case AiDataContextType.tsv:
// return new CsvContextSummaryParser("\t");
// case AiDataContextType.csv2:
// return new CsvContextSummaryParser(";", true);
// case AiDataContextType.tsv2:
// return new CsvContextSummaryParser("\t", true);
// default:
// break;
// }
// throw BeWoNotImplementedException.CreateFromEnum(aiDataContextType);
// }
//}
throw BeWoNotImplementedException.CreateFromEnum(aiDataContextType);
}
}
}

View File

@@ -3,7 +3,6 @@ using AICore.Context.Summary.Function;
using AICore.Context.SummaryParser;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts.Feature.AI;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
@@ -14,53 +13,46 @@ using System.Threading.Tasks;
namespace AICore.Prompt.SystemPrompts
{
//internal class AiFunctionSystemPromptBuilder : BaseSystemPromptBuilder
//{
// public AiFunctionSystemPromptBuilder(string prompt_path) : base(prompt_path)
// {
internal class AiFunctionSystemPromptBuilder : BaseSystemPromptBuilder
{
public AiFunctionSystemPromptBuilder(string prompt_path) : base(prompt_path)
{
// }
}
// public string CreateServiceRecordDocumentationSystemPrompt(AiViewContextDC view_context, BaseContextSummary context)
// {
// var sb = new StringBuilder();
public string CreateServiceRecordDocumentationSystemPrompt(BaseContextSummary context)
{
var sb = new StringBuilder();
// sb.AppendLine(getCustomSystemPrompt());
// sb.AppendLine();
// sb.AppendLine();
// sb.AppendLine("---");
// sb.AppendLine();
// sb.AppendLine("### **Allgemein**");
// sb.AppendLine($"- Aktuelle Zeit: {DateTime.Now}");
// sb.AppendLine();
// sb.AppendLine("### **Ansicht**");
// sb.AppendLine($"- Ich befinde mich aktuell in der \"Zeiterfassung\" meiner Anwendung.");
// if(view_context.Filter is string filter_str)
// {
// sb.AppendLine($"- Es ist folgender Filter gesetzt: {filter_str}");
// }
// else
// {
// sb.AppendLine($"- Es ist kein Filter gesetzt.");
// }
// sb.AppendLine();
// sb.AppendLine("### **Daten**");
sb.AppendLine(getCustomSystemPrompt());
sb.AppendLine();
sb.AppendLine();
sb.AppendLine("---");
sb.AppendLine();
sb.AppendLine("### **Allgemein**");
sb.AppendLine($"- Aktuelle Zeit: {DateTime.Now}");
sb.AppendLine();
sb.AppendLine("### **Ansicht**");
sb.AppendLine($"- Ich befinde mich aktuell in der \"Zeiterfassung\" meiner Anwendung.");
sb.AppendLine($"- Es ist kein Filter gesetzt.");
sb.AppendLine();
sb.AppendLine("### **Daten**");
// if (context?.Context is null)
// {
// sb.AppendLine("Dir wurden keine Daten bereitgestellt.");
// }
// else
// {
// sb.AppendLine("Du erhälst folgende Daten:");
if (context?.Context is null)
{
sb.AppendLine("Dir wurden keine Daten bereitgestellt.");
}
else
{
sb.AppendLine("Du erhälst folgende Daten:");
// var parser = new CsvContextSummaryParser();
// var parsed = parser.Parse(AiActionType.ServiceRecordDocumentation, context);
var parser = new CsvContextSummaryParser();
var parsed = parser.Parse(AiActionType.ServiceRecordDocumentation, context);
// sb.AppendLine(parsed);
// }
sb.AppendLine(parsed);
}
// return sb.ToString();
// }
//}
return sb.ToString();
}
}
}

View File

@@ -1,57 +0,0 @@
using AICore.Context.Summary;
using AICore.Context.SummaryParser;
using BS.Shared.DataContracts.Feature.AI;
using BS.Shared.Exceptions;
using BS.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Remoting.Messaging;
namespace AICore.Prompt.SystemPrompts
{
internal class AiGenericSystemPromptBuilder : BaseSystemPromptBuilder
{
public AiGenericSystemPromptBuilder(string prompt_path) : base(prompt_path)
{
}
public string CreateSystemPrompt(AiActionType actionType, AiViewContextDC view_context, BaseContextSummary context, AiDataContextType aiDataContextType)
{
var replace_dict = new Dictionary<string, string>()
{
{"{AktuelleZeit}", DateTime.Now.ToString() },
{"{AktuellesModule}", Translations[actionType]},
{"{FilterEinstellungen}", getFilterString(view_context.Filter)},
{"{DatenBlock}", getContextBlock(actionType, context, aiDataContextType)}
};
return createSystemPrompt(replace_dict);
}
private string getFilterString(object filter)
{
if (filter is null)
return "Es ist kein Filter gesetzt.";
return $"Es ist folgender Filter gesetzt: {filter}";
}
private string getContextBlock(AiActionType actionType, BaseContextSummary context, AiDataContextType aiDataContextType)
{
if (context is null)
{
return "Dir wurden keine Daten bereitgestellt.";
}
var parser = getParser(aiDataContextType);
var parsed = parser.Parse(actionType, context);
return $"Du erhälst folgende Daten: {Environment.NewLine}"
+ parsed;
}
}
}

View File

@@ -1,8 +1,4 @@
using AICore.Context.Summary;
using AICore.Context.SummaryParser;
using BS.Shared;
using BS.Shared.DataContracts.Feature.AI;
using BS.Shared.Exceptions;
using BS.Shared;
using System;
using System.Collections.Generic;
using System.IO;
@@ -28,45 +24,7 @@ namespace AICore.Prompt.SystemPrompts
Path = path;
}
protected string createSystemPrompt(Dictionary<string, string> replace_dict)
{
var sb = new StringBuilder();
sb.AppendLine(getCustomSystemPrompt());
foreach (var kvp in replace_dict)
{
var key = kvp.Key;
var value = kvp.Value;
sb.Replace(key, value);
}
return sb.ToString();
}
protected BaseContextSummaryParser getParser(AiDataContextType aiDataContextType)
{
switch (aiDataContextType)
{
case AiDataContextType.json:
return new JsonContextSummaryParser();
case AiDataContextType.csv:
return new CsvContextSummaryParser();
case AiDataContextType.tsv:
return new CsvContextSummaryParser("\t");
case AiDataContextType.csv2:
return new CsvContextSummaryParser(";", true);
case AiDataContextType.tsv2:
return new CsvContextSummaryParser("\t", true);
default:
break;
}
throw BeWoNotImplementedException.CreateFromEnum(aiDataContextType);
}
private string getCustomSystemPrompt()
protected string getCustomSystemPrompt()
{
var path = Path;
return File.ReadAllText(path);