CaioXapelaum commited on
Commit
1dab2e6
·
verified ·
1 Parent(s): 62ab9b7

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +21 -0
main.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import httpx
3
+ from flask import Flask, jsonify
4
+
5
+ app = Flask(__name__)
6
+
7
+ @app.route('/v1/models')
8
+ def index():
9
+ modelsraw = httpx.get('https://huggingface.co/models-json?inference=warm&sort=trending&withCount=true')
10
+ models = json.loads(modelsraw.text)
11
+ output = []
12
+ for key in models['models']:
13
+ if key['private'] == False and key['gated'] == False:
14
+ output.append({
15
+ "created": 0,
16
+ "id": key['id'],
17
+ "object": "model",
18
+ "owned_by": key['author'],
19
+ "pipeline": key['pipeline_tag']
20
+ })
21
+ return jsonify(output)