문서

간단한 메모리 시스템

Jev가 기억할 가치가 있는 요청과 답을 결정하게 하고, 호출을 작은 함수로 감싸 이후 호출에 기억을 더합니다.

각 Jev 요청은 여러분이 보낸 state만 봅니다. 고객이 지난달에 여러분의 앱에 말한 것, 이를테면 에디션이나 요금제는, 여러분의 코드가 그것을 넣지 않는 한 다음 요청에 들어 있지 않습니다. 여기서 만드는 메모리 시스템은 호출마다 Jev 요청을 하나 더 보내고 Python 딕셔너리 하나를 써서 그것을 해냅니다.

우리의 예제는 지원 티켓을 라우팅합니다. 한 고객이 8월에 Windows Server에서 자체 호스팅한다고 말했습니다. 9월에 그 고객이 “대시보드가 오늘 아침부터 정말 느려졌어요”라고 씁니다. 메모리가 없으면 Jev는 그 티켓을 자체 호스팅 팀이 아니라 클라우드 팀으로 보냅니다. 아래 예제에서는 메모리를 추가하면 이후 티켓 여섯 개가 모두 기대한 팀으로 갑니다. 티켓을 각각 따로 라우팅하면 여섯 개 중 두 개만 맞습니다.

간단한 메모리 시스템은 두 부분으로 이루어집니다.

  • 호출이 끝날 때마다 Jev는 원래 요청과 그 답을 함께 봅니다. 우리가 게이트라고 부르는 Noul 질문이, 그 요청이 기억해야 할 고객에 관한 중요한 사실을 담고 있는지 묻습니다. P(yes)가 0.5 이상이면, 그 티켓과 Jev의 답이 그 고객의 메모리로 저장됩니다.
  • 래퍼 함수 ask_with_memory()는 모델을 고정하고 호출을 캐시한 TypeSafe Python SDK의 client.system_one 메서드인 ask()와 같은 state와 questions 인수를 받아 Jev 응답을 반환합니다. 이 함수는 호출 전에 고객이 저장한 티켓과 그에 대한 Jev의 답을 state에 더합니다.

그 래퍼는 기본적인 에이전트 harness입니다. harness는 모델 주위의 코드로, 도구 호출이나 루프 실행 같은 추가 능력을 모델에 부여합니다. 이 기본 장난감 래퍼는 고객 ID마다 리스트 하나를 둔 평범한 Python 딕셔너리로 메모리만 부여합니다.

  %%{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 요청을 하나씩 연달아 두 번 보냅니다. 먼저 라우팅 요청, 그다음 티켓을 Jev의 답과 함께 심사하는 게이트입니다. 래퍼는 저장된 것이 있든 없든 라우팅 응답을 반환합니다.

ask_with_memory()가 ask()와 같은 인수를 받고 같은 응답을 반환하므로, 다른 코드를 바꾸지 않고도 하나를 다른 하나로 바꿔 쓸 수 있습니다. 래퍼는 고객의 메모리를 찾아 state에 더하고 새 메모리를 스스로 저장합니다.

이 예제는 두 고객의 이전 티켓 다섯 개를 래퍼에 보낸 다음, 각 고객의 이후 메시지 세 개를 두 번씩 라우팅합니다. 한 번은 저장한 메모리와 함께, 한 번은 메모리 없이. 표에서 여섯 개 모두의 두 답을 나란히 놓습니다.

준비

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"))

티켓 정의하기

두 고객, 이전 티켓 다섯 개, 이후 메시지 세 개가 모두 이 쿡북을 위해 작성되었습니다. C-1042(Harbor Logistics)는 Enterprise 계약으로 Windows Server에서 자체 호스팅 에디션을 운영합니다. C-2210(Fernwood Studio)은 클라우드 에디션의 셀프서브 Team 요금제를 씁니다. 이전 티켓 세 개는 지속되는 사실을 밝힙니다. 에디션, 요금제, 계약입니다. 두 개는 그렇지 않습니다. 공항에서 건 전화, 공휴일입니다. 이후 메시지 중 고객의 환경을 언급하는 것은 없으므로, 메모리가 없으면 Jev는 그것을 추측해야 합니다.

각 티켓은 두 부분을 가진 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?"
      }
    ]
  }
}

티켓 라우팅하기

Choice 질문 하나가 지원 팀을 고릅니다. none_suitable 선택지는 어떤 팀도 맞지 않을 때 Jev가 답할 수 있게 해주며, 컨텍스트가 너무 적은 티켓이 여기로 갈 수 있습니다.

헬퍼 ask()는 모델 버전을 고정하고 모든 호출을 캐시한 client.system_one입니다. state 하나와 질문 딕셔너리 하나를 받아 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는 각 질문을 그 답에 매핑합니다. 이렇게 하면 오래된 메모리가 새 메모리마다 안에 중첩되는 것을 막습니다.

두 번째 Jev 호출이 그 짝을 읽습니다. 게이트는 그 요청이 고객에 관한 중요한 사실(에디션, 운영체제, 요금제, 계약 등)을 담고 있는지 묻습니다. Jev의 답이 컨텍스트로 함께 있지만, 답에만 나타나는 사실은 세지 않습니다. 그 규칙이 없으면 “일반 제품 질문” 같은 두루뭉술한 답이 요청 속 진짜 사실을 압도할 수 있고, 앞선 메모리에 기댄 답이 새것인 양 다시 저장될 수 있습니다.

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마다 리스트 하나를 둔 평범한 딕셔너리입니다. 래퍼는 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

이렇게 메모리를 더하면 여러분의 앱에 네 가지 결과가 따릅니다.

  • 모든 호출이 순차적으로 두 번의 요청을 보냅니다. 여러분의 호출과 그 뒤의 메모리 게이트입니다. 게이트는 티켓을 Jev의 답과 함께 심사하므로 라우팅 요청 뒤에 실행됩니다. 여러분의 게이트가 답을 무시한다면 대신 라우팅 요청의 두 번째 질문으로 둘 수 있습니다(팬아웃 참조).
  • 메모리는 늘어나기만 합니다. 저장된 메모리마다 그 고객의 이후 모든 호출에 들어갑니다. 여기에는 크기 제한도, 관련성 검사도, 만료일도 없습니다. 다음 단계 절에 각각에 대한 아이디어가 있습니다.
  • 여러분의 질문은 메모리를 언급하지 않습니다. 메모리는 earlier_tickets_from_this_customer 아래 state로 들어가고, Jev는 state 전체를 읽습니다. ROUTE에서 바뀌는 것은 없습니다.
  • state에는 customer.id가 필요합니다. 평범한 Jev는 state로 문자열도 받지만, 이 래퍼는 고객의 리스트를 찾기 위해 ID가 필요합니다.

이전 티켓을 보내고 답이 바뀌는지 지켜보기

이전 티켓 다섯 개를 도착한 순서대로 ask_with_memory()에 보냅니다. 같은 고객이 이후 메시지 중 두 개(느린 대시보드와 좌석 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

에디션, 요금제, 계약을 밝히는 티켓 세 개는 0.91~0.92로 저장됩니다. T-102는 Jev가 그것을 일반 팀으로 라우팅했는데도 저장됩니다. 게이트는 답이 아니라 고객의 말을 세기 때문입니다. 공항과 공휴일 티켓은 0.07과 0.10을 받아 저장되지 않으므로, 그 뒤의 답은 바뀌지 않습니다.

저장된 메모리마다 그것이 관련된 답을 바꿉니다. C-1042의 경우 Windows 티켓이 느린 대시보드를 클라우드 팀(0.80)에서 Windows 팀(0.99)으로 옮깁니다. 이어서 Enterprise 계약이 좌석을 0.99로 정리합니다. C-2210의 경우 Team 요금제 티켓이 클라우드 팀을 0.75에서 0.91로 올리고 좌석을 Enterprise 데스크(0.52)에서 청구(0.98)로 옮깁니다. Enterprise 메모리를 추가하면 C-1042의 느린 대시보드가 0.99에서 0.94로 조금 낮아지는데, 이것이 어떤 메모리를 더할지 골라야 하는 이유 하나입니다(다음 단계 참조). 게이트는 반복된 메시지를 하나도 저장하지 않았습니다.

두 고객에 대해 같은 메시지 라우팅하기

이제 각 고객이 이후 메시지 세 개를 보냅니다. 각 메시지는 같은 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.

메모리를 쓰면 여섯 메시지가 모두 기대한 팀에 도달하고, 없으면 두 개입니다. 이제 같은 메시지가 고객마다 다른 팀으로 갑니다. 느린 대시보드는 C-1042에서는 Windows 팀으로 가고 C-2210에서는 클라우드 팀에 남으며, 좌석 20개 추가는 C-1042에서는 Enterprise 데스크로, C-2210에서는 청구로 갑니다. 평범한 Jev가 이미 맞던 곳에서도 메모리는 확률을 올립니다. C-1042의 좌석은 0.62에서 0.99로 올라갑니다. 래퍼는 이후 메시지 여섯 개도 심사했고 하나도 저장하지 않았습니다. 그것들은 중요한 사실을 담고 있지 않습니다.

각 행의 기대 팀은 이전 티켓에 담긴 고객의 환경에서 나옵니다. C-1042의 자체 호스팅 에디션과 Enterprise 계약, 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로 키를 지정한 데이터베이스로 교체하십시오. 인메모리 딕셔너리는 프로세스가 종료되면 사라집니다.
  • 라우팅 결과에 따라 행동하십시오. 각 팀을 코드의 핸들러에 매핑하십시오. 예컨대 Enterprise 고객의 통화를 예약하거나 설정별 문서를 보내는 식입니다. 인텐트 라우팅과 신뢰도 기반 라우팅을 참조하십시오. 여러분의 답변을 지원 메시지로 티켓 스레드에 더하면, 게이트가 여러분이 한 일을 기억할 수 있습니다.

부록

저장된 답이 실수를 강화할 수 있나요?

그렇습니다. 게이트는 Jev의 답에만 나타나는 것은 무시하므로, 답 자체만으로 티켓이 저장될 수는 없습니다. 하지만 티켓이 한 번 저장되면 그 답도 함께 저장됩니다. 틀린 추론까지 포함해서요. 그리고 그 고객의 이후 모든 호출이 그것을 읽습니다. 그러면 이후의 답이 그 실수를 되풀이할 수 있습니다.

임계값은 어떻게 골라야 하나요?

이 래퍼의 0.5는 출발값입니다. 여러분만의 값을 고르려면, 여러분의 트래픽에서 요청-답 쌍에 기억할 가치가 있는지 없는지 라벨을 붙이고, 두 집단을 가장 잘 가르는 확률을 찾으십시오. 그것을 고르는 데 쓰지 않은 쌍에서 확인하십시오. 잘못된 메모리가 놓친 메모리보다 더 큰 비용을 치른다면 올리고, 반대라면 내리십시오. 임계값을 고르고 각 행동의 위험에 맞추는 방법은 Confidence와 Confidence-Gated Routing을 참조하십시오.