WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit c775fe6

Browse files
committed
Add a few test cases for strict_filepath_match
1 parent 8a7561f commit c775fe6

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

autogen/agentchat/utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,12 @@ def parse_tags_from_content(
122122
content (Union[str, List[Dict[str, Any]]]): The message content to parse. Can be a string or a list of content
123123
items.
124124
strict_filepath_match (bool, optional): If False (default), the parser will match all characters between the tag opening
125-
and closing, including quotation marks and empty spaces. If True, the parser will stop at the first quotation mark
126-
it encounters. Use True when dealing with nested quotes or complex attribute values. If there are
127-
lots of HTML tag in the content, it is recommended to set this to True, because then it will only match
128-
the only one tag, and will ignore HTML tags in the content.
125+
and closing, including quotation marks and spaces. If True, the parser will only match simple tag contents
126+
without spaces or quotes. This is useful for parsing filenames or URLs and ignoring complex HTML-like structures.
129127
130128
Returns:
131-
List[Dict[str, str]]: A list of dictionaries, where each dictionary represents a parsed tag. Each dictionary
132-
contains three key-value pairs: 'type' which is the tag, 'attr' which is a dictionary of the parsed attributes,
129+
List[Dict[str, Union[str, Dict[str, str], re.Match]]]: A list of dictionaries, where each dictionary represents a parsed tag. Each dictionary
130+
contains three key-value pairs: 'tag' which is the tag name, 'attr' which is a dictionary of the parsed attributes,
133131
and 'match' which is a regular expression match object.
134132
135133
Raises:

test/agentchat/test_agentchat_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@
7777
"strict_filepath_match": True,
7878
"expected": [{"tag": "img", "attr": {"src": "http://example.com/image.png"}}],
7979
},
80+
{
81+
"message": 'Can you generate this audio? <audio text="Hello I\'m a robot" prompt="whisper">',
82+
"strict_filepath_match": True,
83+
"expected": [], # Empty because strict_filepath_match=True doesn't match tags with spaces or quotes
84+
},
85+
{
86+
"message": 'Complex nested quotes <img src="http://example.com/image.png" alt="A "quoted" description">',
87+
"strict_filepath_match": True,
88+
"expected": [], # Empty because strict_filepath_match=True doesn't match tags with spaces or quotes
89+
},
8090
]
8191

8292

0 commit comments

Comments
 (0)