File size: 1,451 Bytes
87149fa
 
 
 
 
 
be97847
 
87149fa
 
 
 
 
 
 
be97847
 
87149fa
 
 
 
 
 
 
 
 
e287216
87149fa
 
 
 
 
 
9d8bbd6
 
 
 
 
 
 
 
 
 
87149fa
 
 
 
 
 
 
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
"""Drafting uses a higher temperature than analysis."""

import pytest

import config
from config import get_settings
from graph import build_llm
from skills import DRAFTING_SKILLS


def test_drafting_is_warmer_than_analysis():
    settings = get_settings()
    assert settings.drafting_temperature > settings.temperature


def test_only_the_writing_skills_draft():
    assert DRAFTING_SKILLS == {"cover_letter", "email"}


def test_default_temperatures():
    assert config.DEFAULT_TEMPERATURE == 0.0
    assert 0 < config.DEFAULT_DRAFTING_TEMPERATURE < 1


def test_build_llm_defaults_to_the_analysis_temperature():
    assert build_llm().temperature == pytest.approx(get_settings().temperature, abs=1e-6)
    assert build_llm().openai_api_base == config.OPENROUTER_BASE_URL


def test_build_llm_accepts_an_override():
    assert build_llm(0.4).temperature == 0.4


def test_build_llm_accepts_a_ui_key_without_an_environment_key(monkeypatch):
    monkeypatch.delenv("OPENROUTER_API_KEY")
    get_settings.cache_clear()
    try:
        llm = build_llm(api_key="ui-key")
        assert llm.openai_api_key.get_secret_value() == "ui-key"
    finally:
        get_settings.cache_clear()


def test_drafting_temperature_is_configurable(monkeypatch):
    monkeypatch.setenv("LLM_DRAFTING_TEMPERATURE", "0.9")
    get_settings.cache_clear()
    try:
        assert get_settings().drafting_temperature == 0.9
    finally:
        get_settings.cache_clear()