yasirme commited on
Commit
acdfb2b
·
verified ·
1 Parent(s): 1daa44a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -48
app.py CHANGED
@@ -1,48 +1,50 @@
1
- from config import Flask,pipeline_dict,Response,convHandler
2
- from application.chat_inference import ChatInference
3
- from flask import render_template,request
4
-
5
- app = Flask(__name__, template_folder='application/templates', static_folder='application/static')
6
-
7
- chat_inference = ChatInference()
8
-
9
- @app.route('/')
10
- def home():
11
- return render_template('index.html')
12
-
13
- @app.route('/completions',methods=['POST'])
14
- def completeions():
15
- data = request.json
16
- models = pipeline_dict['api']['models']
17
- if(data.get('model',None) not in models):
18
- return "Model Not Found", 404
19
- model_info = models[data['model']]
20
- data.update(
21
- {
22
- "base_url": model_info['api_url'],
23
- "type": model_info['type']
24
- }
25
- )
26
- return chat_inference.chat(data=data,handle_stream=pipeline_dict['handle_stream'],user=request.remote_addr)
27
-
28
- @app.route('/convs')
29
- def get_conv():
30
- print(request.remote_addr)
31
- return convHandler.get_conv(request.remote_addr)
32
-
33
- @app.route('/create', methods=['POST'])
34
- def create_conv():
35
- sysPrompt = request.json.get('system_prompt', '')
36
- return convHandler.create_conv(ip=request.remote_addr,sysPrompt=sysPrompt)
37
- @app.route('/fetch', methods=['POST'])
38
- def fetch():
39
- convId = request.json.get('convId')
40
- return convHandler.fetch_conv(convId=convId,ip=request.remote_addr)
41
- @app.route('/update')
42
- def update():
43
- return convHandler.update_conv(request.remote_addr, request.json)
44
- @app.route('/models')
45
- def models():
46
- return list(pipeline_dict['api']['models'].keys())
47
-
48
- app.run(host='0.0.0.0',port=5000,debug=False)
 
 
 
1
+ from config import Flask,pipeline_dict,Response,convHandler
2
+ from application.chat_inference import ChatInference
3
+ from flask import render_template,request
4
+
5
+ app = Flask(__name__, template_folder='application/templates', static_folder='application/static')
6
+
7
+ chat_inference = ChatInference()
8
+
9
+ @app.route('/')
10
+ def home():
11
+ return render_template('index.html')
12
+
13
+ @app.route('/completions',methods=['POST'])
14
+ def completeions():
15
+ data = request.json
16
+ models = pipeline_dict['api']['models']
17
+ if(data.get('model',None) not in models):
18
+ return "Model Not Found", 404
19
+ model_info = models[data['model']]
20
+ data.update(
21
+ {
22
+ "base_url": model_info['api_url'],
23
+ "type": model_info['type']
24
+ }
25
+ )
26
+ return chat_inference.chat(data=data,handle_stream=pipeline_dict['handle_stream'],user=request.remote_addr)
27
+
28
+ @app.route('/convs')
29
+ def get_conv():
30
+ print(request.remote_addr)
31
+ return convHandler.get_conv(request.remote_addr)
32
+
33
+ @app.route('/create', methods=['POST'])
34
+ def create_conv():
35
+ sysPrompt = request.json.get('system_prompt', '')
36
+ return convHandler.create_conv(ip=request.remote_addr,sysPrompt=sysPrompt)
37
+ @app.route('/fetch', methods=['POST'])
38
+ def fetch():
39
+ convId = request.json.get('convId')
40
+ return convHandler.fetch_conv(convId=convId,ip=request.remote_addr)
41
+ @app.route('/update')
42
+ def update():
43
+ return convHandler.update_conv(request.remote_addr, request.json)
44
+ @app.route('/models')
45
+ def models():
46
+ return list(pipeline_dict['api']['models'].keys())
47
+
48
+ if __name__ == "__main__":
49
+ app.run(host="0.0.0.0", port=7860)
50
+