Token-Optimierung: Prompt Caching + Tool-Result-Truncation in History
This commit is contained in:
1 parent
ec5917ef63
commit
f74409dd89
12 files changed
+220
-59
No files matched your search
@@ -0,0 +1,35 @@
|
||||
using System.Collections.Generic;
|
||||
using Gott.Models;
|
||||
|
||||
namespace Gott.Services;
|
||||
|
||||
public static class SystemPromptBuilder
|
||||
{
|
||||
public static string Build(AgentRecord agent, SessionRecord session)
|
||||
{
|
||||
var parts = new List<string>();
|
||||
parts.Add($"Du bist {agent.Name}.");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(agent.Persona))
|
||||
parts.Add($"## Persona\n{agent.Persona}");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(agent.Instructions))
|
||||
parts.Add($"## Instructions\n{agent.Instructions}");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(session.Workspace))
|
||||
{
|
||||
parts.Add(@$"## Tools
|
||||
Du hast Tools zur Verfügung (read_file, write_file, edit_file, list_files, delete_file, execute). Benutze sie um Dateien zu lesen, schreiben und bearbeiten.
|
||||
|
||||
Der Workspace-Pfad ist: `{session.Workspace}`
|
||||
Alle Dateipfade in Tool-Aufrufen müssen relativ zu diesem Workspace sein oder absolute Pfade verwenden, die mit diesem Pfad beginnen.
|
||||
|
||||
Wenn der User auf eine bestimmte Zeile in einer Datei verweist (z.B. `[Datei: foo.txt:11]`), zähle Leerzeilen immer mit. Verwende `cat -n` oder ein ähnliches Tool um Zeilennummern exakt zu bestimmen - NIEMALS Leerzeilen beim Zählen überspringen.");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(session.Context))
|
||||
parts.Add($"## Kontext\n{session.Context}");
|
||||
|
||||
return string.Join("\n\n", parts);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user