summaryrefslogtreecommitdiff
path: root/src/system_prompt.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/system_prompt.zig')
-rw-r--r--src/system_prompt.zig15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/system_prompt.zig b/src/system_prompt.zig
index 6676442..9dce3e5 100644
--- a/src/system_prompt.zig
+++ b/src/system_prompt.zig
@@ -330,6 +330,15 @@ fn projectLayerDir(arena: Allocator, io: Io) ![]u8 {
const testing = std.testing;
+/// Test helper: append a single-text user message (the `addUserMessage`
+/// signature now takes a block slice).
+fn addUserText(conv: *panto.Conversation, text: []const u8) !void {
+ const tb = try panto.textualBlockFromSlice(conv.allocator, text);
+ var block: panto.ContentBlock = .{ .Text = tb };
+ errdefer block.deinit(conv.allocator);
+ try conv.addUserMessage(&.{block});
+}
+
test "blocksEqual - length and content" {
try testing.expect(blocksEqual(&.{ "a", "b" }, &.{ "a", "b" }));
try testing.expect(!blocksEqual(&.{ "a", "b" }, &.{ "a", "c" }));
@@ -344,7 +353,7 @@ test "effectiveConfigWindow - no replace anchors to leading system blocks" {
try conv.addSystemMessage("seed");
try conv.addSystemMessage("append-1");
- try conv.addUserMessage("hi");
+ try addUserText(&conv, "hi");
var arena_state = std.heap.ArenaAllocator.init(alloc);
defer arena_state.deinit();
@@ -361,10 +370,10 @@ test "effectiveConfigWindow - anchors to last replace block" {
defer conv.deinit();
try conv.addSystemMessage("old seed");
- try conv.addUserMessage("hi");
+ try addUserText(&conv, "hi");
try conv.replaceSystemMessage("new seed");
try conv.addSystemMessage("new append");
- try conv.addUserMessage("again");
+ try addUserText(&conv, "again");
var arena_state = std.heap.ArenaAllocator.init(alloc);
defer arena_state.deinit();