Merge pull request #291 from elder-plinius/master

pull/293/head
Eternal Reclaimer 1 year ago committed by GitHub
commit 4755bcf3cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,37 @@
try:
import multion
except ImportError:
raise ImportError(
"Cannot import multion, please install 'pip install'"
)
from swarms.models.base_llm import AbstractLLM
class MultiOn(AbstractLLM):
"""
MultiOn is a wrapper for the Multion API.
Args:
**kwargs:
Methods:
run(self, task: str, url: str, *args, **kwargs)
Example:
>>> from swarms.models.multion import MultiOn
>>> multion = MultiOn()
>>> multion.run("Order chicken tendies", "https://www.google.com/")
"Order chicken tendies. https://www.google.com/"
"""
def __init__(self, **kwargs):
super(MultiOn, self).__init__(**kwargs)
def run(self, task: str, url: str, *args, **kwargs) -> str:
response = multion.new_session({"input": task, "url": url})
return response
def generate_summary(self, task: str, url: str, *args, **kwargs) -> str:
response = multion.new_session({"input": task, "url": url})
return response

@ -0,0 +1,41 @@
import pytest
from unittest.mock import Mock, patch
from swarms.models.multion import MultiOn
@pytest.fixture
def multion_instance():
return MultiOn()
@pytest.fixture
def mock_multion():
return Mock()
def test_multion_import():
with pytest.raises(ImportError):
import multion
def test_multion_init():
multion = MultiOn()
assert isinstance(multion, MultiOn)
def test_multion_run_with_valid_input(multion_instance, mock_multion):
task = "Order chicken tendies"
url = "https://www.google.com/"
mock_multion.new_session.return_value = "Order chicken tendies. https://www.google.com/"
with patch('swarms.models.multion.multion', mock_multion):
response = multion_instance.run(task, url)
assert response == "Order chicken tendies. https://www.google.com/"
def test_multion_run_with_invalid_input(multion_instance, mock_multion):
task = ""
url = "https://www.google.com/"
mock_multion.new_session.return_value = None
with patch('swarms.models.multion.multion', mock_multion):
response = multion_instance.run(task, url)
assert response is None
# Add more test cases to cover different scenarios, edge cases, and error handling as needed.
Loading…
Cancel
Save