tsengiii commited on
Commit
18ab03c
·
verified ·
1 Parent(s): 6d7eca7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -1,4 +1,3 @@
1
- #app.py
2
  import time
3
  import gradio as gr
4
  import google.generativeai as genai
@@ -34,8 +33,14 @@ def response(message, history):
34
  # 將 Gradio 的歷史紀錄轉換為 Gemini 的格式
35
  chat.history = transform_history(history)
36
 
 
 
 
 
 
 
37
  # 發送訊息到 Gemini API
38
- response = chat.send_message(message)
39
  response.resolve()
40
 
41
  # 逐字回傳生成的文字,實現打字機效果
@@ -45,5 +50,6 @@ def response(message, history):
45
 
46
  # 建立 Gradio 聊天界面
47
  gr.ChatInterface(response,
48
- title='Gemini Chat',
49
- textbox=gr.Textbox(placeholder="Question to Gemini")).launch(share=True)
 
 
 
1
  import time
2
  import gradio as gr
3
  import google.generativeai as genai
 
33
  # 將 Gradio 的歷史紀錄轉換為 Gemini 的格式
34
  chat.history = transform_history(history)
35
 
36
+ # 自訂 Prompt:限縮為與求職面試相關的回答
37
+ prompt = "你是一位招募小助理,名為小招。負責協助求職者成功獲得心儀的Offer,請只回答與求職面試相關的問題。"
38
+
39
+ # 合併Prompt與使用者訊息
40
+ final_message = prompt + "\n" + message
41
+
42
  # 發送訊息到 Gemini API
43
+ response = chat.send_message(final_message)
44
  response.resolve()
45
 
46
  # 逐字回傳生成的文字,實現打字機效果
 
50
 
51
  # 建立 Gradio 聊天界面
52
  gr.ChatInterface(response,
53
+ title='Gemini Chat - 招募助手小招',
54
+ textbox=gr.Textbox(placeholder="請輸入與求職面試相關的問題")).launch(share=True)
55
+