philschmid HF staff commited on
Commit
d521aaf
1 Parent(s): 65db30c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### INSTALL LIB
2
+ import subprocess
3
+ import os
4
+ token = os.environ.get("GITHUB_TOKEN", None)
5
+ if not token:
6
+ raise ValueError("Token not found")
7
+
8
+ # Build the install command
9
+ command = f"pip install git+https://x-access-token:{token}:x-oauth-basic@github.com/philschmid/model-recommender.git"
10
+ subprocess.run(command, shell=True, check=True)
11
+ #### INSTALL LIB
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):
19
+ config = get_tgi_config(model_id, gpu_memory)
20
+ return json.dumps(config)
21
+
22
+
23
+ demo = gr.Interface(
24
+ fn=greet,
25
+ inputs=[
26
+ gr.Textbox(label="Model ID", placeholder="meta-llama/Llama-2-7b-chat-hf"),
27
+ gr.Slider(
28
+ step=4000,
29
+ minimum=16_000,
30
+ maximum=640_000,
31
+ value=24_000,
32
+ label="GPU memory",
33
+ info="Select how much GPU memory you have available",
34
+ ),
35
+ ],
36
+ outputs=[gr.JSON()],
37
+ )
38
+
39
+ demo.launch()