import json
import re
def demo_result(messages):
q = messages[-1]["content"]
normalized = q.upper().replace("-", "").replace(" ", "")
previous = " ".join(m["content"] for m in messages[1:-1])
previous = previous.upper().replace("-", "").replace(" ", "")
explicit_code = re.search(r"[A-Z]{2}\s*-?\s*\d{3}", q.upper())
refers_back = any(word in q for word in ("그 가방", "그 상품", "이 가방", "이 상품"))
known_product = "AB120" in normalized or (
explicit_code is None and refers_back and "AB120" in previous
)
if "배송비" in q or "교환" in q:
data = {"answer": "배송비·교환 규정이 제공되지 않아 현재 안내할 수 없습니다.",
"needs_followup": False, "followup_question": None}
elif "주문" in q or "환불" in q or "배송" in q:
data = {"answer": "조회·처리 기능이 연결되지 않아 처리 결과를 확정할 수 없습니다.",
"needs_followup": False, "followup_question": None}
elif known_product:
if "가격" in q or "얼마" in q:
answer = "AB-120 데일리 백팩의 판매 가격은 39,000원입니다."
elif "무게" in q:
answer = "AB-120 데일리 백팩의 무게는 580g입니다."
elif "용량" in q:
answer = "AB-120 데일리 백팩의 용량은 18L입니다."
elif normalized.rstrip("?.!") in (
"AB120", "AB120이요", "AB120상품에대해알려주세요", "AB120상품을소개해주세요"
):
answer = "AB-120 데일리 백팩은 판매 가격 39,000원, 용량 18L, 무게 580g입니다."
else:
answer = "AB-120의 해당 정보는 참조 사실에 없어 현재 안내할 수 없습니다."
data = {"answer": answer, "needs_followup": False, "followup_question": None}
elif explicit_code:
data = {"answer": "문의하신 상품의 참조 사실이 제공되지 않아 현재 안내할 수 없습니다.",
"needs_followup": False, "followup_question": None}
else:
data = {"answer": "상품 문의를 도와드리겠습니다.",
"needs_followup": True,
"followup_question": "상품명이나 상품코드와 궁금한 점을 알려주시겠어요?"}
return {"answer": json.dumps(data, ensure_ascii=False), "usage": None, "model": "DEMO_MODE"}