imseldrith commited on
Commit
b132330
·
verified ·
1 Parent(s): cf9fdca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -2,6 +2,7 @@ from flask import Flask, request, jsonify
2
  import requests
3
  from dotenv import load_dotenv
4
  import os
 
5
 
6
  # Load environment variables from .env file
7
  load_dotenv()
@@ -55,13 +56,12 @@ def webhook():
55
  # Set typing on
56
  set_typing_on(sender_id)
57
 
58
- if message_text.lower() == 'hi':
59
- response_text = 'hello'
60
- print(f"Sending response to {sender_id}: {response_text}")
61
- send_message(sender_id, response_text)
62
- else:
63
- print(f"No action taken for message: {message_text}")
64
-
65
  # Set typing off after responding
66
  set_typing_off(sender_id)
67
 
 
2
  import requests
3
  from dotenv import load_dotenv
4
  import os
5
+ from helper.openai_api import chat_completion
6
 
7
  # Load environment variables from .env file
8
  load_dotenv()
 
56
  # Set typing on
57
  set_typing_on(sender_id)
58
 
59
+ result = chat_completion(message_text)
60
+ response_text = result.get('response', '')
61
+ #response_text = 'hello'
62
+ print(f"Sending response to {sender_id}: {response_text}")
63
+ send_message(sender_id, response_text)
64
+
 
65
  # Set typing off after responding
66
  set_typing_off(sender_id)
67