Update main.py
Browse files
main.py
CHANGED
|
@@ -15,9 +15,7 @@ generation_config = genai.types.GenerateContentConfig(max_output_tokens=3000, te
|
|
| 15 |
|
| 16 |
# Retrieve the PDF
|
| 17 |
files = glob.glob('docs/*.pdf')
|
| 18 |
-
print(files)
|
| 19 |
files_content = [genai.types.Part.from_bytes(data=(pathlib.Path(filepath)).read_bytes(), mime_type='application/pdf') for filepath in files]
|
| 20 |
-
print(files_content)
|
| 21 |
|
| 22 |
# 設定 Line Bot 的 API 金鑰和秘密金鑰
|
| 23 |
line_bot_api = LineBotApi(os.environ["CHANNEL_ACCESS_TOKEN"])
|
|
@@ -91,7 +89,7 @@ def handle_message(event):
|
|
| 91 |
# 取得使用者輸入的文字
|
| 92 |
prompt = event.message.text
|
| 93 |
# Combine the PDF contents and the new prompt into a single list for the 'contents' argument
|
| 94 |
-
combined_contents = [
|
| 95 |
# 使用 client.models.generate_content
|
| 96 |
completion = client.models.generate_content(
|
| 97 |
model="gemini-2.5-flash",
|
|
|
|
| 15 |
|
| 16 |
# Retrieve the PDF
|
| 17 |
files = glob.glob('docs/*.pdf')
|
|
|
|
| 18 |
files_content = [genai.types.Part.from_bytes(data=(pathlib.Path(filepath)).read_bytes(), mime_type='application/pdf') for filepath in files]
|
|
|
|
| 19 |
|
| 20 |
# 設定 Line Bot 的 API 金鑰和秘密金鑰
|
| 21 |
line_bot_api = LineBotApi(os.environ["CHANNEL_ACCESS_TOKEN"])
|
|
|
|
| 89 |
# 取得使用者輸入的文字
|
| 90 |
prompt = event.message.text
|
| 91 |
# Combine the PDF contents and the new prompt into a single list for the 'contents' argument
|
| 92 |
+
combined_contents = [prompt] + files_content
|
| 93 |
# 使用 client.models.generate_content
|
| 94 |
completion = client.models.generate_content(
|
| 95 |
model="gemini-2.5-flash",
|