Update main.py
Browse files
main.py
CHANGED
|
@@ -6,12 +6,6 @@ from linebot import LineBotApi, WebhookHandler
|
|
| 6 |
from linebot.exceptions import InvalidSignatureError
|
| 7 |
from linebot.models import MessageEvent, TextMessage, TextSendMessage, ImageSendMessage, AudioMessage
|
| 8 |
|
| 9 |
-
# Retrieve the PDF
|
| 10 |
-
files = glob.glob('docs/*.pdf')
|
| 11 |
-
print(files)
|
| 12 |
-
files_content = [client.files.upload(file=pathlib.Path(file_path)) for file_path in files]
|
| 13 |
-
print(files_content)
|
| 14 |
-
|
| 15 |
# 設定 Google AI API 金鑰
|
| 16 |
client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 17 |
|
|
@@ -19,6 +13,12 @@ client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"))
|
|
| 19 |
generation_config = genai.types.GenerateContentConfig(max_output_tokens=3000, temperature=0.1, top_p=0.2,
|
| 20 |
system_instruction="您是一位問答助手。請僅限使用以上提供的內容來回答問題。如果您不知道答案,請說您不知道,不要捏造答案。")
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# 設定 Line Bot 的 API 金鑰和秘密金鑰
|
| 23 |
line_bot_api = LineBotApi(os.environ["CHANNEL_ACCESS_TOKEN"])
|
| 24 |
line_handler = WebhookHandler(os.environ["CHANNEL_SECRET"])
|
|
|
|
| 6 |
from linebot.exceptions import InvalidSignatureError
|
| 7 |
from linebot.models import MessageEvent, TextMessage, TextSendMessage, ImageSendMessage, AudioMessage
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# 設定 Google AI API 金鑰
|
| 10 |
client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 11 |
|
|
|
|
| 13 |
generation_config = genai.types.GenerateContentConfig(max_output_tokens=3000, temperature=0.1, top_p=0.2,
|
| 14 |
system_instruction="您是一位問答助手。請僅限使用以上提供的內容來回答問題。如果您不知道答案,請說您不知道,不要捏造答案。")
|
| 15 |
|
| 16 |
+
# Retrieve the PDF
|
| 17 |
+
files = glob.glob('docs/*.pdf')
|
| 18 |
+
print(files)
|
| 19 |
+
files_content = [client.files.upload(file=pathlib.Path(file_path)) for file_path 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"])
|