読み方のヒント
矢印ボタン(または ← → キー)でページを移動できます。
handle は、次の順番で質問を処理します。
def handle(llm, session, toolbox, question, now, trace) -> Outcome:
if needs_staff(question):
return Outcome("handoff", None, HANDOFF)
with trace.step("classify") as detail:
kind = detail["kind"] = classify(llm, question)
if kind == "other":
return Outcome("other", kind, OTHER)
if kind == "shop_info":
with trace.step("docs") as detail:
status, answer, hits = answer_from_docs(session, llm, question)
...
return Outcome(status, kind, answer, sources=...)
with trace.step(f"agent:{kind}") as detail:
result = run_agent(llm, LimitedToolbox(toolbox, ROUTE_TOOLS[kind]), question, now)
...
| 段階 | LLMを呼ぶ回数 | 使える道具 |
|---|---|---|
| 店員につなぐか(決まり) | 0 | なし |
| 種類を決める | 1 | なし |
other | 0 | なし(決まった文) |
shop_info | 1(資料が見つかったとき) | なし(/ask と同じ検索と答え) |
product | 2〜5 | find_products |
reservation | 2〜5 | find_products、draft_reservation |
shop_info の段階は、エージェントではなく、/ask と同じ「探して、渡して、答えさせる」処理です。検索の言葉をLLMに決めさせないため、第1節の「車で行っても大丈夫ですか」で検索の言葉を誤った問題が起きません。質問の文そのもので探します。
12 / 22