Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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
|
| 13 |
client = InferenceClient(token=HF_TOKEN)
|
| 14 |
|
| 15 |
@app.route("/", methods=["GET"])
|
| 16 |
def home():
|
| 17 |
-
return "Krypton-1
|
| 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 |
-
#
|
| 26 |
response = client.chat_completion(
|
| 27 |
-
model="
|
| 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:
|
| 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 |
|