Spaces:
Paused
Paused
Upload 5 files
Browse files- Dockerfile +13 -60
- app.py +1 -1
Dockerfile
CHANGED
|
@@ -1,71 +1,24 @@
|
|
| 1 |
-
|
| 2 |
-
# TODO: 解决完整版本的依赖问题后替换此文件
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
|
| 7 |
-
# 安装基本依赖
|
| 8 |
-
RUN apk add --no-cache git build-base ca-certificates
|
| 9 |
-
|
| 10 |
-
# 设置工作目录
|
| 11 |
WORKDIR /app
|
| 12 |
|
| 13 |
-
|
| 14 |
-
RUN
|
| 15 |
-
|
| 16 |
-
# 预先下载依赖
|
| 17 |
-
RUN go get github.com/google/generative-ai-go/genai@v0.8.0
|
| 18 |
-
RUN go get google.golang.org/api@v0.152.0
|
| 19 |
-
RUN go get github.com/gin-gonic/gin@v1.9.1
|
| 20 |
-
RUN go get github.com/go-playground/validator/v10@v10.14.0
|
| 21 |
-
RUN go get github.com/gabriel-vasile/mimetype@v1.4.2
|
| 22 |
-
|
| 23 |
-
# 复制源代码
|
| 24 |
-
COPY main.go .
|
| 25 |
-
|
| 26 |
-
# 确保依赖关系
|
| 27 |
-
RUN go mod tidy
|
| 28 |
-
RUN go mod download
|
| 29 |
-
|
| 30 |
-
# 构建
|
| 31 |
-
RUN CGO_ENABLED=0 GOOS=linux go build -o tokenizer -a -installsuffix cgo -ldflags="-w -s" .
|
| 32 |
-
|
| 33 |
-
# 第二阶段:构建Python环境
|
| 34 |
-
FROM python:3.9-slim
|
| 35 |
-
|
| 36 |
-
# 安装基本依赖
|
| 37 |
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 38 |
-
ca-certificates \
|
| 39 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 40 |
-
|
| 41 |
-
# 设置工作目录
|
| 42 |
-
WORKDIR /app
|
| 43 |
-
|
| 44 |
-
# 复制Go二进制文件
|
| 45 |
-
COPY --from=go-builder /app/tokenizer .
|
| 46 |
-
|
| 47 |
-
# 复制Python服务文件和tokenizer文件
|
| 48 |
-
COPY deepseek_v3_tokenizer /app/deepseek_v3_tokenizer
|
| 49 |
-
COPY openai_service.py /app/
|
| 50 |
|
| 51 |
-
|
| 52 |
-
RUN pip install --no-cache-dir flask transformers tiktoken
|
| 53 |
|
| 54 |
# 设置环境变量
|
| 55 |
-
ENV
|
| 56 |
ENV PORT=7860
|
| 57 |
-
ENV DEEPSEEK_URL=http://127.0.0.1:7861
|
| 58 |
-
ENV OPENAI_URL=http://127.0.0.1:7862
|
| 59 |
|
| 60 |
-
#
|
| 61 |
-
RUN
|
| 62 |
-
python /app/deepseek_v3_tokenizer/deepseek_service.py & \n\
|
| 63 |
-
python /app/openai_service.py & \n\
|
| 64 |
-
sleep 5\n\
|
| 65 |
-
./tokenizer' > /app/start.sh && chmod +x /app/start.sh
|
| 66 |
|
| 67 |
-
#
|
| 68 |
-
EXPOSE 7860
|
| 69 |
|
| 70 |
-
#
|
| 71 |
-
CMD ["
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
|
|
|
| 2 |
|
| 3 |
+
# 设置用户为root
|
| 4 |
+
USER root
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
WORKDIR /app
|
| 7 |
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
COPY . .
|
|
|
|
| 12 |
|
| 13 |
# 设置环境变量
|
| 14 |
+
ENV HOST=0.0.0.0
|
| 15 |
ENV PORT=7860
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
# 删除敏感文件
|
| 18 |
+
RUN rm -f config.json password.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
# 暴露端口(Hugging Face默认使用7860端口)
|
| 21 |
+
EXPOSE 7860
|
| 22 |
|
| 23 |
+
# 启动命令
|
| 24 |
+
CMD ["python", "app.py"]
|
app.py
CHANGED
|
@@ -18,7 +18,7 @@ app.secret_key = os.environ.get("SECRET_KEY", "abacus_chat_proxy_secret_key")
|
|
| 18 |
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7)
|
| 19 |
|
| 20 |
# 添加tokenizer服务URL
|
| 21 |
-
TOKENIZER_SERVICE_URL = "https://
|
| 22 |
|
| 23 |
API_ENDPOINT_URL = "https://abacus.ai/api/v0/describeDeployment"
|
| 24 |
MODEL_LIST_URL = "https://abacus.ai/api/v0/listExternalApplications"
|
|
|
|
| 18 |
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7)
|
| 19 |
|
| 20 |
# 添加tokenizer服务URL
|
| 21 |
+
TOKENIZER_SERVICE_URL = "https://malt666-abacus-chat-proxy.hf.space/count_tokens"
|
| 22 |
|
| 23 |
API_ENDPOINT_URL = "https://abacus.ai/api/v0/describeDeployment"
|
| 24 |
MODEL_LIST_URL = "https://abacus.ai/api/v0/listExternalApplications"
|