forked from LibreChat-AI/librechat-config-yaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.py
More file actions
40 lines (33 loc) · 1.02 KB
/
github.py
File metadata and controls
40 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import json
import requests
def fetch_models():
"""Fetch models from GitHub's Azure inference API."""
url = "https://models.inference.ai.azure.com/models"
headers = {
"accept": "application/json"
}
try:
response = requests.get(url, headers=headers)
response.raise_for_status()
data = response.json()
# Extract and sort model names instead of IDs
model_names = sorted([
model['name']
for model in data
if 'name' in model
])
return model_names
except Exception as e:
print(f"Error fetching models: {str(e)}")
return None
def main():
print("Fetching models from GitHub...")
models = fetch_models()
if models:
with open("github.txt", "w") as file:
json.dump(models, file, indent=2)
print(f"Successfully saved {len(models)} models to github.txt")
else:
print("Failed to fetch models.")
if __name__ == "__main__":
main()