@@ -216,7 +216,7 @@ fn trainAndMaybeRepl(allocator: std.mem.Allocator, pretrain_path: []const u8, ch
216216 std .debug .print ("Type a prompt and press Enter to generate text.\n " , .{});
217217 std .debug .print ("Type 'exit' to quit.\n " , .{});
218218
219- const stdin_file = std.fs.File { . handle = std . posix . STDIN_FILENO } ;
219+ const stdin_file = std .fs .File . stdin () ;
220220 const stdin = stdin_file .deprecatedReader ();
221221 var buffer : [1024 ]u8 = undefined ;
222222 while (true ) {
@@ -245,33 +245,6 @@ fn execRoot(ctx: chilli.CommandContext) !void {
245245 var config = if (config_path .len > 0 ) try loadConfig (allocator , config_path ) else Config {};
246246 defer config .deinit (allocator );
247247
248- // Override with CLI flags if provided (checking if they are different from defaults is tricky with chilli,
249- // so we'll assume CLI flags take precedence if they are set to non-default values or if we just use them directly.
250- // Actually, a better approach is: use config as base, then overwrite with CLI flags.
251- // But chilli returns defaults if flag is missing.
252- // So we need to know if flag was actually passed. Chilli doesn't easily expose this.
253- // For now, let's just use CLI flags if config is NOT present, OR if we want to support overrides,
254- // we have to accept that CLI defaults might overwrite config values.
255- // To solve this properly:
256- // 1. Load config
257- // 2. For each field, check if CLI flag was passed (not easy with current chilli usage).
258- // Alternative: We only use config if --config is passed, and ignore other flags? No, overrides are good.
259- // Let's assume: Config file sets defaults. CLI flags override.
260- // But chilli returns default values if flag is missing.
261- // So if config has batch_size=64, and CLI default is 32, and user runs without --batch-size, chilli returns 32.
262- // If we overwrite config with 32, we lose the config value.
263- // We need to check if the flag was present.
264- // Since we can't easily do that, let's prioritize CLI flags ONLY if they are explicitly different from our hardcoded defaults?
265- // Or simpler: If --config is passed, we use it. We can manually parse args to see if flags are present, but that's messy.
266-
267- // Let's stick to the plan: Config file sets values. CLI flags override.
268- // If we want CLI to override, we need to know if user typed it.
269- // Given the constraints, let's do this:
270- // If --config is present, use it.
271- // AND we will NOT read other flags if --config is present, to avoid confusion.
272- // OR we can say: CLI flags are ignored if --config is present, EXCEPT for interactive/save-model maybe?
273- // Let's go with: If --config is present, it is the source of truth.
274-
275248 if (config_path .len > 0 ) {
276249 std .debug .print ("Loaded configuration from {s}\n " , .{config_path });
277250 } else {
@@ -361,7 +334,7 @@ pub fn main() anyerror!void {
361334 var root_cmd = try chilli .Command .init (allocator , .{
362335 .name = "zigformer-cli" ,
363336 .description = "An educational transformer-based LLM in Zig" ,
364- .version = "v0.1.0 " ,
337+ .version = "v0.1.1 " ,
365338 .exec = execRoot ,
366339 });
367340 defer root_cmd .deinit ();
0 commit comments