Spaces:
Sleeping
Sleeping
optimize dialogue examples
Browse files- app.py +2 -2
- chroma_db/{123e8804-404f-4705-b512-8edeefb82a67 → 0cfbd3c3-6140-4ee1-85f8-a49ab34bcd3f}/data_level0.bin +1 -1
- chroma_db/{123e8804-404f-4705-b512-8edeefb82a67 → 0cfbd3c3-6140-4ee1-85f8-a49ab34bcd3f}/header.bin +0 -0
- chroma_db/{123e8804-404f-4705-b512-8edeefb82a67 → 0cfbd3c3-6140-4ee1-85f8-a49ab34bcd3f}/length.bin +1 -1
- chroma_db/{123e8804-404f-4705-b512-8edeefb82a67 → 0cfbd3c3-6140-4ee1-85f8-a49ab34bcd3f}/link_lists.bin +0 -0
- chroma_db/chroma.sqlite3 +0 -0
- docs2.json +2 -1
- process.ipynb +61 -2
app.py
CHANGED
|
@@ -31,7 +31,7 @@ def need_rag_check(model, user_input):
|
|
| 31 |
prompt = f"""
|
| 32 |
你是一個智慧客服助理。
|
| 33 |
對話內容:{user_input}
|
| 34 |
-
是否需要從保險資料庫中查詢才能回答(如果判斷是回復
|
| 35 |
如需要則輸出 "YES", 否則輸出 "NO"
|
| 36 |
"""
|
| 37 |
resp = model.generate_content(prompt)
|
|
@@ -134,7 +134,7 @@ if st.button("送出"):
|
|
| 134 |
retrieved_docs = "無匹配資料"
|
| 135 |
else:
|
| 136 |
retrieved_docs = "(模型判定此次提問無需檢索)"
|
| 137 |
-
|
| 138 |
# 組合對話
|
| 139 |
user_message = (
|
| 140 |
f"你擁有以下與『{user_input}』相關的專業知識:\n\n"
|
|
|
|
| 31 |
prompt = f"""
|
| 32 |
你是一個智慧客服助理。
|
| 33 |
對話內容:{user_input}
|
| 34 |
+
是否需要從保險資料庫中查詢才能回答(如果判斷是回復個人資訊,就不用,但如果是問有甚麼推薦的保險方案或者是與保險相關的資訊,就一定要查詢資料庫)?
|
| 35 |
如需要則輸出 "YES", 否則輸出 "NO"
|
| 36 |
"""
|
| 37 |
resp = model.generate_content(prompt)
|
|
|
|
| 134 |
retrieved_docs = "無匹配資料"
|
| 135 |
else:
|
| 136 |
retrieved_docs = "(模型判定此次提問無需檢索)"
|
| 137 |
+
print(retrieved_docs)
|
| 138 |
# 組合對話
|
| 139 |
user_message = (
|
| 140 |
f"你擁有以下與『{user_input}』相關的專業知識:\n\n"
|
chroma_db/{123e8804-404f-4705-b512-8edeefb82a67 → 0cfbd3c3-6140-4ee1-85f8-a49ab34bcd3f}/data_level0.bin
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4236000
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a0677edd3e3dc2b51e6c7153e9f3062e3748cfb0048c1619518fa8eb1e0cd91a
|
| 3 |
size 4236000
|
chroma_db/{123e8804-404f-4705-b512-8edeefb82a67 → 0cfbd3c3-6140-4ee1-85f8-a49ab34bcd3f}/header.bin
RENAMED
|
File without changes
|
chroma_db/{123e8804-404f-4705-b512-8edeefb82a67 → 0cfbd3c3-6140-4ee1-85f8-a49ab34bcd3f}/length.bin
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4000
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:03ae3aaa7e7e078f73de4503ad52bab18dee80f96af7a15c907c5846d3db8acf
|
| 3 |
size 4000
|
chroma_db/{123e8804-404f-4705-b512-8edeefb82a67 → 0cfbd3c3-6140-4ee1-85f8-a49ab34bcd3f}/link_lists.bin
RENAMED
|
File without changes
|
chroma_db/chroma.sqlite3
CHANGED
|
Binary files a/chroma_db/chroma.sqlite3 and b/chroma_db/chroma.sqlite3 differ
|
|
|
docs2.json
CHANGED
|
@@ -292,6 +292,7 @@
|
|
| 292 |
"metadata": {
|
| 293 |
"類型": "介紹方案案例_對話示範"
|
| 294 |
},
|
| 295 |
-
"text": "【外送員保險方案 - 對話示例
|
| 296 |
}
|
|
|
|
| 297 |
]
|
|
|
|
| 292 |
"metadata": {
|
| 293 |
"類型": "介紹方案案例_對話示範"
|
| 294 |
},
|
| 295 |
+
"text": "【外送員保險方案 - 對話示例(請按照以下示例)】\n\n(外送員 = U / 機器人 = R)\n\n--------------------------------------\n# 當外送員未指明平台\n\nU: 嗨,我是外送員,想了解一下有沒有合適的保險?\n\nR: 您好,請問您目前是哪個平台的外送員呢?foodpanda 或 ubereats?\n\nU: 我是 ubereats。\n\nR: 好的,ubereats 目前有兩個方案:\n1) 簡易(513/年)只有強制險,第三人責任險由平台付\n2) 進階(861/年)多 500 萬超額保險(348/年);此外平台已幫您負擔意外身故 300 萬、30 萬傷害醫療及日額 1,000。\n\nU: OK,我預算夠,想要加超額保險。\n\nR: 那就建議進階方案,年繳 861 元。\n\n--------------------------------------\n# foodpanda 範例\n\nU: 我是 foodpanda 外送員,想對自己的醫療做最完整的保障。\n\nR: 您可選第三級「安心方案」。它無 300 萬意外身故/3 萬實支,但可加『駕駛人傷害(200 萬/20 萬)』、醫療實支,以及含 500 萬超額保險。若想要 300 萬身故 & 3 萬實支,則需基礎或超值方案。\n\nU: 那我要安心方案,想請你做詳細試算。\n\nR: 安心方案基底約 3,225 元/年 (含強制險/駕駛人傷害/超額保險),再加上醫療實支(Y, 28 歲男性約 3,916) 總計約 7,141 元。視年齡、性別可調整。\n\n--------------------------------------\n# 若使用者決定投保 → 蒐集個人資訊\n\nU: 好,那就請幫我投保吧!\n\nR: 好的。為了辦理投保,需要請您提供以下個人資訊,並確認資料正確:\n1. 姓名 (例如:王曉明)\n2. 年齡 (例如:28)\n3. 性別 (例如:男)\n4. 居住地(盡可能詳細,如:新北市新莊區忠孝路128號6樓之3)\n5. 生日(月/日或完整西元,如:4/26 或 1995/04/26)\n6. 身分證字號(台灣格式,如:F123456789)\n\nU: 我叫陳涵生,23歲,男,新北市新莊區忠孝路128號6樓之3,5/9,身分證字號F130246782\n\nR: 已收到您的資料:\n- 姓名:陳涵生\n- 年齡:23\n- 性別:男\n- 居住地:新北市新莊區忠孝路128號6樓之3\n- 生日:4/26\n- 身分證字號:F130246782\n\n您所選擇的方案為「foodpanda 第三級安心方案」,預估年繳保費約 7,103 元 (基底 3,225 + 醫療實支 3,878,以25歲男性計算)。\n\n接著我��會協助您送交保險公司評核,並與您聯繫後續事宜。\n\n--------------------------------------\n# 結論\n1. 先問清楚平台(foodpanda / ubereats)。\n2. 了解年齡、性別、預算與保障需求。\n3. foodpanda:\n - 基礎(4,409/年,含意外實支)\n - 超值(4,757/年,含 500 萬超額)\n - 安心(3,225 + Y):可加駕駛人傷害(200萬) & 醫療實支,也含 500 萬超額\n4. ubereats:\n - 簡易(513) / 進階(861)\n - 平台附 300萬身故、30萬醫療、1,000日額\n5. 若對方決定投保,蒐集必要個資 (姓名、年齡、性別、地址、生日、身分證字號) 並重述所選方案與總保費。"
|
| 296 |
}
|
| 297 |
+
|
| 298 |
]
|
process.ipynb
CHANGED
|
@@ -57,14 +57,73 @@
|
|
| 57 |
},
|
| 58 |
{
|
| 59 |
"cell_type": "code",
|
| 60 |
-
"execution_count":
|
| 61 |
"metadata": {},
|
| 62 |
"outputs": [
|
| 63 |
{
|
| 64 |
"name": "stderr",
|
| 65 |
"output_type": "stream",
|
| 66 |
"text": [
|
| 67 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
]
|
| 69 |
},
|
| 70 |
{
|
|
|
|
| 57 |
},
|
| 58 |
{
|
| 59 |
"cell_type": "code",
|
| 60 |
+
"execution_count": 4,
|
| 61 |
"metadata": {},
|
| 62 |
"outputs": [
|
| 63 |
{
|
| 64 |
"name": "stderr",
|
| 65 |
"output_type": "stream",
|
| 66 |
"text": [
|
| 67 |
+
"Add of existing embedding ID: doc_001\n",
|
| 68 |
+
"Insert of existing embedding ID: doc_001\n",
|
| 69 |
+
"Add of existing embedding ID: doc_002\n",
|
| 70 |
+
"Insert of existing embedding ID: doc_002\n",
|
| 71 |
+
"Add of existing embedding ID: doc_003\n",
|
| 72 |
+
"Insert of existing embedding ID: doc_003\n",
|
| 73 |
+
"Add of existing embedding ID: doc_004\n",
|
| 74 |
+
"Insert of existing embedding ID: doc_004\n",
|
| 75 |
+
"Add of existing embedding ID: doc_005\n",
|
| 76 |
+
"Insert of existing embedding ID: doc_005\n",
|
| 77 |
+
"Add of existing embedding ID: doc_006\n",
|
| 78 |
+
"Insert of existing embedding ID: doc_006\n",
|
| 79 |
+
"Add of existing embedding ID: doc_007\n",
|
| 80 |
+
"Insert of existing embedding ID: doc_007\n",
|
| 81 |
+
"Add of existing embedding ID: doc_008\n",
|
| 82 |
+
"Insert of existing embedding ID: doc_008\n",
|
| 83 |
+
"Add of existing embedding ID: doc_009\n",
|
| 84 |
+
"Insert of existing embedding ID: doc_009\n",
|
| 85 |
+
"Add of existing embedding ID: doc_010\n",
|
| 86 |
+
"Insert of existing embedding ID: doc_010\n",
|
| 87 |
+
"Add of existing embedding ID: doc_011\n",
|
| 88 |
+
"Insert of existing embedding ID: doc_011\n",
|
| 89 |
+
"Add of existing embedding ID: doc_012\n",
|
| 90 |
+
"Insert of existing embedding ID: doc_012\n",
|
| 91 |
+
"Add of existing embedding ID: doc_013\n",
|
| 92 |
+
"Insert of existing embedding ID: doc_013\n",
|
| 93 |
+
"Add of existing embedding ID: doc_014\n",
|
| 94 |
+
"Insert of existing embedding ID: doc_014\n",
|
| 95 |
+
"Add of existing embedding ID: doc_015\n",
|
| 96 |
+
"Insert of existing embedding ID: doc_015\n",
|
| 97 |
+
"Add of existing embedding ID: doc_016\n",
|
| 98 |
+
"Insert of existing embedding ID: doc_016\n",
|
| 99 |
+
"Add of existing embedding ID: doc_017\n",
|
| 100 |
+
"Insert of existing embedding ID: doc_017\n",
|
| 101 |
+
"Add of existing embedding ID: doc_018\n",
|
| 102 |
+
"Insert of existing embedding ID: doc_018\n",
|
| 103 |
+
"Add of existing embedding ID: doc_019\n",
|
| 104 |
+
"Insert of existing embedding ID: doc_019\n",
|
| 105 |
+
"Add of existing embedding ID: doc_020\n",
|
| 106 |
+
"Insert of existing embedding ID: doc_020\n",
|
| 107 |
+
"Add of existing embedding ID: doc_021\n",
|
| 108 |
+
"Insert of existing embedding ID: doc_021\n",
|
| 109 |
+
"Add of existing embedding ID: doc_022\n",
|
| 110 |
+
"Insert of existing embedding ID: doc_022\n",
|
| 111 |
+
"Add of existing embedding ID: doc_023\n",
|
| 112 |
+
"Insert of existing embedding ID: doc_023\n",
|
| 113 |
+
"Add of existing embedding ID: doc_foodpanda_plan_1\n",
|
| 114 |
+
"Insert of existing embedding ID: doc_foodpanda_plan_1\n",
|
| 115 |
+
"Add of existing embedding ID: doc_foodpanda_plan_2\n",
|
| 116 |
+
"Insert of existing embedding ID: doc_foodpanda_plan_2\n",
|
| 117 |
+
"Add of existing embedding ID: doc_foodpanda_plan_3\n",
|
| 118 |
+
"Insert of existing embedding ID: doc_foodpanda_plan_3\n",
|
| 119 |
+
"Add of existing embedding ID: doc_uber_plan_1\n",
|
| 120 |
+
"Insert of existing embedding ID: doc_uber_plan_1\n",
|
| 121 |
+
"Add of existing embedding ID: doc_uber_plan_2\n",
|
| 122 |
+
"Insert of existing embedding ID: doc_uber_plan_2\n",
|
| 123 |
+
"Add of existing embedding ID: doc_comparison_overall\n",
|
| 124 |
+
"Insert of existing embedding ID: doc_comparison_overall\n",
|
| 125 |
+
"Add of existing embedding ID: doc_introduction_scenario\n",
|
| 126 |
+
"Insert of existing embedding ID: doc_introduction_scenario\n"
|
| 127 |
]
|
| 128 |
},
|
| 129 |
{
|