mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 17:55:01 +00:00
fix failing tests
This commit is contained in:
parent
9ceaf97f08
commit
90d5071709
2 changed files with 16 additions and 13 deletions
|
@ -12,6 +12,7 @@ def is_image_file(file_name):
|
|||
:param file_name: The name of the file to check.
|
||||
:return: True if the file is an image, False otherwise.
|
||||
"""
|
||||
file_name = str(file_name) # Convert file_name to string
|
||||
return any(file_name.endswith(ext) for ext in IMAGE_EXTENSIONS)
|
||||
|
||||
|
||||
|
@ -50,4 +51,6 @@ def is_gpt4_with_openai_base_url(model_name, client):
|
|||
:param client: The OpenAI client instance.
|
||||
:return: True if conditions are met, False otherwise.
|
||||
"""
|
||||
if client is None or not hasattr(client, 'base_url'):
|
||||
return False
|
||||
return model_name.startswith("gpt-4") and "api.openai.com" in client.base_url.host
|
||||
|
|
|
@ -29,19 +29,19 @@ class TestModels(unittest.TestCase):
|
|||
|
||||
def test_openrouter_model_properties(self):
|
||||
client = MagicMock()
|
||||
client.models.list.return_value = {
|
||||
"data": [
|
||||
{
|
||||
"id": "openai/gpt-4",
|
||||
"object": "model",
|
||||
"context_length": "8192",
|
||||
"pricing": {"prompt": "0.00006", "completion": "0.00012"},
|
||||
}
|
||||
]
|
||||
}
|
||||
client.models.list.return_value = type(
|
||||
"", (), {"data": client.models.list.return_value["data"]}
|
||||
)()
|
||||
class ModelData:
|
||||
def __init__(self, id, object, context_length, pricing):
|
||||
self.id = id
|
||||
self.object = object
|
||||
self.context_length = context_length
|
||||
self.pricing = pricing
|
||||
|
||||
model_data = ModelData("openai/gpt-4", "model", "8192", {"prompt": "0.00006", "completion": "0.00012"})
|
||||
class ModelList:
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
client.models.list.return_value = ModelList([model_data])
|
||||
|
||||
model = OpenRouterModel(client, "gpt-4")
|
||||
self.assertEqual(model.name, "openai/gpt-4")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue