alipay / agentUniverse

agentUniverse is a LLM multi-agent framework that allows developers to easily build multi-agent applications.
Apache License 2.0
572 stars 66 forks source link

Connection to LLM Baidu #49

Closed kbzh2558 closed 1 month ago

kbzh2558 commented 1 month ago

Hi,

In the provided example, the llm.yaml file was built upon OpenAI's model. I am wondering about the documentation needed for linking Baidu's model. More specifically, I am quoting the model name and module part of the framework that need to be changed, as highlighted by the two arrows.

name: 'demo_llm' description: 'demo openai' -> model_name: 'gpt-4o' <- max_tokens: 8000 max_retries: 2 metadata: type: 'LLM' -> module: 'agentuniverse.llm.default.default_openai_llm' <- class: 'DefaultOpenAILLM'

Thank you!

LandJerry commented 1 month ago

Hi,

In the provided example, the llm.yaml file was built upon OpenAI's model. I am wondering about the documentation needed for linking Baidu's model. More specifically, I am quoting the model name and module part of the framework that need to be changed, as highlighted by the two arrows.

name: 'demo_llm' description: 'demo openai' -> model_name: 'gpt-4o' <- max_tokens: 8000 max_retries: 2 metadata: type: 'LLM' -> module: 'agentuniverse.llm.default.default_openai_llm' <- class: 'DefaultOpenAILLM'

Thank you!

Thank you for your attention.

Referencing this PR: https://github.com/alipay/agentUniverse/pull/45/files

Referencing files: sample_standard_app/app/core/llm/wenxin_llm.yaml sample_standard_app/app/test/test_wenxin_llm.py

We will be releasing this content around this Friday. We have added common LLM connection methods and will also be appending relevant usage documentation.

kbzh2558 commented 1 month ago

Hi, In the provided example, the llm.yaml file was built upon OpenAI's model. I am wondering about the documentation needed for linking Baidu's model. More specifically, I am quoting the model name and module part of the framework that need to be changed, as highlighted by the two arrows. name: 'demo_llm' description: 'demo openai' -> model_name: 'gpt-4o' <- max_tokens: 8000 max_retries: 2 metadata: type: 'LLM' -> module: 'agentuniverse.llm.default.default_openai_llm' <- class: 'DefaultOpenAILLM' Thank you!

Thank you for your attention.

Referencing this PR: https://github.com/alipay/agentUniverse/pull/45/files

Referencing files: sample_standard_app/app/core/llm/wenxin_llm.yaml sample_standard_app/app/test/test_wenxin_llm.py

We will be releasing this content around this Friday. We have added common LLM connection methods and will also be appending relevant usage documentation.

Hi,

Thank you for your immediate reply! I just made the changes as indicated in the reference file. However, is it possible to schedule an earlier release for the connection to Wenxin model as I am in need of using it to test a series of frameworks that I've established.

LandJerry commented 1 month ago

Hi, In the provided example, the llm.yaml file was built upon OpenAI's model. I am wondering about the documentation needed for linking Baidu's model. More specifically, I am quoting the model name and module part of the framework that need to be changed, as highlighted by the two arrows. name: 'demo_llm' description: 'demo openai' -> model_name: 'gpt-4o' <- max_tokens: 8000 max_retries: 2 metadata: type: 'LLM' -> module: 'agentuniverse.llm.default.default_openai_llm' <- class: 'DefaultOpenAILLM' Thank you!

Thank you for your attention. Referencing this PR: https://github.com/alipay/agentUniverse/pull/45/files Referencing files: sample_standard_app/app/core/llm/wenxin_llm.yaml sample_standard_app/app/test/test_wenxin_llm.py We will be releasing this content around this Friday. We have added common LLM connection methods and will also be appending relevant usage documentation.

Hi,

Thank you for your immediate reply! I just made the changes as indicated in the reference file. However, is it possible to schedule an earlier release for the connection to Wenxin model as I am in need of using it to test a series of frameworks that I've established.

Using the existing version is perfectly fine. we have already placed the corresponding examples in the following branch: https://github.com/alipay/agentUniverse/tree/tmp_branch_for_issue_49

You can copy and modify the following files from this branch: sample_standard_app/app/core/agent/rag_agent_case/demo_rag_agent.yaml sample_standard_app/app/core/llm/wenxin_langchain_instance.py sample_standard_app/app/core/llm/wenxin_llm.py sample_standard_app/app/core/llm/wenxin_llm.yaml And use sample_standard_app/app/test/test_rag_agent.py for testing. Please note that you need to inject the following keys into your environment variables: QIANFAN_SK: your wenxin secret_key QIANFAN_AK: your wenxin access_key

kbzh2558 commented 1 month ago

Hi,

Thank you for getting back to me. I made the changes and copied the abovementioned files into the designated folder. When I was running the test files, the following error appeared. Also, I wonder if there is a way to initialize this framework as a service app window or some other way to allow direct interactions. Thank you.

============================= test session starts ============================= collecting ... collected 1 item

test_rag_agent.py::RagAgentTest::test_rag_agent

======================== 1 failed, 8 warnings in 5.91s ======================== FAILED [100%]Warn: Boot file is not located under directory 'bootstrap', but under 'test' log config file isn't a valid toml, use default config.

test_rag_agent.py:16 (RagAgentTest.test_rag_agent) self =

def test_rag_agent(self):
    """Test demo rag agent."""
    instance: Agent = AgentManager().get_instance_obj('demo_rag_agent')
  output_object: OutputObject = instance.run(input='分析下巴菲特减持比亚迪的原因')

E AttributeError: 'NoneType' object has no attribute 'run'

test_rag_agent.py:20: AttributeError

Process finished with exit code 1

LandJerry commented 1 month ago

demo_rag_agent

The error message is “AttributeError: 'NoneType' object has no attribute 'run'”, it means the instance is None.

The AgentManager cannot find the agent which named 'demo_rag_agent', please make sure you have the agent named 'demo_rag_agent'.

If you directly copied the project example without changing the name of the sample agent, that agent exists by default. I believe it is highly likely that the configuration of the startup scanning path is causing the agent to not be found. You need to modify the correct path in the project's config.toml. If the issue still cannot be resolved, please show me the project's configuration file (path: agentUniverse/sample_standard_app/config/config.toml) and the directory path where the agent is located.

kbzh2558 commented 1 month ago

Hi,

I modified the file path in the config.toml file. The project directory itself is as follows: C:\Users\name\folder1\MODEL_agent. Following this is the exact project structure as presented in the introduction docs. In all module parts of the code I wrote the path as MODEL_agent.app.core.agent.rag_agent, for example, for metadata. An example of the config.toml file is written as

[CORE_PACKAGE]

Perform a full component scan and registration for all the paths under this list.

default = ['app.core']

Scan and register agent components for all paths under this list, with priority over the default.

agent = ['app.core.agent']

The config file is located in the path C:\Users\name\folder1\MODEL_agent\config.

After the abovementioned adjustments, the following error persists. Thank you.

============================= test session starts ============================= collecting ... collected 1 item

test_rag_agent.py::RagAgentTest::test_rag_agent

======================== 1 failed, 8 warnings in 4.15s ======================== FAILED [100%]Warn: Boot file is not located under directory 'bootstrap', but under 'test'

test_rag_agent.py:16 (RagAgentTest.test_rag_agent) self =

def test_rag_agent(self):
    """Test demo rag agent."""
    instance: Agent = AgentManager().get_instance_obj('demo_rag_agent')
  output_object: OutputObject = instance.run(input='分析下巴菲特减持比亚迪的原因')

E AttributeError: 'NoneType' object has no attribute 'run'

test_rag_agent.py:20: AttributeError

Process finished with exit code 1

LandJerry commented 1 month ago

Hi,

I modified the file path in the config.toml file. The project directory itself is as follows: C:\Users\name\folder1\MODEL_agent. Following this is the exact project structure as presented in the introduction docs. In all module parts of the code I wrote the path as MODEL_agent.app.core.agent.rag_agent, for example, for metadata. An example of the config.toml file is written as

[CORE_PACKAGE]

Perform a full component scan and registration for all the paths under this list.

default = ['app.core']

Scan and register agent components for all paths under this list, with priority over the default.

agent = ['app.core.agent']

The config file is located in the path C:\Users\name\folder1\MODEL_agent\config.

After the abovementioned adjustments, the following error persists. Thank you.

============================= test session starts ============================= collecting ... collected 1 item

test_rag_agent.py::RagAgentTest::test_rag_agent

======================== 1 failed, 8 warnings in 4.15s ======================== FAILED [100%]Warn: Boot file is not located under directory 'bootstrap', but under 'test'

test_rag_agent.py:16 (RagAgentTest.test_rag_agent) self =

def test_rag_agent(self):
    """Test demo rag agent."""
    instance: Agent = AgentManager().get_instance_obj('demo_rag_agent')
  output_object: OutputObject = instance.run(input='分析下巴菲特减持比亚迪的原因')

E AttributeError: 'NoneType' object has no attribute 'run'

test_rag_agent.py:20: AttributeError

Process finished with exit code 1

6E4FCCC1-FD8A-4EF2-9F75-762B45FF2FEB

I tried to simulate your path, as shown in the figure. It works normally. Below is my configuration for your reference.

demo_rag_agent.yaml

# omit some setting

metadata:
  type: 'AGENT'
  module: 'app.core.agent.rag_agent_case.demo_rag_agent'
  class: 'DemoRagAgent'

config.toml

# omit some setting

[CORE_PACKAGE]
# Perform a full component scan and registration for all the paths under this list.
default = ['app.core']
# Scan and register agent components for all paths under this list, with priority over the default.
agent = ['app.core.agent']
# Scan and register knowledge components for all paths under this list, with priority over the default.
knowledge = ['app.core.knowledge']
# Scan and register llm components for all paths under this list, with priority over the default.
llm = ['app.core.llm']
# Scan and register planner components for all paths under this list, with priority over the default.
planner = ['app.core.planner']
# Scan and register tool components for all paths under this list, with priority over the default.
tool = ['app.core.tool']
# Scan and register memory components for all paths under this list, with priority over the default.
memory = ['app.core.memory']
# Scan and register service components for all paths under this list, with priority over the default.
service = ['app.core.service']
# Scan and register prompt components for all paths under this list, with priority over the default.
prompt = ['app.core.prompt']

# omit some setting