diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig index a752a12..c1212e8 100644 --- a/src/main.zig +++ b/src/main.zig @@ -19,7 +19,6 @@ test { const Receiver = panto.provider.Receiver; const ReceiverVTable = panto.provider.ReceiverVTable; const ContentBlockType = panto.provider.ContentBlockType; -const BlockMeta = panto.provider.BlockMeta; const MessageRole = panto.conversation.MessageRole; /// Receiver that prints streaming deltas to stdout. Thinking blocks are @@ -50,16 +49,16 @@ const CLIReceiver = struct { ptr: *anyopaque, block_type: ContentBlockType, index: usize, - meta: ?BlockMeta, ) anyerror!void { _ = index; const self: *CLIReceiver = @ptrCast(@alignCast(ptr)); switch (block_type) { .Thinking => try self.stdout.writeAll("\x1b[2m[thinking] "), - .ToolUse => { - const name = if (meta) |m| (m.tool_name orelse "?") else "?"; - try self.stdout.print("\n\x1b[36m[tool: {s}]\x1b[0m ", .{name}); - }, + // Tool name is not known reliably at start time (OpenAI may + // stream id/name across fragments). Open with a bare prefix; + // the tool name lands at onBlockComplete from the assembled + // ContentBlock. + .ToolUse => try self.stdout.writeAll("\n\x1b[36mtool: \x1b[0m"), else => {}, } try self.file.flush(); @@ -81,7 +80,8 @@ const CLIReceiver = struct { const self: *CLIReceiver = @ptrCast(@alignCast(ptr)); switch (block) { .Thinking => try self.stdout.writeAll("\x1b[0m\n"), - .ToolUse => try self.stdout.writeAll("\n"), + // Append the tool name now that we know it for certain. + .ToolUse => |tu| try self.stdout.print("\x1b[36m : ({s})\x1b[0m\n", .{tu.name}), else => {}, } try self.file.flush(); |
