w831152001 commited on
Commit
78cdfd0
·
1 Parent(s): 7731f27

try to fix

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. main.py +10 -7
Dockerfile CHANGED
@@ -8,4 +8,4 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
 
9
  COPY . .
10
 
11
- CMD ["gunicorn","-b", "0.0.0.0:7860", "main:app"]
 
8
 
9
  COPY . .
10
 
11
+ CMD ["gunicorn","-b", "0.0.0.0:7860", "main:app"]
main.py CHANGED
@@ -44,11 +44,8 @@ app.logger.setLevel(logging.INFO)
44
  channel_secret = os.environ.get('YOUR_CHANNEL_SECRET')
45
  channel_access_token = os.environ.get('YOUR_CHANNEL_ACCESS_TOKEN')
46
 
 
47
  handler = WebhookHandler(channel_secret)
48
- # configuration = Configuration(
49
- # access_token=channel_access_token
50
- # )
51
- line_bot_api = LineBotApi(channel_access_token)
52
 
53
  @app.route("/")
54
  def home():
@@ -72,13 +69,19 @@ def callback():
72
 
73
  return 'OK'
74
 
75
- @handler.add(MessageEvent, message=(TextMessage, TextMessageContent))
76
  def handle_message(event):
 
 
77
  response = query({"inputs": event.message.text})
78
  html_msg = markdown.markdown(response)
79
  soup = BeautifulSoup(html_msg, 'html.parser')
80
- message = TextSendMessage(text=soup.get_text())
81
- line_bot_api.reply_message(event.reply_token, messages=message)
 
 
 
 
82
 
83
  @app.route('/static/<path:path>')
84
  def send_static_content(path):
 
44
  channel_secret = os.environ.get('YOUR_CHANNEL_SECRET')
45
  channel_access_token = os.environ.get('YOUR_CHANNEL_ACCESS_TOKEN')
46
 
47
+ configuration = Configuration(access_token=channel_access_token)
48
  handler = WebhookHandler(channel_secret)
 
 
 
 
49
 
50
  @app.route("/")
51
  def home():
 
69
 
70
  return 'OK'
71
 
72
+ @handler.add(MessageEvent, message=TextMessageContent)
73
  def handle_message(event):
74
+ with ApiClient(configuration) as api_client:
75
+ line_bot_api = MessagingApi(api_client)
76
  response = query({"inputs": event.message.text})
77
  html_msg = markdown.markdown(response)
78
  soup = BeautifulSoup(html_msg, 'html.parser')
79
+ line_bot_api.reply_message_with_http_info(
80
+ ReplyMessageRequest(
81
+ reply_token=event.reply_token,
82
+ messages=[TextMessage(text=soup.get_text())]
83
+ )
84
+ )
85
 
86
  @app.route('/static/<path:path>')
87
  def send_static_content(path):