nanoppa commited on
Commit
d9dbeb6
·
verified ·
1 Parent(s): 7743fdc

Update app.py

Browse files

增加/vi/models的接口,支持openwebui

Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -6,8 +6,8 @@ import time
6
  import os
7
  import re
8
 
9
- _COOKIES = os.environ.get("COOKIES", "")
10
- #_COOKIES = "cf_clearance=toCFbLwd4RZKgHIv_nY.7B1yXUkIfvh0QwWBzxpLa5w-1740730551-1.2.1.1-yasz4kMVvPBtgGz06uRNFlDE1VXXZ2McAq65AKeidqAagCe4ZQ5desj88RDdSZAZ3CG4tJZrZ7pVxTCUDHnvGy96C6_ocRUQc3.qbbsWyeLwHNCD2OZjtVqkVI5MHiNFarJv8qGd9uOriKAytgttX.vMYbEOstOnMGvY5DnjODPDUWDlOwwNrshAsghJbf8B32X9VokGduYk1FvqqPhs85Eq4zdHv83tGKFSpTidYD7FmQoxwiv77T2kyeBXX.6.4ExZiHE9DszGcWZ9_FO8Ub5U2zod0S9U0oqncQwQVXM; session_token=82673f97181bb5da073f2d8771f5b4cd9208f15e0df4c29c74fd849f729249e0"
11
 
12
  API_KEY = os.getenv("API_KEY", "linux.do")
13
 
@@ -19,6 +19,21 @@ def check_api_key():
19
  if key != "Bearer "+API_KEY:
20
  return jsonify({"success": False, "message": "Unauthorized: Invalid API key"}), 403
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  @app.route('/v1/chat/completions', methods=['POST'])
24
  def chat_completions():
 
6
  import os
7
  import re
8
 
9
+ #_COOKIES = os.environ.get("COOKIES", "")
10
+ _COOKIES = "cf_clearance=toCFbLwd4RZKgHIv_nY.7B1yXUkIfvh0QwWBzxpLa5w-1740730551-1.2.1.1-yasz4kMVvPBtgGz06uRNFlDE1VXXZ2McAq65AKeidqAagCe4ZQ5desj88RDdSZAZ3CG4tJZrZ7pVxTCUDHnvGy96C6_ocRUQc3.qbbsWyeLwHNCD2OZjtVqkVI5MHiNFarJv8qGd9uOriKAytgttX.vMYbEOstOnMGvY5DnjODPDUWDlOwwNrshAsghJbf8B32X9VokGduYk1FvqqPhs85Eq4zdHv83tGKFSpTidYD7FmQoxwiv77T2kyeBXX.6.4ExZiHE9DszGcWZ9_FO8Ub5U2zod0S9U0oqncQwQVXM; session_token=82673f97181bb5da073f2d8771f5b4cd9208f15e0df4c29c74fd849f729249e0"
11
 
12
  API_KEY = os.getenv("API_KEY", "linux.do")
13
 
 
19
  if key != "Bearer "+API_KEY:
20
  return jsonify({"success": False, "message": "Unauthorized: Invalid API key"}), 403
21
 
22
+ @app.route('/v1/models', methods=['GET'])
23
+ def get_models():
24
+ # 构建请求头
25
+ headers = {
26
+ "Content-Type": "application/json",
27
+ "Cookie": _COOKIES
28
+ }
29
+ # 发送请求到Akash API
30
+ response = requests.get(
31
+ 'https://chat.akash.network/api/models',
32
+ headers=headers
33
+ )
34
+ print(response.text)
35
+ return response.json()
36
+
37
 
38
  @app.route('/v1/chat/completions', methods=['POST'])
39
  def chat_completions():