Evaaaaa06 commited on
Commit
8f4bb7f
·
verified ·
1 Parent(s): 8e7c0cf

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -2
main.py CHANGED
@@ -96,7 +96,8 @@ def analyze_with_gemini(image_path, user_text):
96
  raise FileNotFoundError(f"圖片路徑無效:{image_path}")
97
 
98
  organ = PIL.Image.open(image_path)
99
- response = model.start_chat([user_text, organ])
 
100
 
101
  # 提取回應內容
102
  return response.parts[0].text
@@ -166,7 +167,7 @@ def handle_image_message(event):
166
  store_user_message(user_id, "text", prompt)
167
  # 使用 Gemini 模型生成文字
168
  chat = model.start_chat(history = [])
169
- completion = chat.send_message(prompt, generation_config=generation_config)
170
  # 檢查生成結果是否為空
171
  if (completion.parts[0].text != None):
172
  # 取得生成結果
 
96
  raise FileNotFoundError(f"圖片路徑無效:{image_path}")
97
 
98
  organ = PIL.Image.open(image_path)
99
+ chat = model.start_chat()
100
+ response = chat.send_message([user_text, organ])
101
 
102
  # 提取回應內容
103
  return response.parts[0].text
 
167
  store_user_message(user_id, "text", prompt)
168
  # 使用 Gemini 模型生成文字
169
  chat = model.start_chat(history = [])
170
+ completion = chat.send_message(chat.history+prompt, generation_config=generation_config)
171
  # 檢查生成結果是否為空
172
  if (completion.parts[0].text != None):
173
  # 取得生成結果