跳转至

agentmaker

一个通用的 Python 框架,用于构建 LLM Agent(大模型智能体)与多 agent 系统,内置工具(tool)、记忆、检索 / RAG(Retrieval-Augmented Generation,检索增强生成,即先检索资料再让模型作答)、上下文工程、护栏、human-in-the-loop(HITL,人在回路,即关键步骤交由人工确认)以及可观测性。

安装

pip install agentmaker            # core batteries, works out of the box
pip install "agentmaker[all]"     # every optional capability

需要 Python 3.12+。完整的可选附加项矩阵见 安装

30 秒示例

无需任何配置即可运行(无需 API key,无需联网),与 examples/01_quickstart.py 中随包提供的代码完全一致:

from agentmaker import Agent, tool
from agentmaker.testing import ScriptedLLM


@tool
def get_weather(city: str) -> str:
    """Return today's weather for a city.

    Args:
        city: The city name.
    """
    return f"{city}: sunny, 24C"


# With a real model the LLM decides when to call the tool. Here we script that decision:
# first it asks to call get_weather(city="Copenhagen"), then it writes the final answer.
llm = ScriptedLLM([
    ScriptedLLM.tool_call("get_weather", {"city": "Copenhagen"}),
    "It's sunny and 24C in Copenhagen today.",
])

agent = Agent("assistant", llm, tools=[get_weather])
result = agent.run("What's the weather in Copenhagen?")
print(result.final_output)

要使用真实模型,把 ScriptedLLM(...) 换成 LLMClient("deepseek")(或 "openai" / "anthropic" / "gemini"),并在环境中设置对应的 API key;此后由模型自己决定何时调用工具。

下一步去哪里

版本策略

1.0 之前:次版本号可能引入破坏性变更,修订版本号只做修复。请锁定 agentmaker>=0.1,<0.2。参见 更新日志

许可证

MIT