Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -100,7 +100,7 @@ def generate_and_upload_image(prompt: str) -> str:
|
|
| 100 |
prompt: 用於生成圖片的文字提示。
|
| 101 |
|
| 102 |
Returns:
|
| 103 |
-
|
| 104 |
"""
|
| 105 |
try:
|
| 106 |
response = genai_client.models.generate_content(
|
|
@@ -172,7 +172,9 @@ llm = ChatGoogleGenerativeAI(google_api_key=google_api, model="gemini-2.5-flash"
|
|
| 172 |
|
| 173 |
# 建立提示模板
|
| 174 |
prompt_template = ChatPromptTemplate([
|
| 175 |
-
("system", "
|
|
|
|
|
|
|
| 176 |
("user", "{input}"),
|
| 177 |
("placeholder", "{agent_scratchpad}"),
|
| 178 |
])
|
|
|
|
| 100 |
prompt: 用於生成圖片的文字提示。
|
| 101 |
|
| 102 |
Returns:
|
| 103 |
+
回傳生成圖片的 URL。
|
| 104 |
"""
|
| 105 |
try:
|
| 106 |
response = genai_client.models.generate_content(
|
|
|
|
| 172 |
|
| 173 |
# 建立提示模板
|
| 174 |
prompt_template = ChatPromptTemplate([
|
| 175 |
+
("system", "你是一個強大的助理,可以根據用戶的請求使用提供的工具。當用戶要求你生成圖片時,你必須使用 generate_and_upload_image 工具。
|
| 176 |
+
在工具執行成功後,你將會獲得一個圖片的 URL。你的任務是將這個 URL 作為最終回應的一部分,直接、清楚地回傳給用戶。
|
| 177 |
+
切勿在回傳 URL 時添加任何額外的解釋性文字、符號或句子,以確保圖片能夠被正確解析和顯示。如果工具執行失敗,你則需要向用戶回報錯誤。"),
|
| 178 |
("user", "{input}"),
|
| 179 |
("placeholder", "{agent_scratchpad}"),
|
| 180 |
])
|