Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ timeout = 20.0

[openai]
api_key = your_api_key_here
model = gpt-5.4-mini
model = gpt-5.6-luna
temperature = 0.0
timeout = 20.0
```
Expand All @@ -134,7 +134,7 @@ timeout = 20.0
| Provider | Default Model | Config Section |
|----------|--------------|----------------|
| Anthropic | `claude-haiku-4-5-latest` | `[anthropic]` |
| OpenAI | `gpt-5.4-mini` | `[openai]` |
| OpenAI | `gpt-5.6-luna` | `[openai]` |

Set `provider` in `[settings]` to switch between them. Only the selected provider's API key is required.

Expand Down
2 changes: 1 addition & 1 deletion config.ini.default
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ timeout = 20.0

[openai]
api_key = your_api_key_here
model = gpt-5.4-mini
model = gpt-5.6-luna
# Temperature for AI responses (0.0 = deterministic). Remove to use model default.
temperature = 0.0
timeout = 20.0
2 changes: 1 addition & 1 deletion email_utils/openai_spam_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def check_spam_with_openai(email_content: str) -> dict[str, Any]:
config = load_config()

api_key = config.get("openai", "api_key")
model = config.get("openai", "model", fallback="gpt-5.4-mini")
model = config.get("openai", "model", fallback="gpt-5.6-luna")
timeout = config.getfloat("openai", "timeout", fallback=20.0)

client = OpenAI(api_key=api_key, timeout=timeout)
Expand Down
22 changes: 20 additions & 2 deletions tests/test_openai_spam_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
from email_utils.openai_spam_check import check_spam_with_openai


def _mock_config(tmp_path, monkeypatch, temperature=None):
def _mock_config(tmp_path, monkeypatch, temperature=None, model="gpt-5.6-luna"):
"""Helper to set up a mock config file."""
lines = "[openai]\napi_key = test-key\nmodel = gpt-5.4-mini\ntimeout = 10.0\n"
lines = "[openai]\napi_key = test-key\n"
if model is not None:
lines += f"model = {model}\n"
lines += "timeout = 10.0\n"
if temperature is not None:
lines += f"temperature = {temperature}\n"
config_file = tmp_path / "config.ini"
Expand All @@ -28,6 +31,21 @@ def _make_mock_response(response_json):


class TestCheckSpamWithOpenai:
@patch("email_utils.openai_spam_check.OpenAI")
def test_uses_luna_by_default(self, mock_openai_cls, tmp_path, monkeypatch):
_mock_config(tmp_path, monkeypatch, model=None)

mock_client = MagicMock()
mock_client.chat.completions.create.return_value = _make_mock_response(
{"is_spam": "no", "confidence": 0, "reason": "test"}
)
mock_openai_cls.return_value = mock_client

check_spam_with_openai("test")

call_kwargs = mock_client.chat.completions.create.call_args[1]
assert call_kwargs["model"] == "gpt-5.6-luna"

@patch("email_utils.openai_spam_check.OpenAI")
def test_spam_detected(self, mock_openai_cls, tmp_path, monkeypatch):
_mock_config(tmp_path, monkeypatch, temperature=0.0)
Expand Down
Loading