@@ -1,5 +1,6 @@
11 const std = @import("std");
2-const types = @import("types.zig");
2+const message_mod = @import("message.zig");
3+const models = @import("models.zig");
34 const http = @import("http.zig");
45 const time = @import("time.zig");
56
@@ -8,7 +9,7 @@ pub const Event = union(enum) {
89 reasoning: []const u8,
910 tool_start: []const u8,
1011 tool_args: usize,
11- tool_call: types.ToolCall,
12+ tool_call: message_mod.ToolCall,
1213 };
1314
1415 pub const Sink = struct {
@@ -20,8 +21,6 @@ pub const Sink = struct {
2021 }
2122 };
2223
23-pub const Raw = types.Raw;
24-
2524 pub const ErrField = struct {
2625 message: ?[]const u8 = null,
2726
@@ -57,10 +56,10 @@ pub const Count = struct {
5756 pub const Request = struct {
5857 pers: std.mem.Allocator,
5958 scratch: std.mem.Allocator,
60- model: *const types.Model,
59+ model: *const models.Model,
6160 system_prompt: []const u8,
6261 tools_json: []const u8,
63- messages: []const types.Message,
62+ messages: []const message_mod.Message,
6463 effort: []const u8,
6564 session_id: ?[]const u8,
6665 cancel: *const std.atomic.Value(bool),
@@ -84,7 +83,7 @@ pub fn run(
8483 req: Request,
8584 sink: Sink,
8685 finalize: *const fn (st: *State) std.mem.Allocator.Error!void,
87-) std.mem.Allocator.Error!types.AssistantMessage {
86+) std.mem.Allocator.Error!message_mod.AssistantMessage {
8887 var msg = newAssistant(req);
8988
9089 var arena = std.heap.ArenaAllocator.init(req.scratch);
@@ -142,7 +141,7 @@ pub fn blockAt(comptime T: type, list: *std.ArrayList(T), a: std.mem.Allocator,
142141 return &list.items[idx];
143142 }
144143
145-pub fn stream(req: Request, sink: Sink) std.mem.Allocator.Error!types.AssistantMessage {
144+pub fn stream(req: Request, sink: Sink) std.mem.Allocator.Error!message_mod.AssistantMessage {
146145 if (std.mem.eql(u8, req.model.api, "openai-completions")) {
147146 return @import("api/openai_completions.zig").stream(req, sink);
148147 }
@@ -161,7 +160,7 @@ pub fn stream(req: Request, sink: Sink) std.mem.Allocator.Error!types.AssistantM
161160 return msg;
162161 }
163162
164-fn newAssistant(req: Request) types.AssistantMessage {
163+fn newAssistant(req: Request) message_mod.AssistantMessage {
165164 return .{
166165 .content = .empty,
167166 .api = req.model.api,
@@ -198,7 +197,7 @@ fn wireHeaders(a: std.mem.Allocator, req: Request, wire: Wire) ![]http.Header {
198197 return list.toOwnedSlice(a);
199198 }
200199
201-fn post(req: Request, url: []const u8, hdrs: []const http.Header, body: []const u8, handler: http.SseHandler, msg: *types.AssistantMessage) std.mem.Allocator.Error!bool {
200+fn post(req: Request, url: []const u8, hdrs: []const http.Header, body: []const u8, handler: http.SseHandler, msg: *message_mod.AssistantMessage) std.mem.Allocator.Error!bool {
202201 var err_body: ?[]const u8 = null;
203202 http.postSse(req.scratch, url, hdrs, body, handler, req.cancel, &err_body) catch |e| {
204203 if (e == error.OutOfMemory) return error.OutOfMemory;
@@ -243,7 +242,7 @@ pub const Call = struct {
243242 }
244243 };
245244
246-pub fn appendCalls(msg: *types.AssistantMessage, sink: Sink, a: std.mem.Allocator, calls: []const Call, failed: bool) !bool {
245+pub fn appendCalls(msg: *message_mod.AssistantMessage, sink: Sink, a: std.mem.Allocator, calls: []const Call, failed: bool) !bool {
247246 if (failed) return false;
248247 var any = false;
249248 for (calls) |call| {
@@ -275,12 +274,12 @@ pub fn keepString(slot: *?[]const u8, a: std.mem.Allocator, value: ?[]const u8)
275274 slot.* = try a.dupe(u8, v);
276275 }
277276
278-pub fn appendParts(msg: *types.AssistantMessage, a: std.mem.Allocator, thinking: []const u8, signature: ?[]const u8, text: []const u8) !void {
277+pub fn appendParts(msg: *message_mod.AssistantMessage, a: std.mem.Allocator, thinking: []const u8, signature: ?[]const u8, text: []const u8) !void {
279278 if (thinking.len > 0) try msg.content.append(a, .{ .thinking = .{ .text = thinking, .signature = signature } });
280279 if (text.len > 0) try msg.content.append(a, .{ .text = text });
281280 }
282281
283-pub fn finishUsage(msg: *types.AssistantMessage, model: *const types.Model, usage: types.Usage) void {
282+pub fn finishUsage(msg: *message_mod.AssistantMessage, model: *const models.Model, usage: message_mod.Usage) void {
284283 var u = usage;
285284 if (u.total_tokens == 0) u.total_tokens = u.input + u.output + u.cache_read + u.cache_write;
286285 const per = struct {