mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-02-08 01:02:22 +08:00
18 lines
564 B
Python
18 lines
564 B
Python
def copy(self):
|
|
"""
|
|
Special copy method for browser tool to avoid recreating browser instance.
|
|
|
|
:return: A new instance with shared browser reference but unique model
|
|
"""
|
|
new_tool = self.__class__()
|
|
|
|
# Copy essential attributes
|
|
new_tool.model = self.model
|
|
new_tool.context = getattr(self, 'context', None)
|
|
new_tool.config = getattr(self, 'config', None)
|
|
|
|
# Share the browser instance instead of creating a new one
|
|
if hasattr(self, 'browser'):
|
|
new_tool.browser = self.browser
|
|
|
|
return new_tool |