Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TheExplainthis committed Mar 23, 2023
1 parent b8861a4 commit 70ce1a5
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,13 @@ def handle_text_message(event):
else:
chunks = website.get_content_from_url(url)
if len(chunks) == 0:
msg = TextSendMessage(text='無法撈取此網站文字')
else:
website_reader = WebsiteReader(user_model, os.getenv('OPENAI_MODEL_ENGINE'))
is_successful, response, error_message = website_reader.summarize(chunks)
if not is_successful:
raise Exception(error_message)
role, response = get_role_and_content(response)
msg = TextSendMessage(text=response)
raise ValueError('無法撈取此網站文字')
website_reader = WebsiteReader(user_model, os.getenv('OPENAI_MODEL_ENGINE'))
is_successful, response, error_message = website_reader.summarize(chunks)
if not is_successful:
raise Exception(error_message)
role, response = get_role_and_content(response)
msg = TextSendMessage(text=response)
else:
is_successful, response, error_message = user_model.chat_completions(memory.get(user_id), os.getenv('OPENAI_MODEL_ENGINE'))
if not is_successful:
Expand Down

0 comments on commit 70ce1a5

Please sign in to comment.