Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

fix: Update web_toolkit.py (#1758)

Sun Taobd92af657339
diff --git a/camel/toolkits/web_toolkit.py b/camel/toolkits/web_toolkit.py
index 79e6e2760..7afeaee3e 100644
--- a/camel/toolkits/web_toolkit.py
+++ b/camel/toolkits/web_toolkit.py
@@ -157,16 +157,15 @@ def _parse_json_output(text: str) -> Dict[str, Any]:
if triple_quotes_match:
text = triple_quotes_match.group(1).strip()
- text = text.replace("`", '"')
-
try:
return json.loads(text)
except json.JSONDecodeError:
try:
- fixed_text = re.sub(r'`([^`]*)`', r'"\1"', text)
+ fixed_text = re.sub(
+ r'`([^`]*?)`(?=\s*[:,\[\]{}]|$)', r'"\1"', text
+ )
return json.loads(fixed_text)
except json.JSONDecodeError:
- # Try to extract key fields
result = {}
try:
bool_pattern = r'"(\w+)"\s*:\s*(true|false)'
@@ -986,7 +985,7 @@ Here are an example of the output:
{{
"observation": [IMAGE_DESCRIPTION],
"reasoning": [YOUR_REASONING],
- "action_code": `fill_input_id([ID], [TEXT])`
+ "action_code": "fill_input_id([ID], [TEXT])"
}}
Here are some tips for you: