Spaces:
Build error
Build error
tracyshen301
commited on
Commit
·
88dfac7
1
Parent(s):
9b0d6f7
Add endpoint
Browse files- Dockerfile +3 -2
- app.py +5 -0
Dockerfile
CHANGED
@@ -8,8 +8,8 @@ RUN apt-get update && apt-get install -y \
|
|
8 |
git \
|
9 |
&& rm -rf /var/lib/apt/lists/*
|
10 |
|
11 |
-
# 设置环境变量,指定 Hugging Face
|
12 |
-
ENV
|
13 |
|
14 |
# 设置工作目录
|
15 |
WORKDIR /app
|
@@ -27,3 +27,4 @@ EXPOSE 7860
|
|
27 |
# 启动应用
|
28 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
29 |
|
|
|
|
8 |
git \
|
9 |
&& rm -rf /var/lib/apt/lists/*
|
10 |
|
11 |
+
# 设置环境变量,指定 Hugging Face 缓存目录
|
12 |
+
ENV HF_HOME=/tmp/transformers_cache
|
13 |
|
14 |
# 设置工作目录
|
15 |
WORKDIR /app
|
|
|
27 |
# 启动应用
|
28 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
29 |
|
30 |
+
|
app.py
CHANGED
@@ -34,6 +34,11 @@ gpt2_model = AutoModelForCausalLM.from_pretrained("TracyShen301/myFinnishChatbot
|
|
34 |
AUDIO_DIR = "/tmp/audio_files"
|
35 |
os.makedirs(AUDIO_DIR, exist_ok=True)
|
36 |
|
|
|
|
|
|
|
|
|
|
|
37 |
@app.post("/process_audio/")
|
38 |
async def process_audio(file: UploadFile = File(...)):
|
39 |
try:
|
|
|
34 |
AUDIO_DIR = "/tmp/audio_files"
|
35 |
os.makedirs(AUDIO_DIR, exist_ok=True)
|
36 |
|
37 |
+
@app.get("/")
|
38 |
+
async def read_root():
|
39 |
+
return {"message": "Welcome to the Finnish Chatbot API!"}
|
40 |
+
|
41 |
+
|
42 |
@app.post("/process_audio/")
|
43 |
async def process_audio(file: UploadFile = File(...)):
|
44 |
try:
|