Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,9 +2,9 @@ from flask import Flask, request, jsonify
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
# Initialize the InferenceClient with your API key
|
| 5 |
-
x="hf_uYlR"
|
| 6 |
-
y="EMsDNbxQPJCSAHgwthrylHZZKKmGyg"
|
| 7 |
-
u=x+y
|
| 8 |
client = InferenceClient(api_key=f"{u}")
|
| 9 |
|
| 10 |
# Create a Flask app
|
|
@@ -33,8 +33,11 @@ def chat():
|
|
| 33 |
# Get the assistant's response
|
| 34 |
assistant_message = response.choices[0].message.content
|
| 35 |
|
|
|
|
|
|
|
|
|
|
| 36 |
# Return the assistant's response as JSON
|
| 37 |
return jsonify({"response": assistant_message})
|
| 38 |
|
| 39 |
if __name__ == '__main__':
|
| 40 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
# Initialize the InferenceClient with your API key
|
| 5 |
+
x = "hf_uYlR"
|
| 6 |
+
y = "EMsDNbxQPJCSAHgwthrylHZZKKmGyg"
|
| 7 |
+
u = x + y
|
| 8 |
client = InferenceClient(api_key=f"{u}")
|
| 9 |
|
| 10 |
# Create a Flask app
|
|
|
|
| 33 |
# Get the assistant's response
|
| 34 |
assistant_message = response.choices[0].message.content
|
| 35 |
|
| 36 |
+
# Replace newline characters with <br> for HTML rendering
|
| 37 |
+
assistant_message = assistant_message.replace("\n", "<br>")
|
| 38 |
+
|
| 39 |
# Return the assistant's response as JSON
|
| 40 |
return jsonify({"response": assistant_message})
|
| 41 |
|
| 42 |
if __name__ == '__main__':
|
| 43 |
+
app.run(host="0.0.0.0", port=7860)
|