3v324v23 commited on
Commit
0874690
·
1 Parent(s): a407d90

更新內容

Browse files
Files changed (1) hide show
  1. gemini.py +2 -11
gemini.py CHANGED
@@ -28,15 +28,7 @@ from PIL import Image
28
  GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
29
  google_client = genai.Client(api_key=GOOGLE_API_KEY)
30
  text_system_prompt = "你是一個中文的AI助手,請用繁體中文回答"
31
- chat = google_client.chats.create(
32
- model="gemini-2.0-flash",
33
- messages=[
34
- {
35
- "role": "system",
36
- "parts": [text_system_prompt]
37
- }
38
- ]
39
- )
40
 
41
  # === 初始設定 ===
42
  static_tmp_path = tempfile.gettempdir()
@@ -59,10 +51,9 @@ handler = WebhookHandler(channel_secret)
59
 
60
  # === AI Query 包裝 ===
61
  def query(payload):
62
- response = chat.send_message(payload)
63
  return response.text
64
 
65
-
66
  # === 靜態圖檔路由 ===
67
  @app.route("/images/<filename>")
68
  def serve_image(filename):
 
28
  GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
29
  google_client = genai.Client(api_key=GOOGLE_API_KEY)
30
  text_system_prompt = "你是一個中文的AI助手,請用繁體中文回答"
31
+ chat = google_client.chats.create(model="gemini-2.0-flash")
 
 
 
 
 
 
 
 
32
 
33
  # === 初始設定 ===
34
  static_tmp_path = tempfile.gettempdir()
 
51
 
52
  # === AI Query 包裝 ===
53
  def query(payload):
54
+ response = chat.send_message(f"{text_system_prompt}:{payload}")
55
  return response.text
56
 
 
57
  # === 靜態圖檔路由 ===
58
  @app.route("/images/<filename>")
59
  def serve_image(filename):