ffreemt commited on
Commit
3fecea6
·
1 Parent(s): bebb80b
Files changed (1) hide show
  1. duck2api_fwd.py +16 -3
duck2api_fwd.py CHANGED
@@ -47,9 +47,9 @@ def my_endpoint():
47
  url = "http://127.0.0.1:8080/v1/chat/completions"
48
  url = "http://acone:8080/v1/chat/completions"
49
 
50
- # y(request)
51
  # y(request.host)
52
- # y(request.host_url)
53
  # y(request.path)
54
  # y(request.full_path)
55
  # y(request.json)
@@ -60,11 +60,16 @@ def my_endpoint():
60
  }
61
 
62
  # remove prefix /hf
 
 
63
  if request.path.startswith("/hf"):
64
  url = f"http://127.0.0.1:8080{request.path[3:]}"
65
  else:
66
  url = f"http://127.0.0.1:8080{request.path}"
67
 
 
 
 
68
  try:
69
  response = requests.post(url, headers=headers, json=request.json)
70
  except Exception as exc:
@@ -77,7 +82,15 @@ def my_endpoint():
77
  if response.status_code == 200:
78
  return jsonify(response.json())
79
 
80
- return jsonify({"error": {"message": f"An error occurred: {err_msg}", "type": "server_error", "code": 500}})
 
 
 
 
 
 
 
 
81
 
82
 
83
  if __name__ == "__main__":
 
47
  url = "http://127.0.0.1:8080/v1/chat/completions"
48
  url = "http://acone:8080/v1/chat/completions"
49
 
50
+ y(request)
51
  # y(request.host)
52
+ y(request.host_url)
53
  # y(request.path)
54
  # y(request.full_path)
55
  # y(request.json)
 
60
  }
61
 
62
  # remove prefix /hf
63
+ y(request.url)
64
+ y(request.path)
65
  if request.path.startswith("/hf"):
66
  url = f"http://127.0.0.1:8080{request.path[3:]}"
67
  else:
68
  url = f"http://127.0.0.1:8080{request.path}"
69
 
70
+ y(url)
71
+
72
+
73
  try:
74
  response = requests.post(url, headers=headers, json=request.json)
75
  except Exception as exc:
 
82
  if response.status_code == 200:
83
  return jsonify(response.json())
84
 
85
+ return jsonify(
86
+ {
87
+ "error": {
88
+ "message": f"An error occurred: {err_msg}",
89
+ "type": "server_error",
90
+ "code": 500,
91
+ }
92
+ }
93
+ )
94
 
95
 
96
  if __name__ == "__main__":