haohsiang commited on
Commit
2c42859
·
verified ·
1 Parent(s): 07beecc

update prompt of chatbot and text-to-image function

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -56,7 +56,7 @@ 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]})
@@ -119,7 +119,7 @@ def generate_images(history, conversation_times, last_genimg_times, generated_im
119
  user_story = " ".join([h[0] for h in history])
120
  prompt = translate_to_english(user_story)
121
 
122
- neg_prompt = "dark, realistic, words, sentence, 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]
@@ -127,7 +127,7 @@ def generate_images(history, conversation_times, last_genimg_times, generated_im
127
  last_genimg_times = conversation_times
128
 
129
  for i in range(4):
130
- img = pipe("style of Milton Glaser, modern digital impressionism, hard to understood, abstract, "+prompt,
131
  negative_prompt=neg_prompt,
132
  height=720, width=512,
133
  generator=generator[i],
@@ -315,7 +315,6 @@ with gr.Blocks(theme=theme, css=css, title='療癒對話機器人') as demo:
315
  image_chat_input = gr.Textbox(label="這張圖像讓你產生了什麼樣的聯想?")
316
  image_chat_button = gr.Button("與聊天機器人分享", variant="primary")
317
 
318
- login.activate()
319
  # chatbot events handle
320
  submit.click(handle_chat, [msg, chatbot, conversation_times, valence_scores, arousal_scores, meditation_flag], [chatbot, msg, submit, jump_to_med, meditation_buttons, conversation_times, valence_scores, arousal_scores, meditation_flag])
321
  msg.submit(handle_chat, [msg, chatbot, conversation_times, valence_scores, arousal_scores, meditation_flag], [chatbot, msg, submit, jump_to_med, meditation_buttons, conversation_times, valence_scores, arousal_scores, meditation_flag])
 
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]})
 
119
  user_story = " ".join([h[0] for h in history])
120
  prompt = translate_to_english(user_story)
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]
 
127
  last_genimg_times = conversation_times
128
 
129
  for i in range(4):
130
+ img = pipe("style of Milton Glaser, modern digital impressionism, abstract, "+prompt,
131
  negative_prompt=neg_prompt,
132
  height=720, width=512,
133
  generator=generator[i],
 
315
  image_chat_input = gr.Textbox(label="這張圖像讓你產生了什麼樣的聯想?")
316
  image_chat_button = gr.Button("與聊天機器人分享", variant="primary")
317
 
 
318
  # chatbot events handle
319
  submit.click(handle_chat, [msg, chatbot, conversation_times, valence_scores, arousal_scores, meditation_flag], [chatbot, msg, submit, jump_to_med, meditation_buttons, conversation_times, valence_scores, arousal_scores, meditation_flag])
320
  msg.submit(handle_chat, [msg, chatbot, conversation_times, valence_scores, arousal_scores, meditation_flag], [chatbot, msg, submit, jump_to_med, meditation_buttons, conversation_times, valence_scores, arousal_scores, meditation_flag])