Skip to content

模型返回结果概览

输出控制解决“结果长什么样”,这一章解决“结果怎么读、怎么复用、怎么流式消费”。

适合什么时候读

  • 你已经用 output() 得到了结构化结果
  • 你要同时拿文本、结构化数据和元信息
  • 你要把流式事件接入 UI 或下一步逻辑

你会学到什么

  • 为什么推荐先 get_response() 再读取
  • get_text()get_data()get_data_object()get_meta() 的分工
  • get_generator() / instant / 事件流的典型使用方式

结果链路

最小示例

python
from agently import Agently

agent = Agently.create_agent()

response = (
    agent
    .input("用一句话介绍 Agently")
    .output({"intro": ("str", "一句话介绍")})
    .get_response()
)

print(response.result.get_text())
print(response.result.get_data())
print(response.result.get_meta())

常见误区

  • 连续调用 get_text() / get_data() 时,误以为它们默认读取的是同一次请求。
  • 还没固定 response,就开始在多个地方消费结果。
  • 想要结构化流式事件,却只盯着最终文本。

下一步去哪

相关案例

  • agently-model-response
  • agently-output-control