haohsiang commited on
Commit
1a4e514
·
1 Parent(s): 3ea699e

upgrade gradio to 4.44.1 and update prompt script

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +8 -4
README.md CHANGED
@@ -1,7 +1,7 @@
1
  ---
2
  title: healing-bot-01
3
  sdk: gradio
4
- sdk_version: 4.36.1
5
  emoji: 👂🏻
6
  colorFrom: blue
7
  colorTo: yellow
 
1
  ---
2
  title: healing-bot-01
3
  sdk: gradio
4
+ sdk_version: 4.44.1
5
  emoji: 👂🏻
6
  colorFrom: blue
7
  colorTo: yellow
app.py CHANGED
@@ -56,7 +56,9 @@ def analyze_sentiment_corpus(text, conversation_times, valence_scores, arousal_s
56
  return avg_valence, avg_arousal, conversation_times, valence_scores, arousal_scores
57
 
58
  def call_gpt(input_text, history):
59
- messages = [{"role":"system", "content":"對話請以繁體中文進行:你是一位熟悉現象學的諮商實習生,擅長引導使用者描述他當下的所知覺到的事物。回答問題的時候必須有同理心,請同理使用者說的內容,再繼續回答,且不要超過20個字。當你收到類似介紹自己的提問時,說自己擅長陪人聊天,引導大家療癒自己。"}]
 
 
60
 
61
  for h in history:
62
  messages.append({"role": "user", "content": h[0]})
@@ -121,7 +123,7 @@ def generate_images(history, conversation_times, last_genimg_times, generated_im
121
 
122
  neg_prompt = "man, dark, realistic, words, text, extra, nude, duplicate, ugly"
123
 
124
- seeds = np.random.randint(0, 100000, 4)
125
  generator = [torch.Generator().manual_seed(int(i)) for i in seeds]
126
  images = []
127
  last_genimg_times = conversation_times
@@ -150,7 +152,9 @@ def chat_about_image(input_text, history, selected_image):
150
  img_str = base64.b64encode(buffer).decode()
151
 
152
  messages = [
153
- {"role": "system", "content": "對話請以繁體中文進行:你是一位熟悉現象學的諮商實習生,請根據使用者對他所選出的圖像描述進行引導,指出這張圖像與先前對話的關聯,幫助使用者探索他們的分享與該圖像間的連結,並繼續對話"},
 
 
154
  {"role": "user", "content": [
155
  {"type": "text", "text": f"看到這張圖像,讓我想到 {input_text}"},
156
  {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img_str}"}}
@@ -298,7 +302,7 @@ with gr.Blocks(theme=theme, css=css, title='療癒對話機器人') as demo:
298
 
299
  with gr.Row() as main_interface:
300
  with gr.Column() as chatbot_interface:
301
- chatbot = gr.Chatbot(label="聊天機器人", show_share_button=False, bubble_full_width=False, layout='bubble', scale=6)
302
  msg = gr.Textbox(show_label=False, placeholder="今天想要跟我分享什麼呢?", autofocus=True, scale=2)
303
  with gr.Row():
304
  submit = gr.Button("送出", variant="primary", scale=2)
 
56
  return avg_valence, avg_arousal, conversation_times, valence_scores, arousal_scores
57
 
58
  def call_gpt(input_text, history):
59
+ messages = [{"role":"system", "content":
60
+ '''對話請以繁體中文進行:你是一位熟悉現象學心理學取向的諮商實習生,擅長引導使用者描述他事情中的當下知覺到的事物。
61
+ 回答問題的時候必須有同理心,請同理使用者說的內容,再繼續回答與討論或給予建。回答不要超過30個字。當你收到類似介紹自己的提問時,說自己擅長陪人聊天,引導大家療癒自己。'''}]
62
 
63
  for h in history:
64
  messages.append({"role": "user", "content": h[0]})
 
123
 
124
  neg_prompt = "man, dark, realistic, words, text, extra, nude, duplicate, ugly"
125
 
126
+ seeds = np.random.randint(0, 1000000, 4)
127
  generator = [torch.Generator().manual_seed(int(i)) for i in seeds]
128
  images = []
129
  last_genimg_times = conversation_times
 
152
  img_str = base64.b64encode(buffer).decode()
153
 
154
  messages = [
155
+ {"role": "system", "content":
156
+ '''對話請以繁體中文進行:你是一位熟悉現象學心理學的諮商實習生,請根據使用者對他所選出的圖像描述進行引導,
157
+ 指出這張圖像與先前對話的關聯,幫助使用者探索他們的分享與該圖像間的連結,並繼續對話'''},
158
  {"role": "user", "content": [
159
  {"type": "text", "text": f"看到這張圖像,讓我想到 {input_text}"},
160
  {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img_str}"}}
 
302
 
303
  with gr.Row() as main_interface:
304
  with gr.Column() as chatbot_interface:
305
+ chatbot = gr.Chatbot(label="聊天機器人", show_share_button=False, bubble_full_width=False, show_copy_all_button=True, layout='bubble', scale=6)
306
  msg = gr.Textbox(show_label=False, placeholder="今天想要跟我分享什麼呢?", autofocus=True, scale=2)
307
  with gr.Row():
308
  submit = gr.Button("送出", variant="primary", scale=2)