-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinference_server.py
More file actions
34 lines (28 loc) · 1.02 KB
/
inference_server.py
File metadata and controls
34 lines (28 loc) · 1.02 KB
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
33
34
from flask import Flask, send_file, make_response, request
from flask_cors import CORS, cross_origin
from inferer import LLMInfer
app = Flask(__name__)
cors = CORS(app)
@app.route("/get_config", methods=['POST'])
def get_configuration():
print('request received' + str(request.get_json()))
data = request.get_json()
user_prompt = data['user_prompt']
print('user prompt ' + str(user_prompt))
config = Inferer.infer(user_prompt)
print('configuration ' + str(config))
return config
@app.route("/get_model_architecture", methods=['POST'])
def get_model_architecture():
print('request received' + str(request.get_json()))
data = request.get_json()
print('data type ' + str(type(data)))
config = data['config']
print('config type ' + str(type(config)))
model_arch = Inferer.infer_model(config)
print('model architecture ' + str(model_arch))
return model_arch
if __name__ == '__main__':
Inferer = LLMInfer()
Inferer.load_model()
app.run(debug=True, host='0.0.0.0', port=8000)