Rund 2.600 Kommentarblöcke in 310 C#-Dateien übersetzt, Begründungen vollständig erhalten: blockweise gleiche Anzahl wie vorher, kein Block unter 60 % seiner Länge, der Code außerhalb der Kommentare per Tokenizer byte-identisch geprüft. Zitate deutscher Oberflächentexte und Testdaten bleiben deutsch. WebUI: Kommentare in JS/CSS/HTML übersetzt, JSDoc-@param an die in 4b umbenannten Parameter angeglichen. Dabei behoben: - 4b hatte "tag" (HTML-Tag) als deutsches "Tag" gelesen und zu "dayValue" gemacht (makeElement, svg, Tagesübersicht) - zurück auf tag/day. - Aufgaben "InProgress" bekamen die Plakettenart "laufend", für die es nie eine CSS-Klasse gab - jetzt "success" wie laufende Instanzen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.1 KiB
C#
69 lines
2.1 KiB
C#
using ClawdDotNet.Core.Api.Models;
|
|
|
|
namespace ClawdDotNet.Core.Tests.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// Builds valid message sequences for tests — readable and guaranteed API-compliant.
|
|
/// </summary>
|
|
internal sealed class Conversation
|
|
{
|
|
private readonly List<ChatMessage> _messages = new();
|
|
private int _callCounter;
|
|
|
|
public static Conversation Start(string? systemPrompt = "Du bist ein Testagent.")
|
|
{
|
|
var c = new Conversation();
|
|
if (!string.IsNullOrEmpty(systemPrompt))
|
|
c._messages.Add(ChatMessage.System(systemPrompt));
|
|
return c;
|
|
}
|
|
|
|
public Conversation User(string text)
|
|
{
|
|
_messages.Add(ChatMessage.User(text));
|
|
return this;
|
|
}
|
|
|
|
public Conversation Assistant(string text)
|
|
{
|
|
_messages.Add(ChatMessage.Assistant(text));
|
|
return this;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds a complete tool cycle: assistant with N tool_calls,
|
|
/// followed by exactly N matching tool answers.
|
|
/// </summary>
|
|
public Conversation ToolCycle(int count = 1, int resultLength = 50, string toolName = "TestTool")
|
|
{
|
|
var calls = new List<ToolCall>();
|
|
for (var i = 0; i < count; i++)
|
|
{
|
|
calls.Add(new ToolCall
|
|
{
|
|
Id = $"call_{++_callCounter}",
|
|
Type = "function",
|
|
Function = new ToolCallFunction { Name = toolName, Arguments = """{"action":"test"}""" }
|
|
});
|
|
}
|
|
|
|
_messages.Add(ChatMessage.AssistantWithToolCalls(calls));
|
|
foreach (var call in calls)
|
|
_messages.Add(ChatMessage.ToolResponse(call.Id, new string('x', resultLength)));
|
|
|
|
return this;
|
|
}
|
|
|
|
/// <summary>Repeats a pattern of user message and tool cycle.</summary>
|
|
public Conversation Repeat(int times, int toolCallsPerCycle = 1, int resultLength = 50)
|
|
{
|
|
for (var i = 0; i < times; i++)
|
|
User($"Anfrage {i}").ToolCycle(toolCallsPerCycle, resultLength).Assistant($"Antwort {i}");
|
|
return this;
|
|
}
|
|
|
|
public List<ChatMessage> Build() => _messages;
|
|
|
|
public static implicit operator List<ChatMessage>(Conversation c) => c._messages;
|
|
}
|