habermas-machine 0.1.1.dev0__tar.gz → 0.1.2.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/.github/workflows/ci.yml +6 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/.github/workflows/publish-pypi.yml +1 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/PKG-INFO +1 -1
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/_version.py +3 -3
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/llm_client/anthropic_client.py +3 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/llm_client/togetherai_client.py +3 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine.egg-info/PKG-INFO +1 -1
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine.egg-info/scm_file_list.json +36 -36
- habermas_machine-0.1.2.dev0/src/habermas_machine.egg-info/scm_version.json +8 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/test_anthropic_client.py +20 -17
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/test_ranking_models.py +2 -2
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/test_statement_models.py +2 -2
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/test_togetherai_client.py +30 -26
- habermas_machine-0.1.1.dev0/src/habermas_machine.egg-info/scm_version.json +0 -8
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/.env.example +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/.gitignore +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/.python-version +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/LICENSE +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/README.md +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/pyproject.toml +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/setup.cfg +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/__init__.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/llm_client/__init__.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/llm_client/aistudio_client.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/llm_client/base_client.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/llm_client/mock_client.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/llm_client/utils.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/machine.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/models.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/prompts.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/prompts_i18n.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/reward_model/__init__.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/reward_model/base_model.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/reward_model/cot_ranking_model.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/reward_model/finetuned_reward_model.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/reward_model/length_based_model.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/reward_model/mock_ranking_model.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/reward_model/utils.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/social_choice/__init__.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/social_choice/approval_method.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/social_choice/base_method.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/social_choice/maximal_lotteries.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/social_choice/mock_method.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/social_choice/schulze_method.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/social_choice/utils.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/statement_model/__init__.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/statement_model/base_model.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/statement_model/cot_model.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/statement_model/mock_statement_model.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/statement_model/two_step_diverse_model.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/types.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/utils.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine.egg-info/SOURCES.txt +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine.egg-info/dependency_links.txt +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine.egg-info/requires.txt +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine.egg-info/top_level.txt +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/README.md +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/social_choice/test_approval_method.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/social_choice/test_base_method.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/social_choice/test_maximal_lotteries.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/social_choice/test_mock_method.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/social_choice/test_schulze_method.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/social_choice/test_social_choice_utils.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/test_machine.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/test_package_utils.py +0 -0
- {habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/uv.lock +0 -0
|
@@ -12,6 +12,7 @@ permissions:
|
|
|
12
12
|
|
|
13
13
|
jobs:
|
|
14
14
|
test:
|
|
15
|
+
environment: llm_api_tests
|
|
15
16
|
runs-on: ubuntu-latest
|
|
16
17
|
strategy:
|
|
17
18
|
fail-fast: false
|
|
@@ -22,6 +23,7 @@ jobs:
|
|
|
22
23
|
- uses: actions/checkout@v7
|
|
23
24
|
with:
|
|
24
25
|
fetch-depth: 0
|
|
26
|
+
fetch-tags: true
|
|
25
27
|
|
|
26
28
|
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
|
|
27
29
|
with:
|
|
@@ -31,6 +33,9 @@ jobs:
|
|
|
31
33
|
run: uv sync --group dev --extra all
|
|
32
34
|
|
|
33
35
|
- name: Run tests
|
|
36
|
+
env:
|
|
37
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
38
|
+
TOGETHER_API_KEY: ${{ secrets.TOGETHER_API_KEY }}
|
|
34
39
|
run: uv run pytest
|
|
35
40
|
|
|
36
41
|
build-and-test-publish:
|
|
@@ -44,6 +49,7 @@ jobs:
|
|
|
44
49
|
- uses: actions/checkout@v7
|
|
45
50
|
with:
|
|
46
51
|
fetch-depth: 0
|
|
52
|
+
fetch-tags: true
|
|
47
53
|
|
|
48
54
|
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
|
|
49
55
|
with:
|
{habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/_version.py
RENAMED
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.1.
|
|
22
|
-
__version_tuple__ = version_tuple = (0, 1,
|
|
21
|
+
__version__ = version = '0.1.2.dev0'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 2, 'dev0')
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'g721f938cf'
|
|
@@ -57,6 +57,9 @@ class AnthropicClient(base_client.LLMClient):
|
|
|
57
57
|
),
|
|
58
58
|
)
|
|
59
59
|
|
|
60
|
+
if self._model_name not in [m.id for m in self._client.models.list()]:
|
|
61
|
+
raise ValueError(f"Anthropic client doesn't support model {self._model_name}")
|
|
62
|
+
|
|
60
63
|
@override
|
|
61
64
|
def sample_text(
|
|
62
65
|
self,
|
|
@@ -32,6 +32,9 @@ class TogetherAIClient(base_client.LLMClient):
|
|
|
32
32
|
load_dotenv()
|
|
33
33
|
self._model_name = model_name
|
|
34
34
|
self._client = Together(api_key=os.environ.get("TOGETHER_API_KEY"))
|
|
35
|
+
if self._model_name not in [m.id for m in self._client.models.list() if m.type == "chat"]:
|
|
36
|
+
raise ValueError(f"Together Client doesn't support model {self._model_name}")
|
|
37
|
+
|
|
35
38
|
self._tmp_dir = tmp_dir or tempfile.gettempdir()
|
|
36
39
|
|
|
37
40
|
@override
|
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": [
|
|
3
|
+
".gitignore",
|
|
4
|
+
".python-version",
|
|
5
|
+
".env.example",
|
|
3
6
|
"README.md",
|
|
7
|
+
"pyproject.toml",
|
|
4
8
|
"uv.lock",
|
|
5
|
-
".python-version",
|
|
6
9
|
"LICENSE",
|
|
7
|
-
"
|
|
8
|
-
".
|
|
9
|
-
".
|
|
10
|
+
"src/habermas_machine/_version.py",
|
|
11
|
+
"src/habermas_machine/types.py",
|
|
12
|
+
"src/habermas_machine/utils.py",
|
|
13
|
+
"src/habermas_machine/prompts_i18n.py",
|
|
10
14
|
"src/habermas_machine/prompts.py",
|
|
11
|
-
"src/habermas_machine/__init__.py",
|
|
12
15
|
"src/habermas_machine/models.py",
|
|
13
|
-
"src/habermas_machine/
|
|
16
|
+
"src/habermas_machine/__init__.py",
|
|
14
17
|
"src/habermas_machine/machine.py",
|
|
15
|
-
"src/habermas_machine/
|
|
16
|
-
"src/habermas_machine/
|
|
17
|
-
"src/habermas_machine/
|
|
18
|
-
"src/habermas_machine/
|
|
19
|
-
"src/habermas_machine/
|
|
20
|
-
"src/habermas_machine/
|
|
21
|
-
"src/habermas_machine/
|
|
22
|
-
"src/habermas_machine/
|
|
23
|
-
"src/habermas_machine/reward_model/base_model.py",
|
|
24
|
-
"src/habermas_machine/reward_model/__init__.py",
|
|
18
|
+
"src/habermas_machine/social_choice/base_method.py",
|
|
19
|
+
"src/habermas_machine/social_choice/mock_method.py",
|
|
20
|
+
"src/habermas_machine/social_choice/approval_method.py",
|
|
21
|
+
"src/habermas_machine/social_choice/utils.py",
|
|
22
|
+
"src/habermas_machine/social_choice/schulze_method.py",
|
|
23
|
+
"src/habermas_machine/social_choice/maximal_lotteries.py",
|
|
24
|
+
"src/habermas_machine/social_choice/__init__.py",
|
|
25
|
+
"src/habermas_machine/reward_model/length_based_model.py",
|
|
25
26
|
"src/habermas_machine/reward_model/cot_ranking_model.py",
|
|
27
|
+
"src/habermas_machine/reward_model/finetuned_reward_model.py",
|
|
26
28
|
"src/habermas_machine/reward_model/utils.py",
|
|
29
|
+
"src/habermas_machine/reward_model/base_model.py",
|
|
27
30
|
"src/habermas_machine/reward_model/mock_ranking_model.py",
|
|
28
|
-
"src/habermas_machine/reward_model/
|
|
29
|
-
"src/habermas_machine/reward_model/finetuned_reward_model.py",
|
|
30
|
-
"src/habermas_machine/llm_client/__init__.py",
|
|
31
|
-
"src/habermas_machine/llm_client/togetherai_client.py",
|
|
31
|
+
"src/habermas_machine/reward_model/__init__.py",
|
|
32
32
|
"src/habermas_machine/llm_client/aistudio_client.py",
|
|
33
33
|
"src/habermas_machine/llm_client/utils.py",
|
|
34
34
|
"src/habermas_machine/llm_client/base_client.py",
|
|
35
35
|
"src/habermas_machine/llm_client/mock_client.py",
|
|
36
|
+
"src/habermas_machine/llm_client/togetherai_client.py",
|
|
36
37
|
"src/habermas_machine/llm_client/anthropic_client.py",
|
|
37
|
-
"src/habermas_machine/
|
|
38
|
-
"src/habermas_machine/
|
|
39
|
-
"src/habermas_machine/
|
|
40
|
-
"src/habermas_machine/
|
|
41
|
-
"src/habermas_machine/
|
|
42
|
-
"src/habermas_machine/
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"tests/test_statement_models.py",
|
|
46
|
-
"tests/README.md",
|
|
47
|
-
"tests/test_machine.py",
|
|
38
|
+
"src/habermas_machine/llm_client/__init__.py",
|
|
39
|
+
"src/habermas_machine/statement_model/cot_model.py",
|
|
40
|
+
"src/habermas_machine/statement_model/mock_statement_model.py",
|
|
41
|
+
"src/habermas_machine/statement_model/base_model.py",
|
|
42
|
+
"src/habermas_machine/statement_model/two_step_diverse_model.py",
|
|
43
|
+
"src/habermas_machine/statement_model/__init__.py",
|
|
44
|
+
".github/workflows/ci.yml",
|
|
45
|
+
".github/workflows/publish-pypi.yml",
|
|
48
46
|
"tests/test_package_utils.py",
|
|
47
|
+
"tests/README.md",
|
|
49
48
|
"tests/test_togetherai_client.py",
|
|
49
|
+
"tests/test_machine.py",
|
|
50
|
+
"tests/test_statement_models.py",
|
|
50
51
|
"tests/test_ranking_models.py",
|
|
52
|
+
"tests/test_anthropic_client.py",
|
|
53
|
+
"tests/social_choice/test_mock_method.py",
|
|
51
54
|
"tests/social_choice/test_maximal_lotteries.py",
|
|
52
|
-
"tests/social_choice/test_approval_method.py",
|
|
53
|
-
"tests/social_choice/test_base_method.py",
|
|
54
55
|
"tests/social_choice/test_social_choice_utils.py",
|
|
56
|
+
"tests/social_choice/test_base_method.py",
|
|
55
57
|
"tests/social_choice/test_schulze_method.py",
|
|
56
|
-
"tests/social_choice/
|
|
57
|
-
".github/workflows/ci.yml",
|
|
58
|
-
".github/workflows/publish-pypi.yml"
|
|
58
|
+
"tests/social_choice/test_approval_method.py"
|
|
59
59
|
]
|
|
60
60
|
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
These tests require ANTHROPIC_API_KEY to be set in the environment.
|
|
19
19
|
Tests will be skipped if the API key is not available.
|
|
20
20
|
"""
|
|
21
|
+
from unittest.mock import patch
|
|
21
22
|
|
|
22
23
|
import pytest
|
|
23
24
|
import os
|
|
@@ -37,31 +38,33 @@ class TestAnthropicClientInitialization:
|
|
|
37
38
|
reason="ANTHROPIC_API_KEY not set in environment")
|
|
38
39
|
def test_initialization_with_api_key(self):
|
|
39
40
|
"""Test that AnthropicClient initializes correctly with API key."""
|
|
40
|
-
client = AnthropicClient(model_name="claude-
|
|
41
|
+
client = AnthropicClient(model_name="claude-haiku-4-5-20251001")
|
|
41
42
|
|
|
42
43
|
assert client._client is not None
|
|
43
|
-
assert client._model_name == "claude-
|
|
44
|
+
assert client._model_name == "claude-haiku-4-5-20251001"
|
|
44
45
|
assert client._api_key is not None
|
|
45
46
|
|
|
46
47
|
@pytest.mark.skipif(not ANTHROPIC_API_KEY_AVAILABLE,
|
|
47
48
|
reason="ANTHROPIC_API_KEY not set in environment")
|
|
48
49
|
def test_model_name_property(self):
|
|
49
50
|
"""Test that model_name property is accessible."""
|
|
50
|
-
client = AnthropicClient(model_name="claude-
|
|
51
|
-
assert client.model_name == "claude-
|
|
51
|
+
client = AnthropicClient(model_name="claude-haiku-4-5-20251001")
|
|
52
|
+
assert client.model_name == "claude-haiku-4-5-20251001"
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
@pytest.mark.skipif(not ANTHROPIC_API_KEY_AVAILABLE,
|
|
55
|
+
reason="ANTHROPIC_API_KEY not set in environment")
|
|
56
|
+
def test_bad_model_name_fails(self):
|
|
57
|
+
"""Test that model_name property is accessible."""
|
|
58
|
+
with pytest.raises(ValueError):
|
|
59
|
+
AnthropicClient(model_name="a-cheese-with-a-frown")
|
|
60
|
+
|
|
61
|
+
def test_initialization_without_api_key(self, monkeypatch):
|
|
54
62
|
"""Test that initialization fails gracefully without API key."""
|
|
55
63
|
# Temporarily remove the API key if it exists
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
try:
|
|
64
|
+
monkeypatch.delenv("ANTHROPIC_API_KEY", raising=False)
|
|
65
|
+
with patch("habermas_machine.llm_client.anthropic_client.load_dotenv", return_value=None):
|
|
59
66
|
with pytest.raises(KeyError):
|
|
60
|
-
AnthropicClient(model_name="claude-
|
|
61
|
-
finally:
|
|
62
|
-
# Restore the API key if it was set
|
|
63
|
-
if original_key is not None:
|
|
64
|
-
os.environ['ANTHROPIC_API_KEY'] = original_key
|
|
67
|
+
AnthropicClient(model_name="claude-haiku-4-5-20251001")
|
|
65
68
|
|
|
66
69
|
|
|
67
70
|
@pytest.mark.skipif(not ANTHROPIC_API_KEY_AVAILABLE,
|
|
@@ -76,7 +79,7 @@ class TestAnthropicClientSampling:
|
|
|
76
79
|
@pytest.fixture
|
|
77
80
|
def client(self):
|
|
78
81
|
"""Set up test fixtures."""
|
|
79
|
-
return AnthropicClient(model_name="claude-
|
|
82
|
+
return AnthropicClient(model_name="claude-haiku-4-5-20251001")
|
|
80
83
|
|
|
81
84
|
def test_sample_text_basic(self, client):
|
|
82
85
|
"""Test basic text sampling."""
|
|
@@ -127,7 +130,7 @@ class TestAnthropicClientBatchSampling:
|
|
|
127
130
|
@pytest.fixture
|
|
128
131
|
def client(self):
|
|
129
132
|
"""Set up test fixtures."""
|
|
130
|
-
return AnthropicClient(model_name="claude-
|
|
133
|
+
return AnthropicClient(model_name="claude-haiku-4-5-20251001")
|
|
131
134
|
|
|
132
135
|
def test_sample_many_basic(self, client):
|
|
133
136
|
"""Test sample_many method with multiple prompts."""
|
|
@@ -178,7 +181,7 @@ class TestAnthropicClientMockable:
|
|
|
178
181
|
reason="ANTHROPIC_API_KEY not set in environment")
|
|
179
182
|
def test_client_has_required_methods(self):
|
|
180
183
|
"""Test that client implements required base class methods."""
|
|
181
|
-
client = AnthropicClient(model_name="claude-
|
|
184
|
+
client = AnthropicClient(model_name="claude-haiku-4-5-20251001")
|
|
182
185
|
|
|
183
186
|
# Check that required methods exist
|
|
184
187
|
assert hasattr(client, 'sample_text')
|
|
@@ -194,5 +197,5 @@ class TestAnthropicClientMockable:
|
|
|
194
197
|
reason="ANTHROPIC_API_KEY not set in environment")
|
|
195
198
|
def test_client_inherits_from_base(self):
|
|
196
199
|
"""Test that AnthropicClient inherits from LLMClient."""
|
|
197
|
-
client = AnthropicClient(model_name="claude-
|
|
200
|
+
client = AnthropicClient(model_name="claude-haiku-4-5-20251001")
|
|
198
201
|
assert isinstance(client, base_client.LLMClient)
|
|
@@ -199,7 +199,7 @@ class TestCOTRankingModelWithAnthropicIntegration:
|
|
|
199
199
|
@pytest.fixture
|
|
200
200
|
def cot_ranking_model(self):
|
|
201
201
|
"""Fixture for COTRankingModel with Anthropic."""
|
|
202
|
-
client = AnthropicClient(model_name="claude-
|
|
202
|
+
client = AnthropicClient(model_name="claude-haiku-4-5-20251001")
|
|
203
203
|
return COTRankingModel(llm_client=client, prompt_name="DEFAULT_RANKING")
|
|
204
204
|
|
|
205
205
|
def test_predict_ranking_integration(self, cot_ranking_model):
|
|
@@ -269,7 +269,7 @@ class TestCOTRankingModelWithTogetherAIIntegration:
|
|
|
269
269
|
@pytest.fixture
|
|
270
270
|
def cot_ranking_model(self):
|
|
271
271
|
"""Fixture for COTRankingModel with TogetherAI."""
|
|
272
|
-
client = TogetherAIClient(model_name="
|
|
272
|
+
client = TogetherAIClient(model_name="openai/gpt-oss-20b")
|
|
273
273
|
return COTRankingModel(llm_client=client, prompt_name="DEFAULT_RANKING")
|
|
274
274
|
|
|
275
275
|
def test_predict_ranking_integration(self, cot_ranking_model):
|
|
@@ -236,7 +236,7 @@ class TestCOTModelWithAnthropicIntegration:
|
|
|
236
236
|
@pytest.fixture
|
|
237
237
|
def cot_model(self):
|
|
238
238
|
"""Fixture for COTModel with Anthropic."""
|
|
239
|
-
client = AnthropicClient(model_name="claude-
|
|
239
|
+
client = AnthropicClient(model_name="claude-haiku-4-5-20251001")
|
|
240
240
|
return COTModel(llm_client=client, prompt_name="DEFAULT_STATEMENT")
|
|
241
241
|
|
|
242
242
|
def test_generate_statement_integration(self, cot_model):
|
|
@@ -270,7 +270,7 @@ class TestCOTModelWithTogetherAIIntegration:
|
|
|
270
270
|
@pytest.fixture
|
|
271
271
|
def cot_model(self):
|
|
272
272
|
"""Fixture for COTModel with TogetherAI."""
|
|
273
|
-
client = TogetherAIClient(model_name="
|
|
273
|
+
client = TogetherAIClient(model_name="openai/gpt-oss-20b")
|
|
274
274
|
return COTModel(llm_client=client, prompt_name="DEFAULT_STATEMENT")
|
|
275
275
|
|
|
276
276
|
def test_generate_statement_integration(self, cot_model):
|
|
@@ -18,10 +18,13 @@
|
|
|
18
18
|
These tests require TOGETHER_API_KEY to be set in the environment.
|
|
19
19
|
Tests will be skipped if the API key is not available.
|
|
20
20
|
"""
|
|
21
|
+
from unittest.mock import patch
|
|
21
22
|
|
|
22
23
|
import pytest
|
|
23
24
|
import os
|
|
24
25
|
|
|
26
|
+
from together import TogetherError
|
|
27
|
+
|
|
25
28
|
from habermas_machine.llm_client.togetherai_client import TogetherAIClient
|
|
26
29
|
from habermas_machine.llm_client import base_client
|
|
27
30
|
|
|
@@ -37,31 +40,32 @@ class TestTogetherAIClientInitialization:
|
|
|
37
40
|
reason="TOGETHER_API_KEY not set in environment")
|
|
38
41
|
def test_initialization_with_api_key(self):
|
|
39
42
|
"""Test that TogetherAIClient initializes correctly with API key."""
|
|
40
|
-
client = TogetherAIClient(model_name="
|
|
43
|
+
client = TogetherAIClient(model_name="openai/gpt-oss-20b")
|
|
41
44
|
|
|
42
45
|
assert client._client is not None
|
|
43
|
-
assert client._model_name == "
|
|
46
|
+
assert client._model_name == "openai/gpt-oss-20b"
|
|
44
47
|
|
|
45
48
|
@pytest.mark.skipif(not TOGETHER_API_KEY_AVAILABLE,
|
|
46
49
|
reason="TOGETHER_API_KEY not set in environment")
|
|
47
50
|
def test_model_name_property(self):
|
|
48
51
|
"""Test that model_name property is accessible."""
|
|
49
|
-
client = TogetherAIClient(model_name="
|
|
50
|
-
assert client.model_name == "
|
|
52
|
+
client = TogetherAIClient(model_name="openai/gpt-oss-20b")
|
|
53
|
+
assert client.model_name == "openai/gpt-oss-20b"
|
|
54
|
+
|
|
55
|
+
@pytest.mark.skipif(not TOGETHER_API_KEY_AVAILABLE,
|
|
56
|
+
reason="TOGETHER_API_KEY not set in environment")
|
|
57
|
+
def test_model_name_property(self):
|
|
58
|
+
"""Test that model_name property is accessible."""
|
|
59
|
+
with pytest.raises(ValueError):
|
|
60
|
+
TogetherAIClient(model_name="a-cheese-with-a-frown")
|
|
51
61
|
|
|
52
|
-
def test_initialization_without_api_key(self):
|
|
53
|
-
"""Test that
|
|
62
|
+
def test_initialization_without_api_key(self, monkeypatch):
|
|
63
|
+
"""Test that initialization fails gracefully without API key."""
|
|
54
64
|
# Temporarily remove the API key if it exists
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
with pytest.raises(Exception): # TogetherError
|
|
60
|
-
TogetherAIClient(model_name="mistralai/Mixtral-8x7B-Instruct-v0.1")
|
|
61
|
-
finally:
|
|
62
|
-
# Restore the API key if it was set
|
|
63
|
-
if original_key is not None:
|
|
64
|
-
os.environ['TOGETHER_API_KEY'] = original_key
|
|
65
|
+
monkeypatch.delenv("TOGETHER_API_KEY", raising=False)
|
|
66
|
+
with patch("habermas_machine.llm_client.togetherai_client.load_dotenv", return_value=None):
|
|
67
|
+
with pytest.raises(TogetherError):
|
|
68
|
+
TogetherAIClient(model_name="openai/gpt-oss-20b")
|
|
65
69
|
|
|
66
70
|
|
|
67
71
|
@pytest.mark.skipif(not TOGETHER_API_KEY_AVAILABLE,
|
|
@@ -76,12 +80,12 @@ class TestTogetherAIClientSampling:
|
|
|
76
80
|
@pytest.fixture
|
|
77
81
|
def client(self):
|
|
78
82
|
"""Set up test fixtures."""
|
|
79
|
-
return TogetherAIClient(model_name="
|
|
83
|
+
return TogetherAIClient(model_name="openai/gpt-oss-20b")
|
|
80
84
|
|
|
81
85
|
def test_sample_text_basic(self, client):
|
|
82
86
|
"""Test basic text sampling."""
|
|
83
87
|
prompt = "Say 'Hello, World!' and nothing else."
|
|
84
|
-
response = client.sample_text(prompt, max_tokens=
|
|
88
|
+
response = client.sample_text(prompt, max_tokens=150)
|
|
85
89
|
|
|
86
90
|
assert isinstance(response, str)
|
|
87
91
|
assert len(response) > 0
|
|
@@ -89,7 +93,7 @@ class TestTogetherAIClientSampling:
|
|
|
89
93
|
def test_sample_text_with_max_tokens(self, client):
|
|
90
94
|
"""Test sampling with max_tokens parameter."""
|
|
91
95
|
prompt = "Count from 1 to 5."
|
|
92
|
-
response = client.sample_text(prompt, max_tokens=
|
|
96
|
+
response = client.sample_text(prompt, max_tokens=150)
|
|
93
97
|
|
|
94
98
|
assert isinstance(response, str)
|
|
95
99
|
assert len(response) > 0
|
|
@@ -99,7 +103,7 @@ class TestTogetherAIClientSampling:
|
|
|
99
103
|
prompt = "Write a short sentence about AI."
|
|
100
104
|
response = client.sample_text(
|
|
101
105
|
prompt,
|
|
102
|
-
max_tokens=
|
|
106
|
+
max_tokens=300,
|
|
103
107
|
temperature=0.5
|
|
104
108
|
)
|
|
105
109
|
|
|
@@ -115,7 +119,7 @@ class TestTogetherAIClientSampling:
|
|
|
115
119
|
# and print a warning
|
|
116
120
|
response = client.sample_text(
|
|
117
121
|
prompt,
|
|
118
|
-
max_tokens=
|
|
122
|
+
max_tokens=300,
|
|
119
123
|
terminators=terminators
|
|
120
124
|
)
|
|
121
125
|
|
|
@@ -139,7 +143,7 @@ class TestTogetherAIClientBatchSampling:
|
|
|
139
143
|
@pytest.fixture
|
|
140
144
|
def client(self):
|
|
141
145
|
"""Set up test fixtures."""
|
|
142
|
-
return TogetherAIClient(model_name="
|
|
146
|
+
return TogetherAIClient(model_name="openai/gpt-oss-20b")
|
|
143
147
|
|
|
144
148
|
def test_sample_many_basic(self, client):
|
|
145
149
|
"""Test sample_many method with multiple prompts."""
|
|
@@ -150,7 +154,7 @@ class TestTogetherAIClientBatchSampling:
|
|
|
150
154
|
|
|
151
155
|
responses = client.sample_many(
|
|
152
156
|
prompts,
|
|
153
|
-
max_tokens=
|
|
157
|
+
max_tokens=150,
|
|
154
158
|
temperature=0.7
|
|
155
159
|
)
|
|
156
160
|
|
|
@@ -170,7 +174,7 @@ class TestTogetherAIClientBatchSampling:
|
|
|
170
174
|
|
|
171
175
|
responses = client.batch_sample_text(
|
|
172
176
|
prompts,
|
|
173
|
-
max_tokens=
|
|
177
|
+
max_tokens=150,
|
|
174
178
|
temperature=0.7,
|
|
175
179
|
use_batch_api=False
|
|
176
180
|
)
|
|
@@ -192,7 +196,7 @@ class TestTogetherAIClientMockable:
|
|
|
192
196
|
reason="TOGETHER_API_KEY not set in environment")
|
|
193
197
|
def test_client_has_required_methods(self):
|
|
194
198
|
"""Test that client implements required base class methods."""
|
|
195
|
-
client = TogetherAIClient(model_name="
|
|
199
|
+
client = TogetherAIClient(model_name="openai/gpt-oss-20b")
|
|
196
200
|
|
|
197
201
|
# Check that required methods exist
|
|
198
202
|
assert hasattr(client, 'sample_text')
|
|
@@ -208,5 +212,5 @@ class TestTogetherAIClientMockable:
|
|
|
208
212
|
reason="TOGETHER_API_KEY not set in environment")
|
|
209
213
|
def test_client_inherits_from_base(self):
|
|
210
214
|
"""Test that TogetherAIClient inherits from LLMClient."""
|
|
211
|
-
client = TogetherAIClient(model_name="
|
|
215
|
+
client = TogetherAIClient(model_name="openai/gpt-oss-20b")
|
|
212
216
|
assert isinstance(client, base_client.LLMClient)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/llm_client/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/src/habermas_machine/prompts_i18n.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/social_choice/test_base_method.py
RENAMED
|
File without changes
|
|
File without changes
|
{habermas_machine-0.1.1.dev0 → habermas_machine-0.1.2.dev0}/tests/social_choice/test_mock_method.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|