[Autogen] Triển khai hệ thống AI đa tác nhân

Multi-Agent là một xu hướng quan trọng trong việc triển khai các hệ thống AI hiện nay, trong bài này chúng ta sẽ tập trung thực hành triển khai một hệ thống Multi-Agent đơn giản thông qua [Autogen] – một nền tảng của Microsoft.

https://github.com/taipm/autogen_trading_agents.git

Công cụ sử dụng:

  • autogen (0.4 – bản dev)

Tham khảo:

  1. https://microsoft.github.io/autogen/0.4.0.dev8/user-guide/agentchat-user-guide/index.html
  2. https://microsoft.github.io/autogen/0.4.0.dev8/user-guide/agentchat-user-guide/examples/company-research.html
  3. https://microsoft.github.io/autogen/0.4.0.dev8/user-guide/agentchat-user-guide/examples/literature-review.html
  4. https://microsoft.github.io/autogen/0.4.0.dev8/user-guide/agentchat-user-guide/examples/travel-planning.html

Thực hành

  1. Cài đặt autogen

Bước 01: Tạo project trên Github

Cài đặt:
pip install ‘autogen-agentchat==0.4.0.dev8’ ‘autogen-ext[openai]==0.4.0.dev8’

Fix bug

(venv) (base) taipm@Phans-MacBook-Pro autogen_trading_agents % python app1.py    
Traceback (most recent call last):
  File "/Users/taipm/GitHub/autogen_trading_agents/app1.py", line 111, in <module>
    run()
  File "/Users/taipm/GitHub/autogen_trading_agents/app1.py", line 108, in run
    asyncio.run(main())
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 684, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/taipm/GitHub/autogen_trading_agents/app1.py", line 87, in main
    model_client=OpenAIChatCompletionClient(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/taipm/GitHub/autogen_trading_agents/venv/lib/python3.12/site-packages/autogen_ext/models/_openai/_openai_client.py", line 958, in __init__
    client = _openai_client_from_config(copied_args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/taipm/GitHub/autogen_trading_agents/venv/lib/python3.12/site-packages/autogen_ext/models/_openai/_openai_client.py", line 122, in _openai_client_from_config
    return AsyncOpenAI(**openai_config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/taipm/GitHub/autogen_trading_agents/venv/lib/python3.12/site-packages/openai/_client.py", line 319, in __init__
    raise OpenAIError(
openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *