LINE1 10 20 30 40 50 60 70 80 90 100 110 1201//! Totenschloss: a chat server over the Deadlock DuckLake data.23const std = @import("std");4const auth = @import("auth.zig");5const config = @import("config.zig");6const llm = @import("llm.zig");7const server = @import("server.zig");8const session = @import("session.zig");910const log = std.log.scoped(.main);1112pub fn main() !void {13 var gpa = std.heap.GeneralPurposeAllocator(.{}){};14 defer _ = gpa.deinit();15 const allocator = gpa.allocator();1617 const cfg = try config.load(allocator);18 try std.fs.cwd().makePath(cfg.extension_dir);19 try std.fs.cwd().makePath(cfg.temp_dir);2021 session.installExtensions(&cfg) catch |err| {22 log.err("could not install DuckLake extensions ({s}); chat requests will fail until this succeeds", .{@errorName(err)});23 };2425 if (cfg.llm == null) log.warn("no INFERENCE_API_KEY or ANTHROPIC_API_KEY: chat is disabled, /sql still works", .{});26 if (cfg.web_auth == null) log.warn("no ADMIN_PASSWORD: login is disabled, the site is open to anyone", .{});2728 const auth_state = try auth.State.init(allocator, cfg.web_auth, cfg.storage_dir);2930 var app = server.App{31 .allocator = allocator,32 .config = cfg,33 .model = if (cfg.llm) |llm_cfg| llm.Client{34 .api_key = llm_cfg.api_key,35 .model = llm_cfg.model,36 .base_url = llm_cfg.base_url,37 .auth = llm_cfg.auth,38 } else null,39 .active_chats = std.atomic.Value(u32).init(0),40 .auth = auth_state,41 };42 try server.serve(&app);43}4445test {46 _ = @import("auth.zig");47 _ = @import("chat.zig");48 _ = @import("config.zig");49 _ = @import("duckdb.zig");50 _ = @import("llm.zig");51 _ = @import("server.zig");52 _ = @import("session.zig");53 _ = @import("sql_guard.zig");54}