Evaaaaa06 commited on
Commit
954f7c4
·
verified ·
1 Parent(s): d9a7b29

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -3
main.py CHANGED
@@ -19,7 +19,8 @@ from Uploading_images import get_image_url, store_user_message, analyze_with_gem
19
  #==========================
20
 
21
  # 設定 Google AI API 金鑰
22
- genai_gen.configure(api_key=os.environ["GOOGLE_API_KEY"])
 
23
 
24
  # 設定生成文字的參數
25
  generation_config = genai_gen.types.GenerationConfig(max_output_tokens=1000, temperature=0.2, top_p=0.5, top_k=16) #2048
@@ -37,7 +38,6 @@ client_secret = os.environ.get("IMGUR_CLIENT_SECRET")
37
  access_token = os.environ.get("IMGUR_ACCESS_TOKEN")
38
  refresh_token = os.environ.get("IMGUR_REFRESH_TOKEN")
39
 
40
-
41
  # 設定是否正在與使用者交談
42
  working_status = os.getenv("DEFALUT_TALKING", default = "true").lower() == "true"
43
 
@@ -99,7 +99,7 @@ def handle_image_message(event):
99
 
100
  # 先立即回覆避免token過期
101
  line_bot_api.reply_message(event.reply_token, TextSendMessage(text="圖片生成中~ 請稍候.....✨"))
102
-
103
  # 生成圖片
104
  image_binary = image_generator.generate_image_with_gemini(prompt)
105
 
 
19
  #==========================
20
 
21
  # 設定 Google AI API 金鑰
22
+ google_api = os.environ["GOOGLE_API_KEY"]
23
+ genai_gen.configure(api_key=google_api)
24
 
25
  # 設定生成文字的參數
26
  generation_config = genai_gen.types.GenerationConfig(max_output_tokens=1000, temperature=0.2, top_p=0.5, top_k=16) #2048
 
38
  access_token = os.environ.get("IMGUR_ACCESS_TOKEN")
39
  refresh_token = os.environ.get("IMGUR_REFRESH_TOKEN")
40
 
 
41
  # 設定是否正在與使用者交談
42
  working_status = os.getenv("DEFALUT_TALKING", default = "true").lower() == "true"
43
 
 
99
 
100
  # 先立即回覆避免token過期
101
  line_bot_api.reply_message(event.reply_token, TextSendMessage(text="圖片生成中~ 請稍候.....✨"))
102
+ image_generator = ImageGenerator( google_api, client_id, client_secret, access_token, refresh_token)
103
  # 生成圖片
104
  image_binary = image_generator.generate_image_with_gemini(prompt)
105