-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
community - update ShuttleAI related tests
- Loading branch information
Showing
2 changed files
with
55 additions
and
4 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
51 changes: 51 additions & 0 deletions
51
pkgs/community/tests/unit/llms/ShuttleAIModel_unit_test.py
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,51 @@ | ||
import pytest | ||
import os | ||
from swarmauri.experimental.llms.ShuttleAIToolModel import ShuttleAIToolModel as LLM | ||
from swarmauri.standard.conversations.concrete.Conversation import Conversation | ||
from swarmauri.standard.tools.concrete.AdditionTool import AdditionTool | ||
from swarmauri.standard.toolkits.concrete.Toolkit import Toolkit | ||
from swarmauri.standard.agents.concrete.ToolAgent import ToolAgent | ||
|
||
@pytest.mark.unit | ||
@pytest.mark.skipif(not os.getenv('SHUTTLEAI_API_KEY'), reason="Skipping due to environment variable not set") | ||
def test_ubc_resource(): | ||
API_KEY = os.getenv('SHUTTLEAI_API_KEY') | ||
llm = LLM(api_key = API_KEY) | ||
assert llm.resource == 'LLM' | ||
|
||
@pytest.mark.unit | ||
@pytest.mark.skipif(not os.getenv('SHUTTLEAI_API_KEY'), reason="Skipping due to environment variable not set") | ||
def test_ubc_type(): | ||
API_KEY = os.getenv('SHUTTLEAI_API_KEY') | ||
llm = LLM(api_key = API_KEY) | ||
assert llm.type == 'ShuttleAIToolModel' | ||
|
||
@pytest.mark.unit | ||
@pytest.mark.skipif(not os.getenv('SHUTTLEAI_API_KEY'), reason="Skipping due to environment variable not set") | ||
def test_serialization(): | ||
API_KEY = os.getenv('SHUTTLEAI_API_KEY') | ||
llm = LLM(api_key = API_KEY) | ||
assert llm.id == LLM.model_validate_json(llm.model_dump_json()).id | ||
|
||
@pytest.mark.unit | ||
@pytest.mark.skipif(not os.getenv('SHUTTLEAI_API_KEY'), reason="Skipping due to environment variable not set") | ||
def test_default_name(): | ||
API_KEY = os.getenv('SHUTTLEAI_API_KEY') | ||
model = LLM(api_key = API_KEY) | ||
assert model.name == 'shuttle-2-turbo' | ||
|
||
@pytest.mark.unit | ||
@pytest.mark.skipif(not os.getenv('SHUTTLEAI_API_KEY'), reason="Skipping due to environment variable not set") | ||
def test_agent_exec(): | ||
API_KEY = os.getenv('SHUTTLEAI_API_KEY') | ||
llm = LLM(api_key = API_KEY) | ||
conversation = Conversation() | ||
toolkit = Toolkit() | ||
tool = AdditionTool() | ||
toolkit.add_tool(tool) | ||
|
||
agent = ToolAgent(llm=llm, | ||
conversation=conversation, | ||
toolkit=toolkit) | ||
result = agent.exec('Add 512+671') | ||
assert type(result) == str |