From ecd3815532afb0382229d40f1f26380d9ebf0bef Mon Sep 17 00:00:00 2001 From: Michael Skarlinski Date: Tue, 7 Jan 2025 14:07:55 -0800 Subject: [PATCH 1/5] remove newline filter in param descriptions for agents --- src/aviary/tools/base.py | 2 +- tests/test_tools.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aviary/tools/base.py b/src/aviary/tools/base.py index 7e443f4..ae888d4 100644 --- a/src/aviary/tools/base.py +++ b/src/aviary/tools/base.py @@ -401,7 +401,7 @@ def from_function( ( cls._get_param_desc( p, include_type=types_in_param_descriptions - ).replace("\n", " ") + ) for p in docstring.params if p.arg_name == pname ), diff --git a/tests/test_tools.py b/tests/test_tools.py index 795eb4d..698a694 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -169,7 +169,7 @@ class TestTool: }, "y": { "description": ( - "I am null. And despite that there is a" + "I am null.\nAnd despite that there is a" " multiline argument description." ), "title": "Y", From 8be692a511375e2b47e9616f3a53df91896c809e Mon Sep 17 00:00:00 2001 From: Michael Skarlinski Date: Tue, 7 Jan 2025 14:19:04 -0800 Subject: [PATCH 2/5] ruff formatting --- src/aviary/tools/base.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/aviary/tools/base.py b/src/aviary/tools/base.py index ae888d4..5586113 100644 --- a/src/aviary/tools/base.py +++ b/src/aviary/tools/base.py @@ -399,9 +399,7 @@ def from_function( continue d = next( ( - cls._get_param_desc( - p, include_type=types_in_param_descriptions - ) + cls._get_param_desc(p, include_type=types_in_param_descriptions) for p in docstring.params if p.arg_name == pname ), From b8d7204c57af1cbf8c834f304442716732e4784f Mon Sep 17 00:00:00 2001 From: Michael Skarlinski Date: Tue, 7 Jan 2025 15:32:14 -0800 Subject: [PATCH 3/5] add new test with complex formating --- tests/test_tools.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/test_tools.py b/tests/test_tools.py index 698a694..67bd86c 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -58,6 +58,7 @@ def many_edge_cases( enum: StubEnum, defaulted_str: str = "default", defaulted_float: float = 1.0, + structured_arg: str = "structured", ) -> None: """ Check using docstrings as partial f-string templates like so: {summary_format}. @@ -73,6 +74,22 @@ def many_edge_cases( enum: I am an enum. defaulted_str: I have a string default value. defaulted_float: I have a float default value. + structured_arg: I am structured. There are lots of examples + included which cross several lines. + Query Syntax: + Basic Search: + Search with two words and a space: + >>> "word1 word2" # doctest: +SKIP + + Modified Search: + Use operators to modify search behavior: + >>> 'EXPANSION[None]NAME"word phrase"' # doctest: +SKIP + >>> 'EXPANSION[Concept]words' # doctest: +SKIP + + Operators: + EXPANSION[type]: Terms + - Term1: a description + - Term2: another description """ @@ -226,6 +243,29 @@ class TestTool: "title": "Defaulted Float", "type": "number", }, + "structured_arg": { + "default": "structured", + "description": ( + 'I am structured. There are lots of examples \n' + 'included which cross several lines.\n' + 'Query Syntax:\n' + ' Basic Search:\n' + ' Search with two words and a space:\n' + ' >>> \"word1 word2" # doctest: +SKIP\n' + '\n' + ' Modified Search:\n' + ' Use operators to modify search behavior:\n' + ' >>> \'EXPANSION[None]NAME"word phrase"\' # doctest: +SKIP\n' + ' >>> \'EXPANSION[Concept]words\' # doctest: +SKIP\n' + '\n' + 'Operators:\n' + ' EXPANSION[type]: Terms\n' + ' - Term1: a description\n' + ' - Term2: another description' + ), + "title": "Structured Arg", + "type": "string", + }, }, "required": [ "x", From f20aa0c07e912617e8fe056e2949fa87378e8619 Mon Sep 17 00:00:00 2001 From: Michael Skarlinski Date: Tue, 7 Jan 2025 15:34:07 -0800 Subject: [PATCH 4/5] ruff formatting --- tests/test_tools.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/test_tools.py b/tests/test_tools.py index 67bd86c..35acb3c 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -74,17 +74,17 @@ def many_edge_cases( enum: I am an enum. defaulted_str: I have a string default value. defaulted_float: I have a float default value. - structured_arg: I am structured. There are lots of examples + structured_arg: I am structured. There are lots of examples included which cross several lines. Query Syntax: Basic Search: Search with two words and a space: - >>> "word1 word2" # doctest: +SKIP + >>> "word1 word2" # doctest: +SKIP Modified Search: Use operators to modify search behavior: - >>> 'EXPANSION[None]NAME"word phrase"' # doctest: +SKIP - >>> 'EXPANSION[Concept]words' # doctest: +SKIP + >>> 'EXPANSION[None]NAME"word phrase"' # doctest: +SKIP + >>> "EXPANSION[Concept]words" # doctest: +SKIP Operators: EXPANSION[type]: Terms @@ -246,22 +246,22 @@ class TestTool: "structured_arg": { "default": "structured", "description": ( - 'I am structured. There are lots of examples \n' - 'included which cross several lines.\n' - 'Query Syntax:\n' - ' Basic Search:\n' - ' Search with two words and a space:\n' - ' >>> \"word1 word2" # doctest: +SKIP\n' - '\n' - ' Modified Search:\n' - ' Use operators to modify search behavior:\n' - ' >>> \'EXPANSION[None]NAME"word phrase"\' # doctest: +SKIP\n' - ' >>> \'EXPANSION[Concept]words\' # doctest: +SKIP\n' - '\n' - 'Operators:\n' - ' EXPANSION[type]: Terms\n' - ' - Term1: a description\n' - ' - Term2: another description' + "I am structured. There are lots of examples \n" + "included which cross several lines.\n" + "Query Syntax:\n" + " Basic Search:\n" + " Search with two words and a space:\n" + ' >>> "word1 word2" # doctest: +SKIP\n' + "\n" + " Modified Search:\n" + " Use operators to modify search behavior:\n" + " >>> 'EXPANSION[None]NAME\"word phrase\"' # doctest: +SKIP\n" + " >>> 'EXPANSION[Concept]words' # doctest: +SKIP\n" + "\n" + "Operators:\n" + " EXPANSION[type]: Terms\n" + " - Term1: a description\n" + " - Term2: another description" ), "title": "Structured Arg", "type": "string", From d8743e1e4490de47ef6b097f24ecd35a53c30e4f Mon Sep 17 00:00:00 2001 From: Michael Skarlinski Date: Tue, 7 Jan 2025 15:42:58 -0800 Subject: [PATCH 5/5] reformatted test spaces --- tests/test_tools.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_tools.py b/tests/test_tools.py index 35acb3c..ede67d5 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -84,7 +84,7 @@ def many_edge_cases( Modified Search: Use operators to modify search behavior: >>> 'EXPANSION[None]NAME"word phrase"' # doctest: +SKIP - >>> "EXPANSION[Concept]words" # doctest: +SKIP + >>> 'EXPANSION[Concept]"words"' # doctest: +SKIP Operators: EXPANSION[type]: Terms @@ -246,17 +246,17 @@ class TestTool: "structured_arg": { "default": "structured", "description": ( - "I am structured. There are lots of examples \n" + "I am structured. There are lots of examples\n" "included which cross several lines.\n" "Query Syntax:\n" " Basic Search:\n" " Search with two words and a space:\n" - ' >>> "word1 word2" # doctest: +SKIP\n' + ' >>> "word1 word2" # doctest: +SKIP\n' "\n" " Modified Search:\n" " Use operators to modify search behavior:\n" - " >>> 'EXPANSION[None]NAME\"word phrase\"' # doctest: +SKIP\n" - " >>> 'EXPANSION[Concept]words' # doctest: +SKIP\n" + " >>> 'EXPANSION[None]NAME\"word phrase\"' # doctest: +SKIP\n" + " >>> 'EXPANSION[Concept]\"words\"' # doctest: +SKIP\n" "\n" "Operators:\n" " EXPANSION[type]: Terms\n"