-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add unit test for models.py
#247
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #247 +/- ##
==========================================
+ Coverage 76.23% 78.25% +2.02%
==========================================
Files 18 18
Lines 2845 2907 +62
==========================================
+ Hits 2169 2275 +106
+ Misses 676 632 -44 ☔ View full report in Codecov by Sentry. |
Thanks a lot, this is awesome! Let me know once this is ready for review (it's still marked as a draft) |
@@ -429,8 +430,7 @@ class OllamaModel(BaseModel): | |||
|
|||
def __init__(self, args: ModelArguments, commands: list[Command]): | |||
super().__init__(args, commands) | |||
from ollama import Client | |||
self.client = Client(host=args.host_url) | |||
self.client = OllamaClient(host=args.host_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned in the comment below, I changed it to a format that can be imported from tests like patch("sweagent.agent.models.OllamaClient")
.
@pytest.mark.parametrize("model_name", CLAUDE2_MODELS) | ||
def test_anthropic2_model(model_name, mock_anthropic2_response): | ||
with patch("sweagent.agent.models.config.Config"), \ | ||
patch("sweagent.agent.models.Anthropic") as mock_anthropic: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch here also works when specified as follows.
patch("anthropic.resources.messages.Messages.create")
While above format works, when we add a model, we need to look up the method file from the library. I thought this was difficult for both the implementer and the reviewer.
That's why I adopted this approach.
} | ||
|
||
|
||
def split_claude_model_by_version(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Claude-2, we were sending requests with completions.create()
, while for Claude-3, we were sending requests with messages.create()
, so we needed to separate the test cases and divide the models.
models.py
models.py
After merging #207, the Originally, the implementations of the
I read through the comments on #207, and I think this mixin format will not become redundant when adding other models. (e.g. Add Bedrock to cohere, meta.) I'm still new here, so I'm not sure if this PR follows the development rules here. If the PR is too large or the changes are too big, please feel free to comment! |
@klieret can we merge or close ? |
Reference Issues/PRs
Fixes #185
What does this implement/fix? Explain your changes.
claude-2.1
Any other comments?
There is a conflict with #236 , so I will resolve after #236 gets merged.
🧡 Thanks for contributing!