الأحداث

مسألة

{ 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"}

الجواب الفارغ يمر إلى الوكيل كإجابة فارغة؛ إنه ليس خطأ، والحلقة مستمرة.

« متى » متى « يسأل » يسأل

  • الطلب غامض والخيار هو للمستخدم.
  • وقد فشلت محاولتان في نفس النهج - قيل لها أن تطلب محاولة ثالثة بدلا من أن تجربها.

A a ناقصة لا تسأل

ask_user هو واحد من الأدوات الثلاثة التي لا يحصل عليها العامل الفرعي. قيل له إنه لا يستطيع التحدث إلى المستخدم ويجب أن يقدم تقريراً بدلاً من ذلك - لذا السؤال يأتي دائماً من التشغيل الرئيسي، ولا يحمل أبداً. parentId.