ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s

This commit is contained in:
2026-08-20 13:12:50 +00:00
commit b119135836
10275 changed files with 3284984 additions and 0 deletions
@@ -0,0 +1,2 @@
# coding: utf-8
# Copyright (c) 2025 inclusionAI.
@@ -0,0 +1,49 @@
# coding: utf-8
# Copyright (c) 2025 inclusionAI.
import os
from aworld.agents.llm_agent import Agent
from aworld.config.conf import AgentConfig
from examples.common.tools.common import Tools
search_sys_prompt = "You are a helpful search agent."
search_prompt = """
Please act as a search agent, constructing appropriate keywords and searach terms, using search toolkit to collect relevant information, including urls, webpage snapshots, etc.
Here are the question: {task}
pleas only use one action complete this task, at least results 6 pages.
"""
summary_sys_prompt = "You are a helpful general summary agent."
summary_prompt = """
Summarize the following text in one clear and concise paragraph, capturing the key ideas without missing critical points.
Ensure the summary is easy to understand and avoids excessive detail.
Here are the content:
{task}
"""
agent_config = AgentConfig(
llm_provider=os.getenv("LLM_PROVIDER", "openai"),
llm_model_name=os.getenv("LLM_MODEL_NAME"),
llm_base_url=os.getenv("LLM_BASE_URL"),
llm_api_key=os.getenv("LLM_API_KEY"),
llm_temperature=os.getenv("LLM_TEMPERATURE", 0.0)
)
search = Agent(
conf=agent_config,
name="search_agent",
system_prompt=search_sys_prompt,
agent_prompt=search_prompt,
tool_names=[Tools.SEARCH_API.value]
)
summary = Agent(
conf=agent_config,
name="summary_agent",
system_prompt=summary_sys_prompt,
agent_prompt=summary_prompt
)
@@ -0,0 +1,21 @@
# coding: utf-8
# Copyright (c) 2025 inclusionAI.
from aworld.core.agent.swarm import Swarm
from aworld.runner import Runners
from examples.multi_agents.workflow.search.common import *
if __name__ == "__main__":
s1 = Swarm(search)
s2 = Swarm(summary)
# default is workflow swarm
# swarm1 and swarm2 are embedded into the swarm, which is a hierarchical swarm
swarm = Swarm(s1, s2, max_steps=1)
prefix = ""
# can special search google, wiki, duck go, or baidu. such as:
# prefix = "search wiki: "
res = Runners.sync_run(
input=prefix + """What is an agent.""",
swarm=swarm
)
print(res.answer)
@@ -0,0 +1,28 @@
# coding: utf-8
# Copyright (c) 2025 inclusionAI.
from aworld.core.agent.swarm import Swarm
from aworld.runner import Runners
from examples.multi_agents.workflow.search.common import *
if __name__ == "__main__":
search2 = Agent(
conf=agent_config,
name="search_agent",
system_prompt=search_sys_prompt,
agent_prompt=search_prompt,
tool_names=[Tools.SEARCH_API.value]
)
# default is workflow swarm
# search1 and search2 parallel execution and use the same input.
swarm = Swarm((search, summary), (search2, summary), max_steps=1)
# you also can set root_agent=[search, search2]
prefix = ""
# can special search google, wiki, duck go, or baidu. such as:
# prefix = "search wiki: "
res = Runners.sync_run(
input=prefix + """What is an agent.""",
swarm=swarm
)
print(res.answer)
@@ -0,0 +1,27 @@
# coding: utf-8
# Copyright (c) 2025 inclusionAI.
from aworld.core.agent.swarm import Swarm
from aworld.runner import Runners
from examples.multi_agents.workflow.search.common import *
# os.environ["LLM_MODEL_NAME"] = "YOUR_LLM_MODEL_NAME"
# os.environ["LLM_BASE_URL"] = "YOUR_LLM_BASE_URL"
# os.environ["LLM_API_KEY"] = "YOUR_LLM_API_KEY"
# search and summary
if __name__ == "__main__":
# need to set GOOGLE_API_KEY and GOOGLE_ENGINE_ID to use Google search.
# os.environ['GOOGLE_API_KEY'] = ""
# os.environ['GOOGLE_ENGINE_ID'] = ""
# default is workflow swarm
swarm = Swarm(search, summary, max_steps=1)
# swarm = WorkflowSwarm(search, summary, max_steps=1)
prefix = ""
# can special search google, wiki, duck go, or baidu. such as:
# prefix = "search wiki: "
res = Runners.sync_run(
input=prefix + """What is an agent.""",
swarm=swarm
)
print(res.answer)