MervinPraison / PraisonAI

PraisonAI application combines AutoGen and CrewAI or similar frameworks into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration.
https://docs.praison.ai
MIT License
1.06k stars 159 forks source link

autogen_ScrapeWebsiteTool fix #35

Closed LinuxAITottiLabs closed 2 weeks ago

LinuxAITottiLabs commented 1 month ago

I hope this message finds you well. I'm currently using the Autogen framework in my project and I encountered an issue with the Scrape Website Tool. When attempting to scrape websites in different languages, the tool returns the error 'str' object has no attribute 'decode'.

After some investigation, I found that modifying the tool's function as follows resolves the issue:

def autogen_scrape_website_tool(assistant, user_proxy): def register_scrape_website_tool(tool_class, tool_name, tool_description, assistant, user_proxy): def tool_func(website_url: str) -> Any: tool_instance = tool_class(website_url=website_url) content = tool_instance.run() if isinstance(content, str): content = content.encode('utf-8').decode('utf-8') # Ensure content is properly decoded as UTF-8 return content register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description) register_scrape_website_tool(ScrapeWebsiteTool, "scrape_website_tool", "Read website content(website_url: 'string') - A tool that can be used to read content from a specified website.", assistant, user_proxy)

I believe this modification could improve the tool's compatibility with websites in various languages. Could you please review this change and consider incorporating it into the official release of the Autogen framework?

Thank you for your attention to this matter. I look forward to your feedback.

MervinPraison commented 2 weeks ago

@LinuxAITottiLabs This has been fixed in the latest release https://github.com/MervinPraison/PraisonAI/releases/tag/v0.0.31