tastypear commited on
Commit
d202b50
1 Parent(s): 39fbb88

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +11 -2
main.py CHANGED
@@ -47,9 +47,12 @@ def proxy():
47
  headers.pop('Content-Length', None)
48
  keys = request.headers['Authorization'].split(' ')[1].split(';')
49
  headers['Authorization'] = f'Bearer {random.choice(keys)}'
50
- headers['X-Use-Cache'] = 'false'
51
  json_data = request.get_json()
52
 
 
 
 
53
  # Use the largest ctx
54
  json_data['max_tokens'] = 32768 - calc_messages_tokens(json_data)
55
 
@@ -63,4 +66,10 @@ def proxy():
63
  if chunk:
64
  yield chunk
65
 
66
- return Response(stream_with_context(generate()), content_type='text/event-stream')
 
 
 
 
 
 
 
47
  headers.pop('Content-Length', None)
48
  keys = request.headers['Authorization'].split(' ')[1].split(';')
49
  headers['Authorization'] = f'Bearer {random.choice(keys)}'
50
+
51
  json_data = request.get_json()
52
 
53
+ # Avoid using cache
54
+ json_data["messages"][-1]['content'] = ' '*random.randint(1, 20)+json_data["messages"][-1]['content']
55
+
56
  # Use the largest ctx
57
  json_data['max_tokens'] = 32768 - calc_messages_tokens(json_data)
58
 
 
66
  if chunk:
67
  yield chunk
68
 
69
+ return Response(stream_with_context(generate()), content_type='text/event-stream')
70
+
71
+ #import gevent.pywsgi
72
+ #from gevent import monkey;monkey.patch_all()
73
+ if __name__ == "__main__":
74
+ app.run(debug=True)
75
+ # gevent.pywsgi.WSGIServer((args.host, args.port), app).serve_forever()