An error occurred while running "Hello world examples"
First, many thanks to AWorld for your outstanding work.
An error occurred while I run "Hello world examples", Ref. https://github.com/inclusionAI/AWorld?tab=readme-ov-file#:~:text=Hello%20world%20examples
import os
from aworld.agents.llm_agent import Agent
from aworld.runner import Runners
summarizer = Agent(
name="Summary Agent",
system_prompt="You specialize at summarizing.",
)
result = Runners.sync_run(
input="Tell me a succint history about the universe",
agent=summarizer,
)
Error:
summarizer = Agent(
^^^^^^
TypeError: Agent.__init__() missing 1 required positional argument: 'conf'
When initializing the Agent, the conf parameter needs to be passed in. How should this parameter be set?
Sorry for the initialization inconvenience, please check the following script to pass the AgentConfig explicitly.
import os
from aworld.agents.llm_agent import Agent
from aworld.runner import Runners
from aworld.config.conf import AgentConfig
from aworld.core.agent.swarm import Swarm
gpt_conf = AgentConfig(
llm_provider="openai",
llm_model_name="gpt-4o",
llm_api_key="<OPENAI_API_KEY>",
llm_temperature=0.1,
)
openrouter_conf = AgentConfig(
llm_provider="openai",
llm_model_name="google/gemini-2.5-pro",
llm_api_key="<OPENROUTER_API_KEY>",
llm_base_url="https://openrouter.ai/api/v1"
llm_temperature=0.1,
)
researcher = Agent(
name="Research Agent",
conf=gpt_conf,
system_prompt="You specialize at researching.",
)
summarizer = Agent(
name="Summary Agent",
conf=openrouter_conf,
system_prompt="You specialize at summarizing.",
)
# Create agent team with collaborative workflow
team = Swarm(researcher, summarizer)
result = Runners.sync_run(
input="Tell me a complete history about the universe",
swarm=team,
)
The conf argument is set to None explicitly. #342 handles the initialization strategy.
You could pull the latest code to run the demo. It works as expected with environment variables set.
LLM_BASE_URL=
LLM_API_KEY=
LLM_BASE_URL=
Thanks for reporting the issue! Please let us know if there is any further problem.
@qingw-dev Thank you for your reply, you have answered my question