mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-06-11 01:25:53 -04:00
telemetry: send a new llm event
This commit is contained in:
32
src/main.zig
32
src/main.zig
@@ -196,7 +196,15 @@ fn run(allocator: Allocator, main_arena: Allocator) !void {
|
||||
var failed: bool = false;
|
||||
var cancelled: bool = false;
|
||||
{
|
||||
var worker_thread = try std.Thread.spawn(.{}, agentThread, .{ allocator, app, opts, &failed, &cancelled, &sig_bridge });
|
||||
var worker_thread = try std.Thread.spawn(.{}, agentThread, .{
|
||||
allocator,
|
||||
main_arena,
|
||||
app,
|
||||
opts,
|
||||
&failed,
|
||||
&cancelled,
|
||||
&sig_bridge,
|
||||
});
|
||||
defer worker_thread.join();
|
||||
|
||||
app.network.run();
|
||||
@@ -209,7 +217,15 @@ fn run(allocator: Allocator, main_arena: Allocator) !void {
|
||||
}
|
||||
}
|
||||
|
||||
fn agentThread(allocator: std.mem.Allocator, app: *App, opts: Config.Agent, failed: *bool, cancelled: *bool, sig_bridge: *lp.Agent.SigBridge) void {
|
||||
fn agentThread(
|
||||
allocator: std.mem.Allocator,
|
||||
arena: std.mem.Allocator,
|
||||
app: *App,
|
||||
opts: Config.Agent,
|
||||
failed: *bool,
|
||||
cancelled: *bool,
|
||||
sig_bridge: *lp.Agent.SigBridge,
|
||||
) void {
|
||||
defer app.network.stop();
|
||||
|
||||
var agent_instance = lp.Agent.init(allocator, app, opts) catch |err| {
|
||||
@@ -226,6 +242,18 @@ fn agentThread(allocator: std.mem.Allocator, app: *App, opts: Config.Agent, fail
|
||||
defer agent_instance.deinit();
|
||||
defer sig_bridge.detach();
|
||||
|
||||
if (agent_instance.ai_client) |cli| {
|
||||
app.telemetry.record(.{ .llm = .{
|
||||
.provider = @tagName(cli),
|
||||
.model = arena.dupe(u8, agent_instance.model) catch null,
|
||||
} });
|
||||
} else {
|
||||
app.telemetry.record(.{ .llm = .{
|
||||
.provider = "nollm",
|
||||
.model = null,
|
||||
} });
|
||||
}
|
||||
|
||||
if (!agent_instance.run()) {
|
||||
failed.* = true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const std = @import("std");
|
||||
const zenai = @import("zenai");
|
||||
const lp = @import("lightpanda");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
@@ -103,6 +104,7 @@ pub const Event = union(enum) {
|
||||
run: void,
|
||||
navigate: Navigate,
|
||||
buffer_overflow: BufferOverflow,
|
||||
llm: LLM,
|
||||
|
||||
const Navigate = struct {
|
||||
tls: bool,
|
||||
@@ -113,6 +115,11 @@ pub const Event = union(enum) {
|
||||
const BufferOverflow = struct {
|
||||
dropped: u32,
|
||||
};
|
||||
|
||||
const LLM = struct {
|
||||
provider: [:0]const u8,
|
||||
model: ?[]const u8,
|
||||
};
|
||||
};
|
||||
|
||||
extern fn setenv(name: [*:0]u8, value: [*:0]u8, override: c_int) c_int;
|
||||
|
||||
Reference in New Issue
Block a user