AMKCode commited on
Commit
4b54665
1 Parent(s): 9e42583

added HF auth

Browse files
Files changed (1) hide show
  1. app.py +65 -7
app.py CHANGED
@@ -9,15 +9,71 @@ from huggingface_hub import HfApi
9
  from huggingface_hub import ModelCard
10
 
11
  from gradio_huggingfacehub_search import HuggingfaceHubSearch
12
-
13
  from apscheduler.schedulers.background import BackgroundScheduler
14
 
15
- HF_TOKEN = os.environ.get("HF_TOKEN")
16
-
17
  HF_PATH = "https://huggingface.co/"
18
 
19
- def button_click(hf_model_id, conv_template, quantization):
20
- api = HfApi()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  model_dir_name = hf_model_id.split("/")[1]
22
  mlc_model_name = model_dir_name + "-" + quantization + "-" + "MLC"
23
 
@@ -42,13 +98,15 @@ def button_click(hf_model_id, conv_template, quantization):
42
  repo_id=f"{user_name}/{mlc_model_name}",
43
  repo_type="model")
44
 
 
 
45
  return "successful"
46
 
47
  demo = gr.Interface(
48
  fn=button_click,
49
  inputs = [gr.Textbox(label="HF Model ID"),
50
- gr.Dropdown(["tinyllama_v1_0", "qwen2"], label="Conversation Template"),
51
- gr.Dropdown(["q4f16_1", "q4f32_1"], label="Quantization Method")],
52
  outputs = "text"
53
  )
54
 
 
9
  from huggingface_hub import ModelCard
10
 
11
  from gradio_huggingfacehub_search import HuggingfaceHubSearch
 
12
  from apscheduler.schedulers.background import BackgroundScheduler
13
 
 
 
14
  HF_PATH = "https://huggingface.co/"
15
 
16
+ CONV_TEMPLATES = [
17
+ "llama-3",
18
+ "llama-3_1",
19
+ "chatml",
20
+ "chatml_nosystem",
21
+ "qwen2",
22
+ "open_hermes_mistral",
23
+ "neural_hermes_mistral",
24
+ "llama_default",
25
+ "llama-2",
26
+ "mistral_default",
27
+ "gpt2",
28
+ "codellama_completion",
29
+ "codellama_instruct",
30
+ "vicuna_v1.1",
31
+ "conv_one_shot",
32
+ "redpajama_chat",
33
+ "rwkv_world",
34
+ "rwkv",
35
+ "gorilla",
36
+ "gorilla-openfunctions-v2",
37
+ "guanaco",
38
+ "dolly",
39
+ "oasst",
40
+ "stablelm",
41
+ "stablecode_completion",
42
+ "stablecode_instruct",
43
+ "minigpt",
44
+ "moss",
45
+ "LM",
46
+ "stablelm-3b",
47
+ "gpt_bigcode",
48
+ "wizardlm_7b",
49
+ "wizard_coder_or_math",
50
+ "glm",
51
+ "custom", # for web-llm only
52
+ "phi-2",
53
+ "phi-3",
54
+ "phi-3-vision",
55
+ "stablelm-2",
56
+ "gemma_instruction",
57
+ "orion",
58
+ "llava",
59
+ "hermes2_pro_llama3",
60
+ "hermes3_llama-3_1",
61
+ "tinyllama_v1_0",
62
+ "aya-23",
63
+ ]
64
+
65
+ QUANTIZATIONS = ["q0f16",
66
+ "q0f32",
67
+ "q3f16_1",
68
+ "q4f16_1",
69
+ "q4f32_1",
70
+ "q4f16_awq"]
71
+
72
+ def button_click(hf_model_id, conv_template, quantization, oauth_token: gr.OAuthToken | None):
73
+ if not oauth_token.token:
74
+ raise ValueError("Log in to Huggingface to use this")
75
+
76
+ api = HfApi(token=oauth_token.token)
77
  model_dir_name = hf_model_id.split("/")[1]
78
  mlc_model_name = model_dir_name + "-" + quantization + "-" + "MLC"
79
 
 
98
  repo_id=f"{user_name}/{mlc_model_name}",
99
  repo_type="model")
100
 
101
+ os.system("rm -rf dist/")
102
+
103
  return "successful"
104
 
105
  demo = gr.Interface(
106
  fn=button_click,
107
  inputs = [gr.Textbox(label="HF Model ID"),
108
+ gr.Dropdown(CONV_TEMPLATES, label="Conversation Template"),
109
+ gr.Dropdown(QUANTIZATIONS, label="Quantization Method")],
110
  outputs = "text"
111
  )
112