Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- Dockerfile +11 -0
- app.py +19 -0
- requirements.txt +2 -0
- space.yaml +2 -0
Dockerfile
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.10-slim
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
COPY requirements.txt requirements.txt
|
6 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
7 |
+
|
8 |
+
COPY app.py app.py
|
9 |
+
|
10 |
+
EXPOSE 7860
|
11 |
+
CMD ["python", "app.py"]
|
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, jsonify
|
2 |
+
from gradio_client import Client
|
3 |
+
|
4 |
+
app = Flask(__name__)
|
5 |
+
|
6 |
+
@app.route("/ask", methods=["POST"])
|
7 |
+
def ask_question():
|
8 |
+
try:
|
9 |
+
client = Client("memorease/flan5_memorease")
|
10 |
+
input_text = request.json.get("text")
|
11 |
+
if not input_text:
|
12 |
+
return jsonify({"error": "Missing 'text'"}), 400
|
13 |
+
result = client.predict(input_text, api_name="/predict")
|
14 |
+
return jsonify({"question": result})
|
15 |
+
except Exception as e:
|
16 |
+
return jsonify({"error": str(e)}), 500
|
17 |
+
|
18 |
+
if __name__ == "__main__":
|
19 |
+
app.run(host="0.0.0.0", port=7860)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
flask
|
2 |
+
gradio_client
|
space.yaml
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
sdk: docker
|
2 |
+
python_version: "3.10"
|