Lightpanda: the headless browser designed for AI and automation
agent: add support for Vercel AI Gateway and Mistral
Adrià Arrufat88bfec4c7e1f
diff --git a/build.zig.zon b/build.zig.zonindex 627e66607..9f5ddb809 100644--- a/build.zig.zon+++ b/build.zig.zon@@ -35,8 +35,8 @@.hash = "sqlite3-3.51.0-DMxLWssOAABZ8cAvU_LfBIbp0kZjm824PU8sSLXpEDdr",},.zenai = .{- .url = "git+https://github.com/lightpanda-io/zenai.git#b138790128c3fa424e707261d36b976996e98727",- .hash = "zenai-0.0.0-iOY_VGOQBABBXW4fba10sWXKPyTlvHf_szZRllWzBwIe",+ .url = "git+https://github.com/lightpanda-io/zenai.git#adb9003f117c42dc852eaf6b9a9635a7818cf7e7",+ .hash = "zenai-0.0.0-iOY_VAybBABxp6BVih24SSYrCzBWPhZOAKc52_jVyT9k",},.isocline = .{.url = "git+https://github.com/arrufat/isocline?ref=lightpanda#832a9fe25f5f4458fcc47b5acc7c21db669c2f47",diff --git a/src/agent/Agent.zig b/src/agent/Agent.zigindex 6924f536a..dc800c40e 100644--- a/src/agent/Agent.zig+++ b/src/agent/Agent.zig@@ -530,6 +530,7 @@ fn resetAfterCancel(self: *Agent, baseline: usize) void {self.conversation.rollback(baseline);self.browser.env.cancelTerminate();self.cancel_requested.store(false, .release);+ self.http_interrupt.reset();}/// One agent turn: the prompt sent to the model, plus optional context — a@@ -1116,6 +1117,7 @@ fn synthesizeSave(self: *Agent, arena: std.mem.Allocator, filename: ?[]const u8,const user_msg = self.buildSaveSynthesisMessage(ma, path, previous_script, prompt) catch return self.failSave("out of memory");self.conversation.messages.append(self.allocator, .{ .role = .user, .content = user_msg }) catch return self.failSave("out of memory");+ self.http_interrupt.reset();self.terminal.spinner.start();var result = provider_client.runTools(self.model,@@ -1488,6 +1490,7 @@ fn formatApiError(self: *Agent, client: zenai.provider.Client, err: anyerror) []fn processUserMessage(self: *Agent, input: TurnInput) !?[]const u8 {const ma = self.conversation.arena.allocator();self.api_error_detail = null;+ self.http_interrupt.reset();try self.conversation.ensureSystemPrompt();diff --git a/src/agent/settings.zig b/src/agent/settings.zigindex 1aadd8008..80365bcd1 100644--- a/src/agent/settings.zig+++ b/src/agent/settings.zig@@ -30,7 +30,7 @@ const Terminal = @import("Terminal.zig");const string = @import("../string.zig");const Credentials = zenai.provider.Credentials;-pub const api_keys_hint = "ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY, or HF_TOKEN";+pub const api_keys_hint = "ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY, HF_TOKEN, AI_GATEWAY_API_KEY, or MISTRAL_API_KEY";/// Determine which provider to use and read its env key. Returns null/// only when no `--provider` was given AND no env key exists (the caller