Skip to content

open needs encoding='utf-8' for non-english environment, error in playwright_controller.py #5566

@bear0330

Description

@bear0330

What happened?

C:\Users\Bear\miniconda3\envs\ai2\Lib\site-packages\magentic_one_cli\_m1.py:59: DeprecationWarning: Instantiating MagenticOne without a code_executor is deprecated. Provide a code_executor to clear this warning (e.g., code_executor=LocalCommandLineCodeExecutor() ).
  m1 = MagenticOne(client=client, hil_mode=hil_mode, input_func=input_manager.get_wrapped_callback())
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Bear\miniconda3\envs\ai2\Scripts\m1.exe\__main__.py", line 7, in <module>
    sys.exit(main())
             ~~~~^^
  File "C:\Users\Bear\miniconda3\envs\ai2\Lib\site-packages\magentic_one_cli\_m1.py", line 67, in main
    asyncio.run(run_task(task, not args.no_hil, args.rich))
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bear\miniconda3\envs\ai2\Lib\asyncio\runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "C:\Users\Bear\miniconda3\envs\ai2\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "C:\Users\Bear\miniconda3\envs\ai2\Lib\asyncio\base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "C:\Users\Bear\miniconda3\envs\ai2\Lib\site-packages\magentic_one_cli\_m1.py", line 59, in run_task
    m1 = MagenticOne(client=client, hil_mode=hil_mode, input_func=input_manager.get_wrapped_callback())
  File "C:\Users\Bear\miniconda3\envs\ai2\Lib\site-packages\autogen_ext\teams\magentic_one.py", line 144, in __init__
    ws = MultimodalWebSurfer("WebSurfer", model_client=client)
  File "C:\Users\Bear\miniconda3\envs\ai2\Lib\site-packages\autogen_ext\agents\web_surfer\_multimodal_web_surfer.py", line 268, in __init__
    self._playwright_controller = PlaywrightController(
                                  ~~~~~~~~~~~~~~~~~~~~^
        animate_actions=self.animate_actions,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
        to_resize_viewport=self.to_resize_viewport,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\Bear\miniconda3\envs\ai2\Lib\site-packages\autogen_ext\agents\web_surfer\playwright_controller.py", line 68, in __init__
    self._page_script = fh.read()
                        ~~~~~~~^^
UnicodeDecodeError: 'cp950' codec can't decode byte 0xe2 in position 11569: illegal multibyte sequence

simply add encoding='utf-8' in line 67:

with open(os.path.join(os.path.abspath(os.path.dirname(__file__)), "page_script.js"), "rt", encoding='utf-8') as fh:

can solve the issue, and i think there will be some similar issues in code base while using open function.

What did you expect to happen?

No error

How can we reproduce it (as minimally and precisely as possible)?

m1 --rich "我手上有一些尚未投入到投市的資金, 預計投入到 VT 和 SOXX, 請問現在是好的時機點嗎? 或是我應該再等一陣子低點入市? 我打算是長期投資, 但依然希望不要有過高的持有成本以免影響我的績效, 而且因為我現在要分批投入的是主要資金, 所以就算之後定期定額, 現在的買點也是很重要"

AutoGen version

0.4.7

Which package was this bug in

Magentic One

Model used

No response

Python version

No response

Operating system

No response

Any additional info you think would be helpful for fixing this bug

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions