ray commited on
Commit
89acc00
1 Parent(s): 4969145

use gpt-4 and some improvement

Browse files
Files changed (3) hide show
  1. README.md +20 -0
  2. app.py +16 -3
  3. chat_template.py +1 -0
README.md CHANGED
@@ -11,3 +11,23 @@ license: apache-2.0
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
14
+
15
+
16
+ By far the best answer:
17
+ 什麼是安心三寶?
18
+
19
+
20
+ 安心三寶是一組法律文件,包括平安紙(遺囑)、持久授權書和預設醫療指示。這三份文件的目的是為了讓人們能夠提前規劃自己晚年的生活,並在無法親自做出決定時,確保自己的意願能夠被尊重和執行。
21
+
22
+ 平安紙(遺囑):這是一份法律文件,允許個人指定他們去世後如何分配自己的資產,以及誰將成為未成年子女的監護人。
23
+
24
+ 持久授權書:這是一份授權文件,允許個人指定一名或多名代理人,在自己因疾病或意外而失去行為能力時,代表自己做出財務和法律決策。
25
+
26
+ 預設醫療指示:這是一份指示文件,允許個人預先決定在特定醫療狀況下他們希望或不希望接受的醫療處置,這樣醫生和家人就可以依照這些指示來進行醫療決策。
27
+
28
+ 製訂這些文件後,可以使個人在晚年或在無法自己做決定的情況下,仍然能夠控制自己的財產和醫療決策,從而提供一定程度的安心和保障。由於這些文件的重要性,保管它們的安全和有效性是非常重要的。安心三寶網上平台提供了一種方便的方式來訂立這些文件,並且還提供預約律師和醫生見證持久授權書的服務。
29
+
30
+
31
+ 參考:
32
+
33
+ 安心三寶網誌.docx
app.py CHANGED
@@ -29,7 +29,7 @@ openai.api_key = os.getenv("OPENAI_API_KEY")
29
 
30
  IS_LOAD_FROM_VECTOR_STORE = True
31
  VDB_COLLECTION_NAME = "demo-v0"
32
- MODEL_NAME = ChatbotVersion.CHATGPT_35.value
33
 
34
 
35
  CHUNK_SIZE = 1024
@@ -87,7 +87,11 @@ class AwesumCareToolChatbot(Chatbot):
87
  SYSTEM_PROMPT = ""
88
  CHAT_EXAMPLES = [
89
  "什麼是安心三寶?",
90
- "點樣立平安紙?"
 
 
 
 
91
  ]
92
 
93
  def _setup_observer(self):
@@ -188,6 +192,15 @@ with gr.Blocks() as demo:
188
 
189
  gr.Markdown("# Awesum Care demo")
190
 
 
 
 
 
 
 
 
 
 
191
  # with gr.Row():
192
  # model_selector = gr.Radio(
193
  # value=ChatbotVersion.CHATGPT_35.value,
@@ -195,7 +208,7 @@ with gr.Blocks() as demo:
195
  # label="Select Chatbot Model (To be implemented)"
196
  # )
197
 
198
- with gr.Tab("With context aware"):
199
  context_interface = gr.ChatInterface(
200
  awesum_chatbot_context.stream_chat,
201
  examples=awesum_chatbot.CHAT_EXAMPLES,
 
29
 
30
  IS_LOAD_FROM_VECTOR_STORE = True
31
  VDB_COLLECTION_NAME = "demo-v0"
32
+ MODEL_NAME = ChatbotVersion.CHATGPT_4.value
33
 
34
 
35
  CHUNK_SIZE = 1024
 
87
  SYSTEM_PROMPT = ""
88
  CHAT_EXAMPLES = [
89
  "什麼是安心三寶?",
90
+ "點樣立平安紙?",
91
+ "甚麼是⾒證?",
92
+ "訂立每份⽂件需要多少錢以及付款⽅法?",
93
+ "通過安⼼三寶製作的⽂件有法律效⼒嗎?",
94
+
95
  ]
96
 
97
  def _setup_observer(self):
 
192
 
193
  gr.Markdown("# Awesum Care demo")
194
 
195
+ gr.Markdown("instructions:\n"
196
+ "\nUsing model gpt-4-preview-1106, the most advanced model now in the market.\n"
197
+ "\n(Note that it can be much slower than gpt-3.5, openai's api can be unstable sometimes.)\n"
198
+ "\nThree Tabs:\n"
199
+ "1. Relevant context: retreiving relevant documents and send to ChatGPT.\n"
200
+ "2. Give tools to chatgpt to retrieve context: the most advanced, slowest (>30s to use the tools, before answering).\n"
201
+ "3. Vanilla ChatGPT: self-explanatory.\n"
202
+ )
203
+
204
  # with gr.Row():
205
  # model_selector = gr.Radio(
206
  # value=ChatbotVersion.CHATGPT_35.value,
 
208
  # label="Select Chatbot Model (To be implemented)"
209
  # )
210
 
211
+ with gr.Tab("With relevant context sent to system prompt"):
212
  context_interface = gr.ChatInterface(
213
  awesum_chatbot_context.stream_chat,
214
  examples=awesum_chatbot.CHAT_EXAMPLES,
chat_template.py CHANGED
@@ -8,6 +8,7 @@ TEXT_QA_SYSTEM_PROMPT = ChatMessage(
8
  "detailed information on legal and medical documents like '平安紙', '持久授權書', and '預設醫療指示'.\n"
9
  "Always answer queries using the context information provided, focusing on delivering "
10
  "accurate, comprehensive, and user-friendly responses.\n"
 
11
  ),
12
  role=MessageRole.SYSTEM,
13
  )
 
8
  "detailed information on legal and medical documents like '平安紙', '持久授權書', and '預設醫療指示'.\n"
9
  "Always answer queries using the context information provided, focusing on delivering "
10
  "accurate, comprehensive, and user-friendly responses.\n"
11
+ "當用戶用繁體中文時,請盡量使用繁體中文作答。"
12
  ),
13
  role=MessageRole.SYSTEM,
14
  )