raygiles3 commited on
Commit
f968d79
·
verified ·
1 Parent(s): 25b677d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -16
app.py CHANGED
@@ -1,22 +1,33 @@
1
- from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
- from flask import Flask, jsonify
 
 
 
 
3
 
4
- model_name = "facebook/blenderbot-400M-distill"
 
5
 
6
- # Load model (download on first run and reference local installation for consequent runs)
7
- model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
8
- tokenizer = AutoTokenizer.from_pretrained(model_name)
9
 
10
- conversation_history = []
 
 
11
 
12
- app = Flask(__name__)
13
 
14
- @app.route('/')
15
- def main():
16
- return jsonify({
17
- 'status':200,
18
- 'content':"Hello, world"
19
- })
 
 
 
 
 
 
 
 
20
 
21
- if __name__ == '__main__':
22
- app.run(host='0.0.0.0', port=7860, debug=False)
 
1
+ import base64
2
+ import json
3
+ from flask import Flask, render_template, request
4
+ from worker import speech_to_text, text_to_speech, openai_process_message
5
+ from flask_cors import CORS
6
+ import os
7
 
8
+ app = Flask(__name__)
9
+ cors = CORS(app, resources={r"/*": {"origins": "*"}})
10
 
 
 
 
11
 
12
+ @app.route('/', methods=['GET'])
13
+ def index():
14
+ return render_template('index.html')
15
 
 
16
 
17
+ @app.route('/speech-to-text', methods=['POST'])
18
+ def speech_to_text_route():
19
+ return None
20
+
21
+
22
+ @app.route('/process-message', methods=['POST'])
23
+ def process_prompt_route():
24
+ response = app.response_class(
25
+ response=json.dumps({"openaiResponseText": None, "openaiResponseSpeech": None}),
26
+ status=200,
27
+ mimetype='application/json'
28
+ )
29
+ return response
30
+
31
 
32
+ if __name__ == "__main__":
33
+ app.run(port=8000, host='0.0.0.0')