Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DavdGao committed Nov 19, 2024
1 parent 56a7651 commit faf0e72
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/agentscope/service/service_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def bing_search(query: str, api_key: str, num_results: int=10):
"type": "function",
"function": {
"name": service_func.__name__,
"description": func_description,
"description": func_description.strip(),
"parameters": {
"type": "object",
"properties": properties_field,
Expand Down
47 changes: 40 additions & 7 deletions tests/service_toolkit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def setUp(self) -> None:
"""Init for ExampleTest."""
agentscope.init(disable_saving=True)

self.maxDiff = None

self.json_schema_bing_search1 = {
"type": "function",
"function": {
Expand Down Expand Up @@ -81,7 +83,7 @@ def setUp(self) -> None:
"type": "function",
"function": {
"name": "func",
"description": None,
"description": "",
"parameters": {
"type": "object",
"properties": {
Expand All @@ -103,7 +105,17 @@ def setUp(self) -> None:
"type": "function",
"function": {
"name": "execute_python_code",
"description": "Execute a piece of python code.",
"description": """Execute a piece of python code.
This function can run Python code provided in string format. It has the
option to execute the code within a Docker container to provide an
additional layer of security, especially important when running
untrusted code.
WARNING: If `use_docker` is set to `False`, the `code` will be run
directly in the host system's environment. This poses a potential
security risk if the code is untrusted. Only disable Docker if you are
confident in the safety of the code being executed.""",
"parameters": {
"type": "object",
"properties": {
Expand All @@ -123,7 +135,13 @@ def setUp(self) -> None:
"type": "function",
"function": {
"name": "retrieve_from_list",
"description": "Retrieve data in a list.",
"description": """Retrieve data in a list.
Memory retrieval with user-defined score function. The score function is
expected to take the `query` and one of the element in 'knowledge' (a
list). This function retrieves top-k elements in 'knowledge' with
HIGHEST scores. If the 'query' is a dict but has no embedding,
we use the embedding model to embed the query.""",
"parameters": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -163,15 +181,20 @@ def setUp(self) -> None:
"type": "function",
"function": {
"name": "summarization",
"description": "Summarize the input text.",
"description": (
"Summarize the input text.\n"
"\n"
"Summarization function (Notice: current version "
"of token limitation is\n"
"built with Open AI API)"
),
"parameters": {
"type": "object",
"properties": {
"text": {
"type": "string",
"description": (
"Text to be summarized by " "the model."
),
"description": "Text to be summarized by the "
"model.",
},
},
"required": [
Expand Down Expand Up @@ -314,6 +337,16 @@ def test_service_toolkit(self) -> None:
1. bing_search: Search question in Bing Search API and return the searching results
question (string): The search query string.
2. execute_python_code: Execute a piece of python code.
This function can run Python code provided in string format. It has the
option to execute the code within a Docker container to provide an
additional layer of security, especially important when running
untrusted code.
WARNING: If `use_docker` is set to `False`, the `code` will be run
directly in the host system's environment. This poses a potential
security risk if the code is untrusted. Only disable Docker if you are
confident in the safety of the code being executed.
code (string): The Python code to be executed.
""", # noqa
)
Expand Down

0 comments on commit faf0e72

Please sign in to comment.