Spaces:
Sleeping
Sleeping
ffreemt
commited on
Commit
·
6ec79ba
1
Parent(s):
ffa1ff4
Update
Browse files- Dockerfile +1 -0
- duck2api_fwd.py +12 -5
- pwd +0 -0
Dockerfile
CHANGED
@@ -28,6 +28,7 @@ WORKDIR /app
|
|
28 |
# 从构建阶段复制编译好的应用和资源
|
29 |
COPY --from=builder /app/duck2api /app/duck2api
|
30 |
|
|
|
31 |
RUN pip install --no-cache-dir -r requirements.txt
|
32 |
|
33 |
# add prefix /hf route and flask forwarder
|
|
|
28 |
# 从构建阶段复制编译好的应用和资源
|
29 |
COPY --from=builder /app/duck2api /app/duck2api
|
30 |
|
31 |
+
COPY . .
|
32 |
RUN pip install --no-cache-dir -r requirements.txt
|
33 |
|
34 |
# add prefix /hf route and flask forwarder
|
duck2api_fwd.py
CHANGED
@@ -3,16 +3,23 @@
|
|
3 |
# flask 糊接口
|
4 |
# curl -sS --location http://127.0.0.1:5000/hf/v1/chat/completions -H "Content-Type: application/json" --data "{\"model\": \"gpt-.5-turbo\", \"messages\": [{\"role\": \"user\", \"content\": \"Say this is a test!\"}], \"stream\": false}"
|
5 |
|
6 |
-
from
|
7 |
import requests
|
8 |
-
import
|
9 |
from ycecream import y
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
y.configure(sln=1)
|
12 |
|
13 |
app = Flask(__name__)
|
14 |
|
15 |
-
|
|
|
16 |
def my_endpoint():
|
17 |
url = "https://api.anakin.ai/v1/apps/1344/chatbot/chat"
|
18 |
url = "http://127.0.0.1:8080/v1/chat/completions"
|
@@ -26,7 +33,7 @@ def my_endpoint():
|
|
26 |
# y(request.json)
|
27 |
# y(dir(request))
|
28 |
headers = {
|
29 |
-
|
30 |
# 'Authorization': 'Bearer ANAKINAI_API_ACCESS_TOKEN'
|
31 |
}
|
32 |
|
@@ -47,5 +54,5 @@ def my_endpoint():
|
|
47 |
return jsonify({"error": {"message": f"An error occurred: {err_msg}", "type": "server_error", "code": 500}})
|
48 |
|
49 |
|
50 |
-
if __name__ ==
|
51 |
app.run(port=5000)
|
|
|
3 |
# flask 糊接口
|
4 |
# curl -sS --location http://127.0.0.1:5000/hf/v1/chat/completions -H "Content-Type: application/json" --data "{\"model\": \"gpt-.5-turbo\", \"messages\": [{\"role\": \"user\", \"content\": \"Say this is a test!\"}], \"stream\": false}"
|
5 |
|
6 |
+
from threading import Thread
|
7 |
import requests
|
8 |
+
from flask import Flask, jsonify, request
|
9 |
from ycecream import y
|
10 |
+
from python_run_cmd import run_cmd
|
11 |
+
|
12 |
+
def run_duck2api():
|
13 |
+
run-cmd("./duck2api")
|
14 |
+
|
15 |
+
Thread(target=run_duck2api).start()
|
16 |
|
17 |
y.configure(sln=1)
|
18 |
|
19 |
app = Flask(__name__)
|
20 |
|
21 |
+
|
22 |
+
@app.route("/hf/v1/chat/completions", methods=["POST"])
|
23 |
def my_endpoint():
|
24 |
url = "https://api.anakin.ai/v1/apps/1344/chatbot/chat"
|
25 |
url = "http://127.0.0.1:8080/v1/chat/completions"
|
|
|
33 |
# y(request.json)
|
34 |
# y(dir(request))
|
35 |
headers = {
|
36 |
+
"Content-Type": "application/json",
|
37 |
# 'Authorization': 'Bearer ANAKINAI_API_ACCESS_TOKEN'
|
38 |
}
|
39 |
|
|
|
54 |
return jsonify({"error": {"message": f"An error occurred: {err_msg}", "type": "server_error", "code": 500}})
|
55 |
|
56 |
|
57 |
+
if __name__ == "__main__":
|
58 |
app.run(port=5000)
|
pwd
ADDED
File without changes
|