Spaces:
Sleeping
Sleeping
ts
Browse files
app.py
CHANGED
@@ -8,30 +8,47 @@ import os
|
|
8 |
logging.basicConfig(level=logging.INFO)
|
9 |
|
10 |
def get_model_info(model_id="Qwen/Qwen2-7B-Instruct", hf_token=os.getenv('HF_TOKEN')):
|
11 |
-
url = f"https://huggingface.co/api/
|
12 |
-
|
13 |
-
"
|
14 |
-
"
|
15 |
-
"
|
16 |
-
"
|
|
|
17 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
logging.info(f"Requesting model info for model ID: {model_id}")
|
20 |
-
logging.info(f"URL: {url}")
|
21 |
|
22 |
-
response = requests.get(url, headers=headers)
|
23 |
|
24 |
-
logging.info(f"Response Status: {response.status_code}")
|
25 |
-
logging.info(f"Response Headers: {response.headers}")
|
26 |
-
logging.info(f"Response Text: {response.text}")
|
27 |
|
28 |
-
if response.status_code != 200:
|
29 |
-
|
30 |
-
|
31 |
|
32 |
-
data = response.json()
|
33 |
-
logging.info("Successfully retrieved model info.")
|
34 |
-
return json.dumps(data, indent=4)
|
35 |
|
36 |
iface = gr.Interface(
|
37 |
fn=lambda model_id: get_model_info(model_id, hf_token=os.getenv('HF_TOKEN')),
|
|
|
8 |
logging.basicConfig(level=logging.INFO)
|
9 |
|
10 |
def get_model_info(model_id="Qwen/Qwen2-7B-Instruct", hf_token=os.getenv('HF_TOKEN')):
|
11 |
+
url = f"https://huggingface.co/api/models"
|
12 |
+
params = {
|
13 |
+
"limit": 5,
|
14 |
+
"pipeline_tag": "text-generation",
|
15 |
+
"sort": "likes30d",
|
16 |
+
"full": "True",
|
17 |
+
"config": "True"
|
18 |
}
|
19 |
+
|
20 |
+
headers = {}
|
21 |
+
if hf_token:
|
22 |
+
headers["Authorization"] = f"Bearer {hf_token}"
|
23 |
+
try:
|
24 |
+
response = requests.get(url, params=params, headers=headers)
|
25 |
+
except requests.exceptions.RequestException as e:
|
26 |
+
print(f"Error fetching data for task text-generation: {e}")
|
27 |
+
return None
|
28 |
+
data = response.json()
|
29 |
+
return json.dumps(data, indent=4)
|
30 |
+
|
31 |
+
# url = f"https://huggingface.co/api/integrations/aws/v1/lookup/{model_id}"
|
32 |
+
# headers = {
|
33 |
+
# "Authorization": f"Bearer {hf_token}",
|
34 |
+
# }
|
35 |
|
36 |
+
# logging.info(f"Requesting model info for model ID: {model_id}")
|
37 |
+
# logging.info(f"URL: {url}")
|
38 |
|
39 |
+
# response = requests.get(url, headers=headers)
|
40 |
|
41 |
+
# logging.info(f"Response Status: {response.status_code}")
|
42 |
+
# logging.info(f"Response Headers: {response.headers}")
|
43 |
+
# logging.info(f"Response Text: {response.text}")
|
44 |
|
45 |
+
# if response.status_code != 200:
|
46 |
+
# logging.error(f"Error: {response.status_code} - {response.text}")
|
47 |
+
# return f"Error: {response.status_code}\\nResponse: {response.text}"
|
48 |
|
49 |
+
# data = response.json()
|
50 |
+
# logging.info("Successfully retrieved model info.")
|
51 |
+
# return json.dumps(data, indent=4)
|
52 |
|
53 |
iface = gr.Interface(
|
54 |
fn=lambda model_id: get_model_info(model_id, hf_token=os.getenv('HF_TOKEN')),
|