philschmid HF staff commited on
Commit
dc74d38
1 Parent(s): d267798

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -12
app.py CHANGED
@@ -12,28 +12,64 @@ subprocess.run(command, shell=True, check=True)
12
 
13
  import json
14
  import gradio as gr
15
- from recommender.main import get_recommendation
16
 
17
- def greet(model_id):
18
- configs = get_recommendation(model_id)
 
 
 
19
  return json.dumps(configs)
20
 
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  demo = gr.Interface(
23
  fn=greet,
 
24
  inputs=[
25
  gr.Textbox(label="Model ID", placeholder="meta-llama/Llama-2-7b-chat-hf"),
26
- # gr.Slider(
27
- # step=4000,
28
- # minimum=16_000,
29
- # maximum=640_000,
30
- # value=24_000,
31
- # label="GPU memory",
32
- # info="Select how much GPU memory you have available",
33
- # ),
 
 
 
 
 
 
 
 
34
  ],
 
35
  outputs=[gr.JSON()],
36
  )
37
 
38
  demo.launch()
39
-
 
12
 
13
  import json
14
  import gradio as gr
15
+ from recommender.main import get_tgi_config
16
 
17
+
18
+ def greet(model_id, gpu_memory, num_gpus):
19
+ configs = get_tgi_config(model_id, gpu_memory, num_gpus)
20
+ if configs is None:
21
+ return json.dumps({"error": f"Couldn't generate TGI config for {model_id}"})
22
  return json.dumps(configs)
23
 
24
 
25
+ theme = gr.themes.Monochrome(
26
+ primary_hue="indigo",
27
+ secondary_hue="blue",
28
+ neutral_hue="slate",
29
+ radius_size=gr.themes.sizes.radius_sm,
30
+ font=[
31
+ gr.themes.GoogleFont("Open Sans"),
32
+ "ui-sans-serif",
33
+ "system-ui",
34
+ "sans-serif",
35
+ ],
36
+ )
37
+ DESCRIPTION = """
38
+ <div style="text-align: center; max-width: 650px; margin: 0 auto; display:grid; gap:25px;">
39
+ <h1 style="font-weight: 900; margin-bottom: 7px;margin-top:5px">
40
+ Hugging Face TGI Configuration Creator
41
+ </h1>
42
+ <p style="margin-bottom: 10px; font-size: 94%; line-height: 23px;">
43
+ This Space helps you generate and validate Hugging Face TGI configurations for your model. Provide you model ID and the amount of GPU memory you have available and we will generate a configuration for you, which you can use to run your model on TGI.
44
+ </p>
45
+ </div>
46
+ """
47
+
48
+
49
  demo = gr.Interface(
50
  fn=greet,
51
+ description=DESCRIPTION,
52
  inputs=[
53
  gr.Textbox(label="Model ID", placeholder="meta-llama/Llama-2-7b-chat-hf"),
54
+ gr.Slider(
55
+ step=4,
56
+ minimum=16,
57
+ maximum=640,
58
+ value=24,
59
+ label="GPU memory",
60
+ info="Select how much GPU memory you have available",
61
+ ),
62
+ gr.Slider(
63
+ step=1,
64
+ minimum=1,
65
+ maximum=8,
66
+ value=1,
67
+ label="# of GPUs",
68
+ info="Select how many GPUs you have available",
69
+ ),
70
  ],
71
+ theme=theme,
72
  outputs=[gr.JSON()],
73
  )
74
 
75
  demo.launch()