Update main.py
Browse files
main.py
CHANGED
|
@@ -90,10 +90,14 @@ def handle_message(event):
|
|
| 90 |
#try:
|
| 91 |
# 取得使用者輸入的文字
|
| 92 |
prompt = event.message.text
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
# 使用 client.models.generate_content
|
| 94 |
completion = client.models.generate_content(
|
| 95 |
model="gemini-2.5-flash",
|
| 96 |
-
contents=
|
| 97 |
# 檢查生成結果是否為空
|
| 98 |
if (completion != None):
|
| 99 |
# 取得生成結果
|
|
|
|
| 90 |
#try:
|
| 91 |
# 取得使用者輸入的文字
|
| 92 |
prompt = event.message.text
|
| 93 |
+
# Convert the prompt to a Text Part
|
| 94 |
+
prompt_part = genai.types.Part.from_text(prompt)
|
| 95 |
+
# Combine the PDF contents and the new prompt into a single list for the 'contents' argument
|
| 96 |
+
combined_contents = files_content + [prompt_part]
|
| 97 |
# 使用 client.models.generate_content
|
| 98 |
completion = client.models.generate_content(
|
| 99 |
model="gemini-2.5-flash",
|
| 100 |
+
contents=combined_contents)
|
| 101 |
# 檢查生成結果是否為空
|
| 102 |
if (completion != None):
|
| 103 |
# 取得生成結果
|