ドキュメント

シンプルなメモリシステム

どのリクエストと答えを記憶する価値があるかを Jev に判断させ、Jev の呼び出しを小さな関数で包んで、後の呼び出しに記憶を加えます。

Jev の各リクエストは、送った state だけを見ます。顧客が先月あなたのアプリに話したこと、たとえばエディションやプランは、あなたのコードがそこに入れない限り、次のリクエストには含まれません。ここで作るメモリシステムは、呼び出しごとに Jev リクエストを 1 回余分に実行し、Python の dict を使ってそれを実現します。

例ではサポートチケットを振り分けます。8 月に、ある顧客が Windows Server でセルフホストしていると述べました。9 月に「朝からダッシュボードがとても遅い」と書きます。メモリがなければ、Jev はそのチケットをセルフホストチームではなくクラウドチームに送ります。以下の例では、メモリを加えると 6 件の後のチケットがすべて期待どおりのチームに送られます。各チケットを単独で振り分けると 6 件中 2 件しか正解しません。

シンプルなメモリシステムには 2 つの部分があります:

  • 各呼び出しの後、Jev は元のリクエストとその答えを一緒に見ます。ここではゲートと呼ぶ Noul 質問が、そのリクエストが記憶すべき顧客に関する重要な事実を述べているかを尋ねます。P(yes) が 0.5 以上なら、そのチケットと Jev の答えが、その顧客のメモリとして保存されます。
  • ラッパー関数 ask_with_memory() は、ask() と同じ state と questions 引数を受け取り、Jev の応答を返します。これは、モデルを固定して呼び出しをキャッシュした TypeSafe Python SDK の client.system_one メソッドです。ラッパーは各呼び出しの前に、その顧客の保存済みチケットとそれに対する Jev の答えを state に加えます。

このラッパーは基本的なエージェントハーネスです。ハーネスとは、モデルを包むコードで、ツール呼び出しやループ実行といった追加の能力を与えます。この基本的なおもちゃのハーネスは、顧客 ID ごとに 1 つのリストを持つ素の Python dict でメモリだけを与えます。

  %%{init: {"fontFamily": "Inter, sans-serif", "flowchart": {"rankSpacing": 25, "wrappingWidth": 300, "subGraphTitleMargin": {"top": 8, "bottom": 20}}}}%%
flowchart TB
    IN["ask_with_memory(state, questions)"]
    subgraph R["Jev: answer the question"]
        Q1["<b>Choice:</b> which support team?"]
    end
    subgraph G["Jev: judge the routed ticket"]
        Q2["<b>Noul:</b> does the request state<br/>an important fact about the customer?"]
    end
    DEC{"P(yes) ≥ 0.5?<br/>your code"}
    SAVE["save the memory<br/>under this customer's ID"]
    OUT["handle the support ticket response in your code"]
    MEM[("MEMORIES<br/>saved memories per customer")]
    IN -- "state with memories<br/>+ routing question" --> R
    R -- "original request + answer<br/>+ memory question" --> G
    G -- "P(yes)" --> DEC
    DEC -- "yes: save" --> SAVE
    DEC -- "no: don't save" --> OUT
    SAVE --> OUT
    SAVE --> MEM
    IN -. "added to the state<br/>on this customer's<br/>next support tickets" .- MEM

ラッパーは Jev リクエストを 2 回、順に行います:ルーティングのリクエスト、次に、チケットを Jev の答えと一緒に判定するゲートです。ラッパーは、何かが保存されたかどうかに関わらず、ルーティングの応答を返します。

ask_with_memory() は ask() と同じ引数を受け取り、同じ応答を返すので、他のコードを一切変えずに一方を他方に差し替えられます。ラッパーは顧客のメモリを見つけて state に加え、新しいものは自分で保存します。

例では、2 人の顧客からの 5 件の以前のチケットをラッパーに通し、その後、各顧客からの 3 件の後のメッセージを 2 回ずつ振り分けます:1 回は保存されたメモリあり、1 回はなしです。表が 6 件すべてについて 2 つの答えを並べます。

セットアップ

pip install ipython 'cooksafe>=0.2.0,<0.3.0'

TYPESAFE_API_KEY を設定します。すべての API 呼び出しは json_cache.json にキャッシュされます。API を呼ぶ代わりに公開された数値を再現するには、このコードを実行するフォルダにそれをダウンロードしてください。すべてライブで実行するには省いてください。

以下の数値は 2026-09-28 の jev-1.13.0 によるものです。メモリのしきい値 0.5 は出発点です。自分の例に対して評価してください。

import json
import os
from pathlib import Path

from cooksafe import JsonCache, make_playground_link
from IPython.display import Markdown, display
from typesafe_sdk import Choice, Noul, NoulCriteria, SystemOneResponse, TypeSafeClient

TYPESAFE_MODEL = "jev-1.13.0"
REMEMBER_AT = 0.5  # save when P(lasting customer fact) reaches this starting threshold
MEMORY_KEY = "earlier_tickets_from_this_customer"  # where saved tickets go in the state

client = TypeSafeClient(
    api_key=os.environ.get("TYPESAFE_API_KEY", "cache-only"),  # keyless kernels replay the cache
    base_url=os.environ.get("TYPESAFE_ENDPOINT"),
    timeout=120.0,
)
json_cache = JsonCache(Path("json_cache.json"))

チケットを定義する

2 人の顧客、5 件の以前のチケット、3 件の後のメッセージで、すべてこの cookbook のために書かれたものです。C-1042(Harbor Logistics)は、エンタープライズ契約の下で Windows Server 上のセルフホスト版を運用しています。C-2210(Fernwood Studio)は、クラウド版のセルフサーブ Team プランです。以前のチケットのうち 3 件は、持続する事実を述べています:エディション、プラン、契約です。2 件は述べていません:空港での電話、祝日です。後のメッセージはどれも顧客の構成に触れていないので、メモリがなければ Jev はそれを推測しなければなりません。

各チケットは 2 つの部分を持つ state になります:customer(顧客が誰か)と ticket(チケットのスレッド)です。ticket_state() 関数は、ヘルプデスクのもののような簡略化したチケットを組み立てます。あなたのアプリでは、state はヘルプデスクが送るままの各チケットで、ask_with_memory() がそれに顧客の保存済みチケットを加えます。以前のチケットと後のメッセージへの分割は、この例のためだけのものです。

DATA = {
    "customers": {
        "C-1042": {"id": "C-1042", "company": "Harbor Logistics"},
        "C-2210": {"id": "C-2210", "company": "Fernwood Studio"},
    },
    "earlier_tickets": [
        {"id": "T-101", "customer_id": "C-1042", "received_on": "2026-08-04",
         "subject": "Adding an admin",
         "text": "Hi, we run your self-hosted edition on Windows Server 2022 in our own data "
                 "centre. How do I add a new admin user?"},
        {"id": "T-102", "customer_id": "C-2210", "received_on": "2026-08-11",
         "subject": "Exporting to PDF",
         "text": "We're a small design studio on your cloud edition, paying monthly on the "
                 "self-serve Team plan. How do I export a dashboard as a PDF?"},
        {"id": "T-103", "customer_id": "C-1042", "received_on": "2026-08-19",
         "subject": "Invoice download",
         "text": "Sorry for the typos, typing this on my phone at the airport. Where can I "
                 "download last month's invoice?"},
        {"id": "T-104", "customer_id": "C-2210", "received_on": "2026-09-02",
         "subject": "Dark mode?",
         "text": "Our whole team is out on Friday for a public holiday, so no rush on this "
                 "one. Is there a dark mode?"},
        {"id": "T-105", "customer_id": "C-1042", "received_on": "2026-09-10",
         "subject": "Sandbox environment",
         "text": "For context, we signed an Enterprise contract with you in March. Can we get "
                 "a sandbox environment for testing?"},
    ],
    "later_messages": [
        {"subject": "Slow dashboards",
         "text": "Dashboards have been really slow since this morning."},
        {"subject": "Upgrade failing",
         "text": "The upgrade to version 5.2 keeps failing halfway through."},
        {"subject": "More seats",
         "text": "We'd like to add 20 more seats before next quarter."},
    ],
    "later_received_on": "2026-09-28",
    # Labelled by hand from what each customer said in the earlier tickets.
    "expected_team": {
        "C-1042": {"Slow dashboards": "selfhosted_windows",
                   "Upgrade failing": "selfhosted_windows", "More seats": "enterprise_desk"},
        "C-2210": {"Slow dashboards": "cloud_ops", "Upgrade failing": "cloud_ops",
                   "More seats": "billing"},
    },
}
CUSTOMERS = DATA["customers"]

def ticket_state(customer_id: str, ticket_id: str, received_on: str, subject: str,
                 text: str) -> dict:
    """The state Jev sees for one ticket: a simplified ticket, like one from a helpdesk."""
    return {
        "customer": CUSTOMERS[customer_id],
        "ticket": {
            "id": ticket_id,
            "received_on": received_on,
            "subject": subject,
            "messages": [{"from": "customer", "text": text}],
        },
    }

EARLIER = [
    ticket_state(t["customer_id"], t["id"], t["received_on"], t["subject"], t["text"])
    for t in DATA["earlier_tickets"]
]
print(f"{len(CUSTOMERS)} customers, {len(EARLIER)} earlier tickets, "
      f"{len(DATA['later_messages'])} later messages. The first ticket as Jev sees it:\n")
print(json.dumps(EARLIER[0], indent=2))
2 customers, 5 earlier tickets, 3 later messages. The first ticket as Jev sees it:

{
  "customer": {
    "id": "C-1042",
    "company": "Harbor Logistics"
  },
  "ticket": {
    "id": "T-101",
    "received_on": "2026-08-04",
    "subject": "Adding an admin",
    "messages": [
      {
        "from": "customer",
        "text": "Hi, we run your self-hosted edition on Windows Server 2022 in our own data centre. How do I add a new admin user?"
      }
    ]
  }
}

チケットを振り分ける

1 つの Choice 質問がサポートチームを選びます。none_suitable の選択肢は、どのチームも当てはまらないときの答えを Jev に与え、文脈が乏しすぎるチケットはそこに落ち着くことがあります。

ヘルパー ask() は、モデルのバージョンを固定し、すべての呼び出しをキャッシュした client.system_one です。state と質問の dict を受け取り、SDK 自身の応答オブジェクトを返すので、client.system_one の応答をすでに読んでいるコードはそのまま動作します。

ROUTE = {
    "team": Choice(
        instructions="Which support team should handle `ticket`?",
        criteria={
            "cloud_ops": "Cloud team: problems with the hosted cloud edition, run by us",
            "selfhosted_linux": "Self-hosted team, Linux: installs, upgrades and "
            "performance of the self-hosted edition on Linux servers",
            "selfhosted_windows": "Self-hosted team, Windows: installs, upgrades and "
            "performance of the self-hosted edition on Windows Server",
            "billing": "Billing: invoices, payments, seats and plan changes for "
            "self-serve plans",
            "enterprise_desk": "Enterprise desk: seats, contracts and account changes for "
            "customers on an Enterprise contract (their technical problems go to the "
            "technical teams)",
            "general": "General product questions: features, how-to, settings",
            "none_suitable": "None of these teams fits the ticket",
        },
    ),
}

@json_cache
def _system_one(model: str, state: str, questions: str) -> dict:
    response = client.system_one(
        state=json.loads(state), questions=json.loads(questions), model=model
    )
    return response.model_dump(mode="json")

def ask(state: dict, questions: dict) -> SystemOneResponse:
    """client.system_one, with the model pinned and the call cached."""
    as_json = {qid: q.model_dump(mode="json", exclude_none=True) for qid, q in questions.items()}
    raw = _system_one(TYPESAFE_MODEL, json.dumps(state), json.dumps(as_json))
    return SystemOneResponse.model_validate(raw)

def later_state(customer_id: str, message_index: int) -> dict:
    """One of the later messages, sent by this customer, with a fixed ticket ID."""
    n = 201 + 3 * list(CUSTOMERS).index(customer_id) + message_index
    message = DATA["later_messages"][message_index]
    return ticket_state(customer_id, f"T-{n}", DATA["later_received_on"], message["subject"],
                        message["text"])

slow = later_state("C-1042", 0)
team = ask(slow, ROUTE).answers["team"]
print(f"C-1042: {slow['ticket']['messages'][0]['text']!r}")
print(f"  plain Jev -> {team.choice} {team.probabilities[team.choice]:.2f}")
C-1042: 'Dashboards have been really slow since this morning.'
  plain Jev -> cloud_ops 0.80

素の Jev は、C-1042 の遅いダッシュボードをクラウドチームに送ります。このチケットだけでは、それ以外のことをする理由がありません。

チケットが記憶する価値があるかを Jev に尋ねる

まず、as_memory() が元の state と Jev の答えを組にします:ラッパーが保存するかもしれないメモリです。request キーはメモリが注入される前の state を保持し、jev_answered は各質問をその答えに対応付けます。これにより、古いメモリが新しいメモリの中に次々と入れ子になるのを防ぎます。

2 回目の Jev 呼び出しがその組を読みます。ゲートは、そのリクエストが顧客に関する重要な事実、たとえばエディション、オペレーティングシステム、プラン、契約を述べているかを尋ねます。Jev の答えは文脈としてそこにありますが、答えにしか現れない事実は数えません。この規則がなければ、「General product questions」のような一般的な答えがリクエスト内の本物の事実を上回ることがあり、以前のメモリに依拠した答えが、新しいものであるかのように再び保存されえます。

GATE = {
    "remember": Noul(
        instructions=(
            "In `request.ticket`, does the thread state a lasting fact about the customer that "
            "should change how their future, unrelated tickets are handled? Count what the "
            "customer or our support staff wrote in `request.ticket`. `jev_answered` shows how "
            "the ticket was routed, which may rely on things learned earlier: do not count "
            "anything it says or implies."
        ),
        criteria=NoulCriteria(
            true=(
                "Yes: in `request.ticket` the customer or our support staff state something "
                "about the customer that stays true after this ticket, such as the product "
                "edition or operating system they run, their plan or contract, or a standing "
                "preference."
            ),
            false=(
                "No: `request.ticket` only contains things specific to this one ticket or "
                "moment, such as a one-off request, today's schedule, or the device they "
                "happen to be typing on; or the lasting fact appears only in `jev_answered`."
            ),
        ),
    ),
}

def answer_text(question, answer):
    """The readable part of an answer: the chosen option's description, or the number."""
    if answer.type == "choice":
        return question.criteria[answer.choice]
    return answer.noul if answer.type == "noul" else answer.score

def as_memory(state: dict, questions: dict, response: SystemOneResponse) -> dict:
    return {
        "request": state,
        "jev_answered": {
            q.instructions: answer_text(q, response.answers[qid])
            for qid, q in questions.items()
        },
    }

def remember_probability(memory: dict) -> float:
    """P(the request states an important fact about the customer), with the answer as context."""
    return ask(memory, GATE).answers["remember"].noul

記憶するように呼び出しを包む

ラッパー ask_with_memory() は、ask() と同じ引数と戻り値を持ちます。メモリの保管場所は、顧客 ID ごとに 1 つのリストを持つ素の dict です。ラッパーは state 内の ID を使って、その顧客のメモリを選びます。

MEMORIES: dict[str, list[dict]] = {}  # customer ID -> that customer's saved memories

def customer_id(state: dict) -> str:
    return state["customer"]["id"]

def ask_with_memory(state: dict, questions: dict) -> SystemOneResponse:
    """ask(), plus memory: same arguments, same return value."""
    # 1. Answer the call with this customer's existing memories.
    saved = MEMORIES.get(customer_id(state), [])
    response = ask({**state, MEMORY_KEY: saved} if saved else state, questions)

    # 2. Ask Jev whether the original request states an important fact worth keeping.
    memory = as_memory(state, questions, response)
    if remember_probability(memory) >= REMEMBER_AT:
        MEMORIES.setdefault(customer_id(state), []).append(memory)
    return response

この方法でメモリを加えると、あなたのアプリに 4 つの結果があります:

  • すべての呼び出しが 2 つの連続したリクエスト、あなたの呼び出しとそれに続くメモリゲートを行います。ゲートはチケットを Jev の答えと一緒に判定するので、ルーティングリクエストの後に実行されます。ゲートが答えを無視するなら、代わりにルーティングリクエスト内の 2 番目の質問にできます(投機的ファンアウトを参照)。
  • メモリは増える一方です。 保存されたメモリはすべて、その顧客の後のすべての呼び出しに入ります。ここにはサイズ制限も、関連性のチェックも、有効期限もありません。次のステップのセクションに、それぞれのアイデアがあります。
  • あなたの質問はメモリに一切触れません。 メモリは earlier_tickets_from_this_customer の下で state に入り、Jev は state 全体を読みます。ROUTE の何も変わりません。
  • state には customer.id が必要です。 素の Jev は state として文字列も受け付けますが、このラッパーは顧客のリストを見つけるために ID を必要とします。

以前のチケットを送り、答えが変わるのを見る

5 件の以前のチケットを、届いた順に ask_with_memory() に通します。同じ顧客が、後のメッセージのうち 2 件を再び送ります:遅いダッシュボードと、20 席の追加です。これにより、保存された各メモリが Jev の答えをどう変えるかが分かります。繰り返したメッセージもラッパーを通るので、ゲートはそれらも判定します。

PROBES = {"Slow dashboards": 0, "More seats": 2}  # later messages to send after each ticket

def memory_ids(cid: str) -> str:
    return ", ".join(m["request"]["ticket"]["id"] for m in MEMORIES.get(cid, [])) or "none"

def send_probes(cid: str) -> None:
    for subject, i in PROBES.items():
        team = ask_with_memory(later_state(cid, i), ROUTE).answers["team"]
        print(f"      {subject:<16} -> {team.choice:<19} {team.probabilities[team.choice]:.2f}")

for cid in CUSTOMERS:
    print(f"{cid}, memories: {memory_ids(cid)}")
    send_probes(cid)

for state in EARLIER:
    cid = customer_id(state)
    response = ask_with_memory(state, ROUTE)
    p = remember_probability(as_memory(state, ROUTE, response))  # cached: the wrapper's call
    verdict = "saved" if p >= REMEMBER_AT else "not saved"
    text = state["ticket"]["messages"][0]["text"]
    print(f"\n{cid} {state['ticket']['id']}  {response.answers['team'].choice:<19} "
          f"P(remember) {p:.2f}  {verdict}")
    print(f"    {text[:84]}")
    print(f"{cid}, memories: {memory_ids(cid)}")
    send_probes(cid)
C-1042, memories: none
      Slow dashboards  -> cloud_ops           0.80
      More seats       -> enterprise_desk     0.62
C-2210, memories: none
      Slow dashboards  -> cloud_ops           0.75
      More seats       -> enterprise_desk     0.52

C-1042 T-101  selfhosted_windows  P(remember) 0.91  saved
    Hi, we run your self-hosted edition on Windows Server 2022 in our own data centre. H
C-1042, memories: T-101
      Slow dashboards  -> selfhosted_windows  0.99
      More seats       -> enterprise_desk     0.44

C-2210 T-102  general             P(remember) 0.91  saved
    We're a small design studio on your cloud edition, paying monthly on the self-serve
C-2210, memories: T-102
      Slow dashboards  -> cloud_ops           0.91
      More seats       -> billing             0.98

C-1042 T-103  billing             P(remember) 0.07  not saved
    Sorry for the typos, typing this on my phone at the airport. Where can I download la
C-1042, memories: T-101
      Slow dashboards  -> selfhosted_windows  0.99
      More seats       -> enterprise_desk     0.44

C-2210 T-104  general             P(remember) 0.10  not saved
    Our whole team is out on Friday for a public holiday, so no rush on this one. Is the
C-2210, memories: T-102
      Slow dashboards  -> cloud_ops           0.91
      More seats       -> billing             0.98

C-1042 T-105  enterprise_desk     P(remember) 0.92  saved
    For context, we signed an Enterprise contract with you in March. Can we get a sandbo
C-1042, memories: T-101, T-105
      Slow dashboards  -> selfhosted_windows  0.94
      More seats       -> enterprise_desk     0.99

エディション、プラン、契約を述べている 3 件のチケットは 0.91〜0.92 で保存されます。T-102 は、Jev がそれを一般チームに振り分けたにもかかわらず保存されます。ゲートは答えではなく顧客の言葉を数えるからです。空港と祝日のチケットは 0.07 と 0.10 で、保存されないので、その後の答えは変わりません。

保存された各メモリは、それが関係する答えを変えます。C-1042 では、Windows のチケットが遅いダッシュボードをクラウドチーム(0.80)から Windows チーム(0.99)へ動かします。次にエンタープライズ契約が席を 0.99 に落ち着かせます。C-2210 では、Team プランのチケットがクラウドチームを 0.75 から 0.91 に引き上げ、席をエンタープライズデスク(0.52)から billing(0.98)へ動かします。エンタープライズのメモリを加えると、C-1042 の遅いダッシュボードは 0.99 から 0.94 へわずかに下がります。これは、どのメモリを加えるかを選ぶ理由の 1 つです(次のステップを参照)。ゲートは繰り返したメッセージを 1 つも保存しませんでした。

両方の顧客について同じメッセージを振り分ける

各顧客が今度は 3 件の後のメッセージを送ります。各メッセージは、同じ state と同じ質問で、素の ask() と ask_with_memory() の両方に渡されます。

EXPECTED = DATA["expected_team"]
plain_correct = memory_correct = total = 0
example_state = None

def cell(answer, expected: str) -> str:
    mark = "✓" if answer.choice == expected else "✗"
    return f"{mark} {answer.choice} {answer.probabilities[answer.choice]:.2f}"

print(f"{'customer':<9}{'message':<17}{'expected':<20}{'plain Jev':<27}{'with memory':<27}")
for cid in CUSTOMERS:
    for i, message in enumerate(DATA["later_messages"]):
        state = later_state(cid, i)
        expected = EXPECTED[cid][message["subject"]]
        plain = ask(state, ROUTE).answers["team"]
        if example_state is None:
            # Keep the exact state used for this call for the playground link.
            saved = MEMORIES.get(cid, [])
            example_state = json.loads(json.dumps({**state, MEMORY_KEY: saved} if saved else state))
        response = ask_with_memory(state, ROUTE)
        remembered = response.answers["team"]
        plain_correct += plain.choice == expected
        memory_correct += remembered.choice == expected
        total += 1
        print(f"{cid:<9}{message['subject']:<17}{expected:<20}{cell(plain, expected):<27}"
              f"{cell(remembered, expected):<27}")

print(f"\nExpected routes: {plain_correct}/{total} without memory, "
      f"{memory_correct}/{total} with memory.")
customer message          expected            plain Jev                  with memory
C-1042   Slow dashboards  selfhosted_windows  ✗ cloud_ops 0.80           ✓ selfhosted_windows 0.94
C-1042   Upgrade failing  selfhosted_windows  ✗ none_suitable 0.60       ✓ selfhosted_windows 1.00
C-1042   More seats       enterprise_desk     ✓ enterprise_desk 0.62     ✓ enterprise_desk 0.99
C-2210   Slow dashboards  cloud_ops           ✓ cloud_ops 0.75           ✓ cloud_ops 0.91
C-2210   Upgrade failing  cloud_ops           ✗ none_suitable 0.63       ✓ cloud_ops 0.86
C-2210   More seats       billing             ✗ enterprise_desk 0.52     ✓ billing 0.98

Expected routes: 2/6 without memory, 6/6 with memory.

メモリありでは、6 件のメッセージすべてが期待どおりのチームに届きます。メモリなしでは 2 件です。同じメッセージが顧客ごとに異なるチームへ行くようになります:遅いダッシュボードは C-1042 では Windows チームへ、C-2210 ではクラウドチームのままです。20 席の追加は C-1042 ではエンタープライズデスクへ、C-2210 では billing へ行きます。素の Jev がすでに正しかったところでも、メモリは確率を引き上げ、C-1042 の席では 0.62 から 0.99 になります。ラッパーは 6 件の後のメッセージも判定し、1 つも保存しませんでした:重要な事実を述べていないからです。

各行の期待チームは、以前のチケットにある顧客の構成から導かれます:C-1042 のセルフホスト版とエンタープライズ契約、C-2210 のクラウド Team プランです。

Playground で開く

このリンクは、C-1042 の最初の遅いダッシュボード呼び出しで使われた正確なルーティング state を、その時点のメモリとルーティング質問とともに保持します。

playground_link = make_playground_link(example_state, ROUTE, models=[TYPESAFE_MODEL])
display(Markdown(
    f"🔗 [Open C-1042's ticket with its memories in the TypeSafe playground]({playground_link})"
))
C-1042 のチケットをそのメモリとともに TypeSafe playground で開く →

次のステップ

  • 自分のアプリが何を記憶すべきかを選ぶ。 GATE を編集して、自分のタスクで記憶する価値があるものを記述し、REMEMBER_AT をラベル付けした自分の例に対してテストします。
  • どのメモリを加えるかを選ぶ。 ラッパーは保存されたメモリをすべて加えます。リストが長くなったら、関連性の質問でより小さな集合を選べます。
  • 古くなったメモリを置き換える。 新しいメモリが古いものを置き換えるかを尋ね、適切なときにコードで古いエントリを削除します。
  • 実行をまたいでメモリを保つ。 MEMORIES を、顧客 ID をキーとするデータベースに置き換えます。インメモリの dict はプロセスが終了すると消えます。
  • 振り分けに基づいて行動する。 各チームをコード内のハンドラに対応付けます。たとえばエンタープライズ顧客に通話を予約したり、セットアップ固有の記事を送ったりします。意図ルーティングと信頼度ルーティングを参照してください。あなたの返信をサポートメッセージとしてチケットスレッドに加えると、ゲートはあなたが何をしたかを記憶できます。

付録

保存された答えが誤りを強めることはありますか?

はい。ゲートは Jev の答えにしか現れないものを無視するので、答えだけでチケットが保存されることはありません。しかし一旦チケットが保存されると、その答えも一緒に保存され、誤った推論も含めてすべてが、その顧客の後のすべての呼び出しで読まれます。すると後の答えがその誤りを繰り返すことがあります。

しきい値はどう選べばよいですか?

このラッパーの 0.5 は出発値です。自分で選ぶには、あなたのトラフィックからリクエストと答えの組を、記憶する価値があるかどうかでラベル付けし、2 つのグループを最もよく分ける確率を見つけます。それを使って選ばなかった組で確認してください。誤解を招くメモリのコストが、記憶し損ねるコストより大きいなら値を上げ、逆なら下げます。しきい値の選び方と、各アクションのリスクへの合わせ方は、信頼度と信頼度ルーティングを参照してください。