added try-catch, removed push message, renamed file
This commit is contained in:
parent
b682911383
commit
1147665331
|
|
@ -102,18 +102,32 @@ def message_text(event):
|
|||
|
||||
# unique_docs = retriever_from_llm.get_relevant_documents(query=event.message.text)
|
||||
with ApiClient(configuration) as api_client:
|
||||
try:
|
||||
answer = str(user_sessions[event.source.user_id]({"question": event.message.text})['answer'])
|
||||
except:
|
||||
answer = "message failed to process, please try again"
|
||||
|
||||
line_bot_api = MessagingApi(api_client)
|
||||
line_bot_api.reply_message_with_http_info(
|
||||
ReplyMessageRequest(
|
||||
reply_token=event.reply_token,
|
||||
messages=[TextMessage(text="Message received.\nProcessing... please wait")]
|
||||
messages=[TextMessage(text=answer)]
|
||||
))
|
||||
|
||||
with ApiClient(configuration) as api_client:
|
||||
line_bot_api = MessagingApi(api_client)
|
||||
with str(user_sessions[event.source.user_id]({"question": event.message.text})['answer']) as answer:
|
||||
line_bot_api.push_message_with_http_info(
|
||||
PushMessageRequest(to=event.source.user_id,messages=[TextMessage(text=answer)]))
|
||||
|
||||
# with ApiClient(configuration) as api_client:
|
||||
# line_bot_api = MessagingApi(api_client)
|
||||
# line_bot_api.reply_message_with_http_info(
|
||||
# ReplyMessageRequest(
|
||||
# reply_token=event.reply_token,
|
||||
# messages=[TextMessage(text="Message received.\nProcessing... please wait")]
|
||||
# ))
|
||||
|
||||
|
||||
# with ApiClient(configuration) as api_client:
|
||||
# line_bot_api = MessagingApi(api_client)
|
||||
#
|
||||
# line_bot_api.push_message_with_http_info(
|
||||
# PushMessageRequest(to=event.source.user_id,messages=[TextMessage(text=answer)]))
|
||||
|
||||
# main is here
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Reference in New Issue