Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,12 @@
|
|
1 |
from flask import Flask, jsonify, request
|
2 |
from webscout import AsyncWEBS, WEBS
|
3 |
from webscout.LLM import LLM
|
|
|
4 |
|
5 |
app = Flask(__name__)
|
6 |
|
|
|
|
|
7 |
|
8 |
@app.route('/search', methods=['POST'])
|
9 |
def WEBScout2_search_search():
|
@@ -18,7 +21,6 @@ def WEBScout2_search_search():
|
|
18 |
responses.append(r)
|
19 |
return jsonify(responses)
|
20 |
|
21 |
-
|
22 |
@app.route('/mws', methods=['POST'])
|
23 |
def WEBScout_search():
|
24 |
data = request.get_json()
|
@@ -108,13 +110,13 @@ def WEBScout_translate():
|
|
108 |
return jsonify(translation)
|
109 |
|
110 |
@app.route('/chat', methods=['POST'])
|
111 |
-
def
|
112 |
user_input = request.json.get('message')
|
113 |
if user_input is None:
|
114 |
return jsonify({'error': 'Message parameter missing'})
|
115 |
-
|
116 |
-
|
117 |
-
return jsonify({"response":
|
118 |
|
119 |
if __name__ == '__main__':
|
120 |
-
app.run(debug=True)
|
|
|
1 |
from flask import Flask, jsonify, request
|
2 |
from webscout import AsyncWEBS, WEBS
|
3 |
from webscout.LLM import LLM
|
4 |
+
from webscout.AI import OPENGPT # Import OPENGPT
|
5 |
|
6 |
app = Flask(__name__)
|
7 |
|
8 |
+
# Initialize the OPENGPT instance
|
9 |
+
opengpt = OPENGPT(is_conversation=False, max_tokens=8000, timeout=30)
|
10 |
|
11 |
@app.route('/search', methods=['POST'])
|
12 |
def WEBScout2_search_search():
|
|
|
21 |
responses.append(r)
|
22 |
return jsonify(responses)
|
23 |
|
|
|
24 |
@app.route('/mws', methods=['POST'])
|
25 |
def WEBScout_search():
|
26 |
data = request.get_json()
|
|
|
110 |
return jsonify(translation)
|
111 |
|
112 |
@app.route('/chat', methods=['POST'])
|
113 |
+
def chat_opengpt():
|
114 |
user_input = request.json.get('message')
|
115 |
if user_input is None:
|
116 |
return jsonify({'error': 'Message parameter missing'})
|
117 |
+
# Use the opengpt instance to process the chat message
|
118 |
+
response_str = opengpt.chat(user_input)
|
119 |
+
return jsonify({"response": response_str})
|
120 |
|
121 |
if __name__ == '__main__':
|
122 |
+
app.run(debug=True)
|