Skip to content

Commit

Permalink
community - update ShuttleAI related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cobycloud committed Sep 24, 2024
1 parent ef03126 commit 03988d2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkgs/community/tests/unit/llms/ShuttleAIModel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_default_name():
model = LLM(api_key = API_KEY)
assert model.name == 'shuttle-2-turbo'

@pytest.mark.experimental
@pytest.mark.unit
@pytest.mark.skipif(not os.getenv('SHUTTLEAI_API_KEY'), reason="Skipping due to environment variable not set")
def test_no_system_context():
API_KEY = os.getenv('SHUTTLEAI_API_KEY')
Expand All @@ -50,7 +50,7 @@ def test_no_system_context():
prediction = conversation.get_last().content
assert type(prediction) == str

@pytest.mark.experimental
@pytest.mark.unit
@pytest.mark.skipif(not os.getenv('SHUTTLEAI_API_KEY'), reason="Skipping due to environment variable not set")
def test_nonpreamble_system_context():
API_KEY = os.getenv('SHUTTLEAI_API_KEY')
Expand Down Expand Up @@ -80,7 +80,7 @@ def test_nonpreamble_system_context():
assert 'Jeff' in prediction


@pytest.mark.experimental
@pytest.mark.unit
@pytest.mark.skipif(not os.getenv('SHUTTLEAI_API_KEY'), reason="Skipping due to environment variable not set")
def test_preamble_system_context():
API_KEY = os.getenv('SHUTTLEAI_API_KEY')
Expand All @@ -100,7 +100,7 @@ def test_preamble_system_context():
assert type(prediction) == str
assert 'Jeff' in prediction

@pytest.mark.experimental
@pytest.mark.unit
@pytest.mark.skipif(not os.getenv('SHUTTLEAI_API_KEY'), reason="Skipping due to environment variable not set")
def test_multiple_system_contexts():
API_KEY = os.getenv('SHUTTLEAI_API_KEY')
Expand Down
51 changes: 51 additions & 0 deletions pkgs/community/tests/unit/llms/ShuttleAIModel_unit_test.py
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

0 comments on commit 03988d2

Please sign in to comment.