Update main.py
Browse files
main.py
CHANGED
|
@@ -16,8 +16,9 @@ generation_config = genai.types.GenerateContentConfig(max_output_tokens=3000, te
|
|
| 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 |
# 設定 Line Bot 的 API 金鑰和秘密金鑰
|
| 22 |
line_bot_api = LineBotApi(os.environ["CHANNEL_ACCESS_TOKEN"])
|
| 23 |
line_handler = WebhookHandler(os.environ["CHANNEL_SECRET"])
|
|
@@ -96,7 +97,7 @@ def handle_message(event):
|
|
| 96 |
# 檢查生成結果是否為空
|
| 97 |
if (completion != None):
|
| 98 |
# 取得生成結果
|
| 99 |
-
out = completion
|
| 100 |
else:
|
| 101 |
# 回覆 "Gemini沒答案!請換個說法!"
|
| 102 |
out = "Gemini沒答案!請換個說法!"
|
|
|
|
| 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"])
|
| 24 |
line_handler = WebhookHandler(os.environ["CHANNEL_SECRET"])
|
|
|
|
| 97 |
# 檢查生成結果是否為空
|
| 98 |
if (completion != None):
|
| 99 |
# 取得生成結果
|
| 100 |
+
out = completion.text
|
| 101 |
else:
|
| 102 |
# 回覆 "Gemini沒答案!請換個說法!"
|
| 103 |
out = "Gemini沒答案!請換個說法!"
|