事件

问题

{ type: "question", id, question, options }

代理商在问你一些事情, 并且停止等待。 和许可一样, 不同的含义: 它想要答案, 而不是批准 。

needs onQuestionthe loop waitsquestion_result follows
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

字段

idstring

是为这个问题而生成的。

questionstring

问什么?

optionsarray

提出答案时,建议给予答案。

需要就问题

const agent = api.agents.create({
  runtime: "local", machine: pc, model,
  onQuestion: async ({ question, options }) => {
    console.log(question, options);
    return await readAnswerFromTheUser();     // a string
  },
  onEvent: (e) => {
    if (e.type === "question")        showQuestion(e.id, e.question, e.options);
    if (e.type === "question_result") closeQuestion(e.id, e.answer);
  },
});
def on_question(request):
    print(request["question"], request["options"])
    return read_answer_from_the_user()     # a string

agent = api.agents.create(runtime="local", machine=pc, model=model, on_question=on_question)
问题没有没有 ask_user

工具只有在回调出现时才有电线。 一名没有回调的特工无法问话,他奉命要打个判断电话或解释什么是阻碍,这是另一场不同的跑,而不是卡住的跑。

question_result

{ type: "question_result", id, answer }    // "" when nothing was returned
# The ask_user tool returns what on_question answered, or None when no callback is set
{"answer": "the second option"}

空答案作为空答案传递给代理商; 它不是一个错误, 循环会继续 。

当它问它问

  • 请求含糊不清,用户的选择。
  • 两次试图采取同样办法的努力都失败了——有人说,它要问的是非要试第三个。

子试剂从不问

ask_user 是一个子试剂得不到的三种工具之一。 被告知它不能与用户交谈, 并且必须报告, 反之必须汇报, 所以问题总是来自主运行, 永远不携带 parentId.