Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -1,9 +1,12 @@
|
|
1 |
from flask import Flask, jsonify, request
|
2 |
from flask_cors import CORS
|
3 |
import google.generativeai as genai
|
|
|
4 |
import os
|
5 |
import json
|
6 |
|
|
|
|
|
7 |
app = Flask(__name__)
|
8 |
|
9 |
CORS(app)
|
@@ -13,7 +16,7 @@ GOOGLE_API_KEY=os.getenv('GOOGLE_API_KEY')
|
|
13 |
genai.configure(api_key=GOOGLE_API_KEY)
|
14 |
model = genai.GenerativeModel('gemini-pro')
|
15 |
|
16 |
-
user_id_ping = 0
|
17 |
user_chats = {}
|
18 |
|
19 |
@app.route('/')
|
@@ -182,7 +185,7 @@ def interview():
|
|
182 |
json_text = json.loads(response.text)
|
183 |
try:
|
184 |
if json_text['end']:
|
185 |
-
user_id_ping = user_id
|
186 |
return jsonify({'success': True, 'data': response.text, 'end': True})
|
187 |
except Exception as e:
|
188 |
print(e)
|
@@ -195,7 +198,7 @@ def interview():
|
|
195 |
user_id = data.get('user_id')
|
196 |
user_chats[user_id].processed = True
|
197 |
user_chats[user_id].results = {'total_video_emotions': data.get('total_video_emotions'), 'emotions_final': data.get('emotions_final'), 'body_language': data.get('body_language'), 'distraction_rate': data.get('distraction_rate'), 'formatted_response': data.get('formatted_response'), 'total_transcript_sentiment': data.get('total_transcript_sentiment')}
|
198 |
-
return
|
199 |
|
200 |
|
201 |
@app.route('/result', methods=['POST', 'GET'])
|
@@ -234,7 +237,7 @@ def result():
|
|
234 |
@app.route('/useridping', methods=['GET'])
|
235 |
def useridping():
|
236 |
if request.method == 'GET':
|
237 |
-
return jsonify(user_id_ping)
|
238 |
|
239 |
|
240 |
if __name__ == '__main__':
|
|
|
1 |
from flask import Flask, jsonify, request
|
2 |
from flask_cors import CORS
|
3 |
import google.generativeai as genai
|
4 |
+
from dotenv import load_dotenv
|
5 |
import os
|
6 |
import json
|
7 |
|
8 |
+
load_dotenv()
|
9 |
+
|
10 |
app = Flask(__name__)
|
11 |
|
12 |
CORS(app)
|
|
|
16 |
genai.configure(api_key=GOOGLE_API_KEY)
|
17 |
model = genai.GenerativeModel('gemini-pro')
|
18 |
|
19 |
+
user_id_ping = {'current': 0}
|
20 |
user_chats = {}
|
21 |
|
22 |
@app.route('/')
|
|
|
185 |
json_text = json.loads(response.text)
|
186 |
try:
|
187 |
if json_text['end']:
|
188 |
+
user_id_ping['current'] = user_id
|
189 |
return jsonify({'success': True, 'data': response.text, 'end': True})
|
190 |
except Exception as e:
|
191 |
print(e)
|
|
|
198 |
user_id = data.get('user_id')
|
199 |
user_chats[user_id].processed = True
|
200 |
user_chats[user_id].results = {'total_video_emotions': data.get('total_video_emotions'), 'emotions_final': data.get('emotions_final'), 'body_language': data.get('body_language'), 'distraction_rate': data.get('distraction_rate'), 'formatted_response': data.get('formatted_response'), 'total_transcript_sentiment': data.get('total_transcript_sentiment')}
|
201 |
+
return jsonify({'success': True})
|
202 |
|
203 |
|
204 |
@app.route('/result', methods=['POST', 'GET'])
|
|
|
237 |
@app.route('/useridping', methods=['GET'])
|
238 |
def useridping():
|
239 |
if request.method == 'GET':
|
240 |
+
return jsonify(user_id_ping['current'])
|
241 |
|
242 |
|
243 |
if __name__ == '__main__':
|