跳转至

入门示例

from agently import Agently

Agently.set_settings(
    "OpenAICompatible",
    {
        "base_url": "http://127.0.0.1:11434/v1",
        "model": "qwen2.5:7b",
    },
)

agent = Agently.create_agent()
print(agent.input("你好,Agently!").start())

三行结构化输出

result = (
    agent.input("总结这个项目")
    .output({"summary": ("str", "简短总结"), "risks": [("str", "风险")]})
    .start()
)
print(result)

流式预览

response = (
    agent.input("解释递归")
    .output({"answer": ("str", "最终回答")})
    .get_response()
)
for msg in response.get_generator(type="instant"):
    if msg.path == "answer" and msg.delta:
        print(msg.delta, end="", flush=True)
print()

下一步

  • 输出控制:examples/step_by_step/03-output_format_control.py
  • 流式输出:examples/step_by_step/06-streaming.py
  • Tools:examples/step_by_step/07-tools.py
  • TriggerFlow:examples/step_by_step/11-triggerflow-01_basics.py