diff --git a/camel/toolkits/search_toolkit.py b/camel/toolkits/search_toolkit.py index cac4db62d..491555c45 100644 --- a/camel/toolkits/search_toolkit.py +++ b/camel/toolkits/search_toolkit.py @@ -49,7 +49,9 @@ def search_wiki(self, entity: str) -> str: try: result = wikipedia.summary(entity, sentences=5, auto_suggest=False) except wikipedia.exceptions.DisambiguationError as e: - result = wikipedia.summary(e.options[0], sentences=5, auto_suggest=False) + result = wikipedia.summary( + e.options[0], sentences=5, auto_suggest=False + ) except wikipedia.exceptions.PageError: result = ( "There is no page in Wikipedia corresponding to entity " @@ -217,10 +219,13 @@ def search_google( # Iterate over 10 results found for i, search_item in enumerate(search_items, start=1): - if "og:description" in search_item["pagemap"]["metatags"][0]: - long_description = search_item["pagemap"]["metatags"][0][ - "og:description" - ] + if ( + "og:description" + in search_item["pagemap"]["metatags"][0] + ): + long_description = search_item["pagemap"]["metatags"][ + 0 + ]["og:description"] else: long_description = "N/A" # Get the page title @@ -349,7 +354,9 @@ def _parse_wolfram_result(self, result) -> Dict[str, Any]: return output - def _get_wolframalpha_step_by_step_solution(self, app_id: str, query: str) -> dict: + def _get_wolframalpha_step_by_step_solution( + self, app_id: str, query: str + ) -> dict: r"""Retrieve a step-by-step solution from the Wolfram Alpha API for a given query. diff --git a/examples/runtime/docker_runtime.py b/examples/runtime/docker_runtime.py index 745999a0d..1c96e7184 100644 --- a/examples/runtime/docker_runtime.py +++ b/examples/runtime/docker_runtime.py @@ -12,7 +12,7 @@ # limitations under the License. # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== from camel.runtime import DockerRuntime -from camel.toolkits import MathToolkit, CodeExecutionToolkit +from camel.toolkits import CodeExecutionToolkit, MathToolkit if __name__ == "__main__": runtime = ( diff --git a/test/runtime/test_code_execution_with_llm_guard_runtime.py b/test/runtime/test_code_execution_with_llm_guard_runtime.py index b9d335650..1b6011cd6 100644 --- a/test/runtime/test_code_execution_with_llm_guard_runtime.py +++ b/test/runtime/test_code_execution_with_llm_guard_runtime.py @@ -11,8 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== -import pytest -from colorama import Fore from camel.agents import ChatAgent from camel.configs import ChatGPTConfig @@ -21,7 +19,7 @@ from camel.runtime import LLMGuardRuntime from camel.toolkits.code_execution import CodeExecutionToolkit from camel.types import ModelPlatformType, ModelType -from camel.utils import print_text_animated + def test_code_execution_with_llm_guard_runtime(): runtime = LLMGuardRuntime(verbose=True).add( @@ -67,7 +65,8 @@ def test_code_execution_with_llm_guard_runtime(): prompt = ( "Weng earns $12 an hour for babysitting. " - "Yesterday, she just did 51 minutes of babysitting. How much did she earn?" + "Yesterday, she just did 51 minutes of babysitting." + "How much did she earn?" ) user_msg = BaseMessage.make_user_message(role_name="User", content=prompt) diff --git a/test/runtime/test_docker_runtime.py b/test/runtime/test_docker_runtime.py index 992be4f41..1c27ba5d2 100644 --- a/test/runtime/test_docker_runtime.py +++ b/test/runtime/test_docker_runtime.py @@ -12,8 +12,9 @@ # limitations under the License. # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== import pytest + from camel.runtime import DockerRuntime -from camel.toolkits import MathToolkit, CodeExecutionToolkit +from camel.toolkits import CodeExecutionToolkit, MathToolkit @pytest.mark.skip(reason="Need Docker environment to run this test.") @@ -28,7 +29,9 @@ def test_docker_runtime(): ) ) - with runtime as r: # using with statement to automatically close the runtime + with ( + runtime as r + ): # using with statement to automatically close the runtime print("Waiting for runtime to be ready...") r.wait() print("Runtime is ready.") @@ -48,6 +51,3 @@ def test_docker_runtime(): assert mul.func(a=2, b=3) == 6 assert r.docs == "http://localhost:8000/docs" - - - diff --git a/test/runtime/test_remote_http_runtime.py b/test/runtime/test_remote_http_runtime.py index 2365d01e8..f739fa577 100644 --- a/test/runtime/test_remote_http_runtime.py +++ b/test/runtime/test_remote_http_runtime.py @@ -11,10 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== -import pytest from camel.runtime import RemoteHttpRuntime from camel.toolkits import MathToolkit + def test_remote_http_runtime(): runtime = ( RemoteHttpRuntime("localhost") @@ -31,4 +31,3 @@ def test_remote_http_runtime(): assert mul.func(2, 3) == 6 assert runtime.docs == "http://localhost:8000/docs" -