Euryeth commited on
Commit
20e3a90
·
verified ·
1 Parent(s): 18e3582

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +13 -3
api.py CHANGED
@@ -8,29 +8,39 @@ app = Flask(__name__)
8
  def chat_completions():
9
  data = request.json
10
  messages = data.get('messages', [])
11
- max_tokens = data.get('max_tokens', 1080)
12
  temperature = data.get('temperature', 0.8)
13
 
14
  if not messages:
15
  return jsonify({"error": "messages array is required"}), 400
16
 
17
  try:
 
18
  result = generate_chat_completion(
19
  messages=messages,
20
  max_tokens=max_tokens,
21
  temperature=temperature
22
  )
 
 
23
  return jsonify({
24
- "model": "DS-R1-Qwen3-8B",
25
  "choices": [{
26
  "message": {
27
  "role": "assistant",
28
  "content": result
29
  }
30
- }]
 
 
 
31
  })
32
  except Exception as e:
33
  return jsonify({"error": str(e)}), 500
34
 
 
 
 
 
35
  if __name__ == '__main__':
36
  app.run(host='0.0.0.0', port=8081)
 
8
  def chat_completions():
9
  data = request.json
10
  messages = data.get('messages', [])
11
+ max_tokens = data.get('max_tokens', 560)
12
  temperature = data.get('temperature', 0.8)
13
 
14
  if not messages:
15
  return jsonify({"error": "messages array is required"}), 400
16
 
17
  try:
18
+ start_time = time.time()
19
  result = generate_chat_completion(
20
  messages=messages,
21
  max_tokens=max_tokens,
22
  temperature=temperature
23
  )
24
+ elapsed = time.time() - start_time
25
+
26
  return jsonify({
27
+ "model": "Mistral-7B-Instruct",
28
  "choices": [{
29
  "message": {
30
  "role": "assistant",
31
  "content": result
32
  }
33
+ }],
34
+ "usage": {
35
+ "generation_time": round(elapsed, 2)
36
+ }
37
  })
38
  except Exception as e:
39
  return jsonify({"error": str(e)}), 500
40
 
41
+ @app.route('/')
42
+ def health_check():
43
+ return "API is running", 200
44
+
45
  if __name__ == '__main__':
46
  app.run(host='0.0.0.0', port=8081)