Spaces:
Running
Running
Update gemini.py
Browse files
gemini.py
CHANGED
@@ -5,6 +5,14 @@ from PIL import Image
|
|
5 |
import gradio as gr
|
6 |
from google import genai
|
7 |
from google.genai import types
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# 設定 Gemini API 金鑰
|
10 |
GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")
|
@@ -39,6 +47,7 @@ def generate_image(prompt):
|
|
39 |
|
40 |
# 建立圖片的公開 URL
|
41 |
image_url = f"https://{SPACE_HOST}/static/images/{filename}"
|
|
|
42 |
return image_url
|
43 |
|
44 |
return "未能生成圖片,請嘗試其他提示詞。"
|
|
|
5 |
import gradio as gr
|
6 |
from google import genai
|
7 |
from google.genai import types
|
8 |
+
import logging
|
9 |
+
|
10 |
+
# 設定logging
|
11 |
+
logging.basicConfig(
|
12 |
+
filename='app.log',
|
13 |
+
level=logging.INFO,
|
14 |
+
format='%(asctime)s - %(levelname)s - %(message)s'
|
15 |
+
)
|
16 |
|
17 |
# 設定 Gemini API 金鑰
|
18 |
GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")
|
|
|
47 |
|
48 |
# 建立圖片的公開 URL
|
49 |
image_url = f"https://{SPACE_HOST}/static/images/{filename}"
|
50 |
+
logging.info(f"生成的圖片 URL: {image_url}")
|
51 |
return image_url
|
52 |
|
53 |
return "未能生成圖片,請嘗試其他提示詞。"
|