-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorchestrator.py
33 lines (27 loc) · 930 Bytes
/
orchestrator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import sys
from flask import Flask, request, jsonify
# import asyncio
from utils import get_llm_output
from activity_recognition import get_activity, get_recommendation
## Pipeline
## 1. Get accelerometer data on api (for demo) ## implemented
## 2. Predict action : ## Implemented using HARGPT paper (https://arxiv.org/abs/2403.02727) as reference
## 3. Send action to llm : ## Implemented
app = Flask(__name__)
@app.route('/api/', methods=['POST'])
def process_request():
content = request.get_json()
try:
data = content['data']
except Exception as e:
print('no data in json', e)
print(content)
return jsonify({'message': 'JSON data can not be parsed!'})
print(data)
activity = get_activity(data)
output = get_recommendation(activity, data)
print(output)
return output
if __name__ == "__main__":
app.run(host='localhost', port=8989, debug=True)