Kelvin000010191 commited on
Commit
7e5cb5d
·
verified ·
1 Parent(s): 5e877c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -9,12 +9,12 @@ CORS(app) # Unlocks your Acode connection securely
9
  # Pulls your hidden WRITE token from Space secrets
10
  HF_TOKEN = os.getenv("HF_TOKEN")
11
 
12
- # Connects directly to the primary stable inference engine router
13
  client = InferenceClient(token=HF_TOKEN)
14
 
15
  @app.route("/", methods=["GET"])
16
  def home():
17
- return "Krypton-1 Routing Engine is Online."
18
 
19
  @app.route("/api/chat", methods=["POST"])
20
  def chat():
@@ -22,9 +22,9 @@ def chat():
22
  data = request.json
23
  user_prompt = data.get("prompt", "")
24
 
25
- # Uses the fast, permanently active chat model endpoint
26
  response = client.chat_completion(
27
- model="Qwen/Qwen2.5-72B-Instruct",
28
  messages=[{"role": "user", "content": user_prompt}],
29
  max_tokens=250,
30
  temperature=0.7
@@ -40,7 +40,7 @@ def chat():
40
  return jsonify({"reply": "SYS_AUTH_ERR: Token unauthorized. Check your HF_TOKEN in Space Secrets."})
41
 
42
  if "loading" in raw_error.lower() or "503" in raw_error:
43
- return jsonify({"reply": "SYS_BOOT: Server cluster warming up. Give the cloud 30 seconds, then try again!"})
44
 
45
  return jsonify({"reply": f"SYS_ALERT: Connection failure. Details: {raw_error}"})
46
 
 
9
  # Pulls your hidden WRITE token from Space secrets
10
  HF_TOKEN = os.getenv("HF_TOKEN")
11
 
12
+ # Connects directly to the official, fully-supported Mistral-7B Instruct cluster
13
  client = InferenceClient(token=HF_TOKEN)
14
 
15
  @app.route("/", methods=["GET"])
16
  def home():
17
+ return "Krypton-1 Core Engine Online."
18
 
19
  @app.route("/api/chat", methods=["POST"])
20
  def chat():
 
22
  data = request.json
23
  user_prompt = data.get("prompt", "")
24
 
25
+ # Targets the official active Mistral endpoint layout
26
  response = client.chat_completion(
27
+ model="mistralai/Mistral-7B-Instruct-v0.3",
28
  messages=[{"role": "user", "content": user_prompt}],
29
  max_tokens=250,
30
  temperature=0.7
 
40
  return jsonify({"reply": "SYS_AUTH_ERR: Token unauthorized. Check your HF_TOKEN in Space Secrets."})
41
 
42
  if "loading" in raw_error.lower() or "503" in raw_error:
43
+ return jsonify({"reply": "SYS_BOOT: Mistral cluster is warming up weights. Give the cloud 30 seconds, then try again!"})
44
 
45
  return jsonify({"reply": f"SYS_ALERT: Connection failure. Details: {raw_error}"})
46