-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement integration tests for models `claude` and `gemini` * Implement integration tests for agents using `claude` and `gemini` * Add invoke tasks to run individual tests * Add integration tests to github CI pipeline Add integration tests Update Update Update
- Loading branch information
Showing
14 changed files
with
543 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from pathlib import Path | ||
|
||
TEST_ROOT_PATH = Path(__file__).parent.resolve() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import time | ||
|
||
from google import genai | ||
|
||
|
||
def rerun_on_google_genai_resource_exhausted(wait_time_s: float): | ||
def _filter(err, name, test, plugin): | ||
err_class, err_value, _ = err | ||
match err_class: | ||
case genai.errors.ClientError: | ||
time.sleep(wait_time_s) | ||
return "RESOURCE_EXHAUSTED" in str(err_value) | ||
case _: | ||
return False | ||
|
||
return _filter |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class UserRepository(ABC): | ||
@abstractmethod | ||
def find_user_name(self, user_id: str) -> str: | ||
"""Finds the name of a user in the user repository. | ||
Args: | ||
user_id (str): The id of the user to find. | ||
Returns: | ||
str: The name of the user. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def find_user_email(self, user_id: str, invalidate_cache: bool = False) -> str: | ||
"""Finds the email of a user in the user repository. | ||
Args: | ||
user_id (str): The id of the user to find. | ||
invalidate_cache (bool): Whether to invalidate all the caches before lookup. | ||
Should typically be left as False unless explicitly needed. | ||
Returns: | ||
str: The email of the user. | ||
""" | ||
pass | ||
|
||
|
||
def create_user_repository() -> UserRepository: | ||
""" | ||
Creates a new instance of the UserRepository tool. | ||
""" | ||
from .impl import UserRepositoryImpl | ||
|
||
return UserRepositoryImpl() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from .api import UserRepository | ||
|
||
USER_ID = "user-123" | ||
|
||
|
||
class UserRepositoryImpl(UserRepository): | ||
def find_user_name(self, user_id: str) -> str: | ||
if user_id.lower().strip() == USER_ID: | ||
return "user_a37c1f54" | ||
|
||
raise ValueError(f"User {user_id} not found") | ||
|
||
def find_user_email(self, user_id: str, invalidate_cache: bool = False) -> str: | ||
if not invalidate_cache: | ||
raise ValueError("You must invalidate the cache to get the email address") | ||
|
||
if user_id.lower().strip() == USER_ID: | ||
return "[email protected]" | ||
|
||
raise ValueError(f"User {user_id} not found") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from unittest.mock import AsyncMock, MagicMock | ||
|
||
import pytest | ||
from dotenv import load_dotenv | ||
|
||
from freeact.logger import Logger | ||
from freeact.model.claude.model import Claude | ||
from freeact.model.gemini.model.chat import Gemini | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def load_env(): | ||
load_dotenv() | ||
|
||
|
||
@pytest.fixture | ||
def logger(): | ||
logger = MagicMock(spec=Logger) | ||
logger.context = MagicMock() | ||
logger.context.return_value.__aenter__ = AsyncMock() | ||
logger.context.return_value.__aexit__ = AsyncMock() | ||
logger.log = AsyncMock() | ||
return logger | ||
|
||
|
||
@pytest.fixture | ||
def claude(logger): | ||
return Claude( | ||
logger=logger, | ||
model_name="claude-3-5-haiku-20241022", | ||
prompt_caching=False, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def gemini(): | ||
return Gemini( | ||
model_name="gemini-2.0-flash-exp", | ||
temperature=0.0, | ||
max_tokens=1024, | ||
) |
Oops, something went wrong.