summaryrefslogtreecommitdiff
path: root/libpanto/src/config.zig
blob: 74bdcc70bea95d50073af3ad57d8a200c83d8a1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
pub const APIStyle = enum {
    openai_chat,
};

/// Reasoning intensity hint sent to providers that support it.
///
/// `.default` omits the field entirely so the provider's own default applies.
/// `.off` sends `"none"` (supported by OpenRouter/NanoGPT; ignored or rejected
/// elsewhere). The remaining values mirror the `reasoning_effort` parameter
/// accepted by OpenAI reasoning models and OpenAI-compatible proxies.
pub const ReasoningEffort = enum {
    default,
    off,
    minimal,
    low,
    medium,
    high,
};

pub const Config = struct {
    api_style: APIStyle,
    api_key: []const u8,
    base_url: []const u8,
    model: []const u8,
    reasoning: ReasoningEffort = .default,
};

const t = @import("std").testing;

test "Config - construct with all fields" {
    const cfg = Config{
        .api_style = .openai_chat,
        .api_key = "sk-test",
        .base_url = "https://api.openai.com/v1",
        .model = "gpt-4o",
        .reasoning = .high,
    };
    try t.expectEqual(APIStyle.openai_chat, cfg.api_style);
    try t.expectEqualStrings("sk-test", cfg.api_key);
    try t.expectEqualStrings("https://api.openai.com/v1", cfg.base_url);
    try t.expectEqualStrings("gpt-4o", cfg.model);
    try t.expectEqual(ReasoningEffort.high, cfg.reasoning);
}

test "Config - reasoning defaults to .default" {
    const cfg = Config{
        .api_style = .openai_chat,
        .api_key = "k",
        .base_url = "u",
        .model = "m",
    };
    try t.expectEqual(ReasoningEffort.default, cfg.reasoning);
}