Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -20,13 +20,32 @@ app.config['UPLOAD_FOLDER'] = "static"
|
|
20 |
@app.route("/chat/completions", methods=['POST'])
|
21 |
@app.route("/", methods=['POST'])
|
22 |
def chat_completions2():
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
streaming = req.json.get('stream', False)
|
25 |
model = req.json.get('model', 'gpt-4-turbo')
|
26 |
messages = req.json.get('messages')
|
27 |
api_keys = req.headers.get('Authorization').replace('Bearer ', '')
|
28 |
functions = req.json.get('functions')
|
29 |
tools = req.json.get('tools')
|
|
|
|
|
|
|
30 |
|
31 |
if tools!=None:
|
32 |
allocate(messages,api_keys,model,tools)
|
@@ -182,7 +201,7 @@ def models():
|
|
182 |
if __name__ == '__main__':
|
183 |
config = {
|
184 |
'host': '0.0.0.0',
|
185 |
-
'port':
|
186 |
'debug': True,
|
187 |
}
|
188 |
|
|
|
20 |
@app.route("/chat/completions", methods=['POST'])
|
21 |
@app.route("/", methods=['POST'])
|
22 |
def chat_completions2():
|
23 |
+
all_request_data = {}
|
24 |
+
all_request_data['json'] = req.get_json(silent=True) or {}
|
25 |
+
all_request_data['headers'] = dict(req.headers)
|
26 |
+
|
27 |
+
all_request_data['args'] = req.args.to_dict(flat=False)
|
28 |
+
all_request_data['form'] = req.form.to_dict(flat=False)
|
29 |
+
try:
|
30 |
+
all_request_data['raw_data'] = req.data.decode('utf-8')
|
31 |
+
except Exception:
|
32 |
+
all_request_data['raw_data'] = f"Could not decode raw data (length: {len(req.data)})"
|
33 |
+
|
34 |
+
|
35 |
+
# --- Now you can access your original values from this dict ---
|
36 |
+
print("--- Consolidated Request Data ---")
|
37 |
+
print(json.dumps(all_request_data, indent=2))
|
38 |
+
print("--------------------------------")
|
39 |
+
|
40 |
streaming = req.json.get('stream', False)
|
41 |
model = req.json.get('model', 'gpt-4-turbo')
|
42 |
messages = req.json.get('messages')
|
43 |
api_keys = req.headers.get('Authorization').replace('Bearer ', '')
|
44 |
functions = req.json.get('functions')
|
45 |
tools = req.json.get('tools')
|
46 |
+
if streaming:
|
47 |
+
helper.stopped=True
|
48 |
+
|
49 |
|
50 |
if tools!=None:
|
51 |
allocate(messages,api_keys,model,tools)
|
|
|
201 |
if __name__ == '__main__':
|
202 |
config = {
|
203 |
'host': '0.0.0.0',
|
204 |
+
'port': 1337,
|
205 |
'debug': True,
|
206 |
}
|
207 |
|