diff --git a/pypi-core/openplugincore/openplugin.py b/pypi-core/openplugincore/openplugin.py index 66c2a57..45de55d 100644 --- a/pypi-core/openplugincore/openplugin.py +++ b/pypi-core/openplugincore/openplugin.py @@ -1,3 +1,5 @@ +# C:\Projects\OpenPlugin\openplugin\pypi-core\openplugincore\openplugin.py + import json from urllib.error import HTTPError import requests diff --git a/pypi-core/openplugincore/openplugin_memo.py b/pypi-core/openplugincore/openplugin_memo.py index 50fce3d..39f846c 100644 --- a/pypi-core/openplugincore/openplugin_memo.py +++ b/pypi-core/openplugincore/openplugin_memo.py @@ -1,3 +1,5 @@ +# C:\Projects\OpenPlugin\openplugin\pypi-core\openplugincore\openplugin_memo.py + import requests from openplugincore import OpenPlugin import os @@ -19,17 +21,23 @@ def init(self): self.plugins_directory[key] = value print('MEMO READY') + def init_openplugin(self, plugin_name=None, root_url=None): + if not plugin_name and not root_url: + raise Exception('Plugin name not found') + plugin = OpenPlugin(plugin_name=plugin_name, root_url=root_url, openai_api_key=os.getenv('OPENAI_API_KEY')) + plugin.init() + return plugin + def init_plugin(self, plugin_name): if not self.plugins_directory: raise Exception('Plugin directory not initialized') plugin_url = self.plugins_directory.get(plugin_name) if plugin_url is None: raise Exception('Plugin not found') - plugin = OpenPlugin(plugin_name=plugin_name, openai_api_key=os.getenv('OPENAI_API_KEY')) - plugin.init() + plugin = self.init_openplugin(plugin_name=plugin_name) self.add_plugin(plugin) return plugin - + # method to add an OpenPlugin to the plugins map def add_plugin(self, plugin): if not plugin.name: diff --git a/pypi-core/setup.py b/pypi-core/setup.py index c18141d..8dfdf70 100644 --- a/pypi-core/setup.py +++ b/pypi-core/setup.py @@ -4,7 +4,7 @@ setup( # the name must match the folder name 'verysimplemodule' name='openplugincore', - version="0.6.3", + version="0.6.4", author="Sebastian Sosa", author_email="1sebastian1sosa1@gmail.com", description='Seamlessly integrate with OpenAI ChatGPT plugins via API (or client), offering the same powerful functionality as the ChatGPT api + plugins!', diff --git a/pypi-core/tests/test_e2e.py b/pypi-core/tests/test_e2e.py index fb25dbd..4662d12 100644 --- a/pypi-core/tests/test_e2e.py +++ b/pypi-core/tests/test_e2e.py @@ -255,30 +255,6 @@ def test_initiate_and_fetch_portfoliopilot(): # Replace the line below with a test for the final output in json_content assert isinstance(json_content["top_stocks"], list) -def test_initiate_and_fetch_C3_Glide(): - plugin = OpenPlugin("C3_Glide", verbose=True) - assert plugin.manifest is not None - - # create chatgpt request that will call the addTodo function - chatgpt_prompt = 'Provide me TAF for KJFK with reguards to aviation weather' - response = plugin.fetch_plugin( - messages=[ - { - "role": "user", - "content": chatgpt_prompt - } - ], - model="gpt-3.5-turbo-0613", - temperature=0, - ) - - assert response is not None - assert response["role"] == "function" - json_content = json.loads(response["content"]) - - # Replace the line below with a test for the final output in json_content - assert isinstance(json_content["tafs"], list) - @pytest.mark.skip(reason="Could not parse: requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1") def test_initiate_and_fetch_Ai_PDF(): plugin = OpenPlugin("Ai_PDF", verbose=True) @@ -304,6 +280,7 @@ def test_initiate_and_fetch_Ai_PDF(): # Replace the line below with a test for the final output in json_content assert isinstance(json_content[0], str) +@pytest.mark.skip(reason="requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1") def test_initiate_and_fetch_askyourpdf(): plugin = OpenPlugin("askyourpdf", verbose=True) assert plugin.manifest is not None diff --git a/pypi-core/tests/test_openplugin_memo.py b/pypi-core/tests/test_openplugin_memo.py index 6b13cbb..c60e4b5 100644 --- a/pypi-core/tests/test_openplugin_memo.py +++ b/pypi-core/tests/test_openplugin_memo.py @@ -46,3 +46,23 @@ def test_retrieve_plugins(): open_plugin_memo.remove_plugin('__testing__') todo_openplugin = open_plugin_memo.get_plugin('__testing__') assert todo_openplugin is None + +def test_root_url_full_suite(): + open_plugin_memo = OpenPluginMemo() + open_plugin_memo.init() + + todo_openplugin = open_plugin_memo.init_openplugin(root_url='http://127.0.0.1:3333') + assert todo_openplugin.manifest is not None + assert len(todo_openplugin.functions) == 2 + + response = todo_openplugin.fetch_plugin( + messages=todo_plugin["messages"], + model='gpt-3.5-turbo-0613', + ) + + assert response is not None + assert response['role'] == 'function' + assert response['name'] == 'addTodo' + + json_content = json.loads(response['content']) + assert json_content['todo'] == todo_plugin['request_out.json()']['todo'] \ No newline at end of file