Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Any HTML-esh Style Tags #2046

Merged
merged 25 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tag content -> tag attr
  • Loading branch information
WaelKarkoub committed Mar 22, 2024
commit 9afbc0558a04e5fcd0d731225418bcfdc72a51ea
2 changes: 1 addition & 1 deletion autogen/agentchat/contrib/img_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def gpt4v_formatter(prompt: str, img_format: str = "uri") -> List[Union[str, dic

# Find all image tags
for match in utils.parse_tags_from_content("img", prompt):
image_location = match["content"]["src"]
image_location = match["attr"]["src"]
try:
if img_format == "pil":
img_data = get_pil_image(image_location)
Expand Down
8 changes: 4 additions & 4 deletions autogen/agentchat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ def _parse_tags_from_text(tag: str, text: str) -> List[Dict[str, str]]:

results = []
for match in re.finditer(pattern, text):
tag_content = match.group(1).strip()
content = _parse_attributes_from_tags(tag_content)
tag_attr = match.group(1).strip()
attr = _parse_attributes_from_tags(tag_attr)

results.append({"tag": tag, "content": content, "start": match.start(), "end": match.end()})
results.append({"tag": tag, "attr": attr, "start": match.start(), "end": match.end()})
return results


Expand Down Expand Up @@ -163,7 +163,7 @@ def _reconstruct_attributes(attrs: List[str]) -> List[str]:

def is_attr(attr: str) -> bool:
if "=" in attr:
key, value = attr.split("=", 1)
_, value = attr.split("=", 1)
if value.startswith("'") or value.startswith('"'):
return True
return False
Expand Down
Loading