Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add model selection support for Anthropic handler #124 #125

Merged
merged 2 commits into from
Dec 29, 2024
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
2 changes: 1 addition & 1 deletion readmeai/models/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def __init__(
) -> None:
super().__init__(config_loader, context)
self.client: Optional[Any] = None
self.model: str = "claude-3-opus-20240229"
if ANTHROPIC_AVAILABLE:
self._model_settings()
else:
Expand All @@ -63,6 +62,7 @@ def _model_settings(self):
return

self.client = anthropic.AsyncAnthropic(api_key=api_key)
self.model = self.config.llm.model

async def _build_payload(self, prompt: str, tokens: int) -> dict[str, Any]:
"""Build payload for POST request to the Anthropic API."""
Expand Down
2 changes: 2 additions & 0 deletions tests/models/test_anthropic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from unittest.mock import AsyncMock, MagicMock, patch

import anthropic
Expand All @@ -22,6 +23,7 @@ def anthropic_handler(repository_context_fixture: RepositoryContext):
pytest.skip("Anthropic library is not available")
config_loader = ConfigLoader()
context = repository_context_fixture
os.environ["ANTHROPIC_API_KEY"] = "test"
return AnthropicHandler(config_loader, context)


Expand Down
Loading