Files
BeWoPlaner/Server/Components/AICore/Prompt/SystemPrompts/BaseSystemPromptBuilder.cs

76 lines
1.8 KiB
C#
Raw Normal View History

using AICore.Context.Summary;
using AICore.Context.SummaryParser;
using BS.Shared;
using BS.Shared.DataContracts.Feature.AI;
using BS.Shared.Exceptions;
2026-05-26 12:30:29 +02:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2025-12-04 15:06:39 +01:00
namespace AICore.Prompt.SystemPrompts
{
2026-05-27 15:34:53 +02:00
internal class BaseSystemPromptBuilder
{
2026-05-26 12:30:29 +02:00
public readonly static Dictionary<AiActionType, string> Translations = new Dictionary<AiActionType, string>
{
{AiActionType.ServiceRecord, "Zeiterfassung" },
{AiActionType.ServiceRecordConversation, "Zeiterfassung" },
{AiActionType.ServiceRecordDocumentation, "Zeiterfassung" },
};
2026-02-20 12:51:18 +01:00
public string Path { get; set; }
2026-02-20 12:51:18 +01:00
public BaseSystemPromptBuilder(string path)
{
2026-02-20 12:51:18 +01:00
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()
{
2026-02-20 12:51:18 +01:00
var path = Path;
return File.ReadAllText(path);
}
}
}