Files
BeWoPlaner/Server/Components/AICore/Prompt/SystemPrompts/BaseSystemPromptBuilder.cs
Rene Evertz 89154c0223 Generischer AiSystemPromptBuilder
-> Mehr über SystmePrompt File steuerbar
2026-06-24 10:47:29 +02:00

76 lines
1.8 KiB
C#

using AICore.Context.Summary;
using AICore.Context.SummaryParser;
using BS.Shared;
using BS.Shared.DataContracts.Feature.AI;
using BS.Shared.Exceptions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AICore.Prompt.SystemPrompts
{
internal class BaseSystemPromptBuilder
{
public readonly static Dictionary<AiActionType, string> Translations = new Dictionary<AiActionType, string>
{
{AiActionType.ServiceRecord, "Zeiterfassung" },
{AiActionType.ServiceRecordConversation, "Zeiterfassung" },
{AiActionType.ServiceRecordDocumentation, "Zeiterfassung" },
};
public string Path { get; set; }
public BaseSystemPromptBuilder(string path)
{
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()
{
var path = Path;
return File.ReadAllText(path);
}
}
}