mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-20 02:24:59 +00:00
feat(scripts): add scripts to help adding new models to the gallery (#2789)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
6886e4e5ab
commit
bb063ab78a
2 changed files with 148 additions and 0 deletions
35
scripts/latest_hf.py
Normal file
35
scripts/latest_hf.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
## Gets latest GGUF models from HF:
|
||||
## Example:
|
||||
## local-ai run hermes-2-theta-llama-3-8b
|
||||
## OPENAI_BASE_URL="http://192.168.xx.xx:8080" python scripts/latest_hf.py
|
||||
|
||||
import requests
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
# get current directory where the script is
|
||||
current_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
def get_latest_model():
|
||||
search_term = "GGUF"
|
||||
if sys.argv[1]:
|
||||
search_term = sys.argv[1]
|
||||
url = "https://huggingface.co/api/models"
|
||||
params = {"sort": "lastModified", "direction": -1, "limit": 30, "search": search_term}
|
||||
response = requests.get(url, params=params)
|
||||
|
||||
if response.status_code == 200:
|
||||
models = response.json()
|
||||
if models:
|
||||
for model in models:
|
||||
print(f"Model: {model['modelId']}")
|
||||
subprocess.run(["python", current_dir+"/model_gallery_info.py", model['modelId']])
|
||||
|
||||
else:
|
||||
print("No models found.")
|
||||
else:
|
||||
print(f"Failed to fetch models. Status code: {response.status_code}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_latest_model()
|
Loading…
Add table
Add a link
Reference in a new issue