Kappa7077 commited on
Commit
3573828
·
1 Parent(s): 6f25afa

optimize dialogue examples

Browse files
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:c42aa1262ff5c5db2e2a67dd5b327cbdc471dc5fe5bb8d770080914734475f00
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:936298a7ceb070265b59366a699d1d1ec4a0522b327d696276f27e38fa29dd1d
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": "【外送員保險方案 - 對話示例根據以下思考如何回答使用者的問題】\n\n(外送員 = U / 機器人 = R)\n\n--------------------------------------\n# 當外送員未指明平台\n\nU: 嗨,我是外送員,想了解一下有沒有合適的保險?\n\nR: 您好,請問您目前是哪個平台的外送員呢?foodpanda 還是 ubereats?兩家平台的保障和可投保方案不太一樣。\n\nU: 我是 ubereats。\n\nR: 好的,若您在 ubereats目前有簡易方案(513/年)進階方案(861/年,含 500 萬超額)。並且平台本身就提供意外身故 300 萬、30 萬傷害醫療日額 1,000。\n\nU: 如果我想要加強對第三人的賠償呢?\n\nR: 建議您選進階方案(861/年)其中 348是給 500 萬超額保險若只想最基本,就選簡易(513/年)。\n\n--------------------------------------\n# foodpanda 範例\n\nU: 哈囉,我是 foodpanda 外送員,今年25歲,保障,聽說有安心方案?\n\nR: 是的,foodpanda 有種:\n1) 基礎(4,409/年):含意外實支實付(300萬身故 / 3萬醫療)\n2) 超值(4,757/年):基礎 + 超額保險(500)\n3) 安心(3,225 + Y)\n - 可加『駕駛人傷害(200萬/20萬)』與『醫療實支實付(Y)』\n - 超額保險(500萬)費用已含在 3,225 裡\n - 不含 300意外實支、3 萬醫療。若要加強自己意外保障則需自訂\n\nU: 如果我想對自己的醫療最完整的保障?\n\nR: 安心方案可以彈性加購醫療實支(看齡、性別),也有駕駛人傷害。若特別想 300 萬身故 / 3 萬實支則建議考慮基礎或超值。超值也有 500 萬超額賠償。\n\n--------------------------------------\n# ubereats 範例\n\nU: 我是 ubereats 外送員只想最基本行嗎?\n\nR: 簡易方案(513/年)即可強制險由負擔,第三責任險平台出。平台另有意外身故 300 萬、醫療實支 30 萬、 1,000。\n\nU: 若要增高對別人的賠償額度?\n\nR: 進階方案(861/= 513 + 348)含 500 萬超額保險。\n\n--------------------------------------\n# 結論\n1. 先問清楚平台(foodpanda ubereats)。\n2. 確認年齡、性別、預算、想要保障重點。\n3. foodpanda:\n - 基礎(4,409):已含意外實支(300萬身故)\n - 超值(4,757):再加 500萬超額\n - 安心(3,225 + Y):可加駕駛人傷害醫療實支,含超額保險\n4. ubereats:\n - 簡易(513) / 進階(861)\n - 平台附 300萬身故、30萬醫療、1,000日額\n\n以上為典型話示例。"
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": 2,
61
  "metadata": {},
62
  "outputs": [
63
  {
64
  "name": "stderr",
65
  "output_type": "stream",
66
  "text": [
67
- "You're using a XLMRobertaTokenizerFast tokenizer. Please note that with a fast tokenizer, using the `__call__` method is faster than using a method to encode the text followed by a call to the `pad` method to get a padded encoding.\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  {