expandme commited on
Commit
617316d
·
1 Parent(s): de7b824

List of models ? - What wind.surf will do ?

Browse files
Files changed (1) hide show
  1. app.py +30 -10
app.py CHANGED
@@ -23,20 +23,27 @@ def load_model(model_name):
23
  current_model = Llama.from_pretrained(
24
  repo_id=model_info["repo_id"],
25
  filename=model_info["filename"],
26
- verbose=True,
27
- n_ctx=32768,
28
- n_threads=2,
29
- chat_format="chatml"
30
- )
31
  return current_model
32
 
33
  # Initialize with first model
34
  current_model = load_model(list(MODELS.keys())[0])
35
 
 
 
 
 
 
 
36
  def respond(
37
  message,
38
  history: list[tuple[str, str]],
39
  model_name,
 
40
  system_message,
41
  max_tokens,
42
  temperature,
@@ -47,7 +54,7 @@ def respond(
47
  # Load new model if changed
48
  if current_model is None or model_name != current_model.model_path:
49
  current_model = load_model(model_name)
50
-
51
  messages = [{"role": "system", "content": system_message}]
52
 
53
  for val in history:
@@ -79,13 +86,21 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
79
  demo = gr.ChatInterface(
80
  respond,
81
  title="GGUF is popular format on PC in LM Studio or on Tablet/Mobile in PocketPal APPs",
82
- description="Try models locclay in: 🖥️ [LM Studio AI for PC](https://lmstudio.ai) | 📱 PocketPal AI ([Android](https://play.google.com/store/apps/details?id=com.pocketpalai) & [iOS](https://play.google.com/store/apps/details?id=com.pocketpalai)) on Tablet or Mobile",
83
-
 
 
 
 
 
 
84
  additional_inputs=[
85
  gr.Dropdown(
86
  choices=list(MODELS.keys()),
87
  value=list(MODELS.keys())[0],
88
- label="Select Model"
 
 
89
  ),
90
  gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
91
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
@@ -146,4 +161,9 @@ demo = gr.ChatInterface(
146
 
147
 
148
  if __name__ == "__main__":
149
- demo.launch()
 
 
 
 
 
 
23
  current_model = Llama.from_pretrained(
24
  repo_id=model_info["repo_id"],
25
  filename=model_info["filename"],
26
+ verbose=True,
27
+ n_ctx=32768,
28
+ n_threads=2,
29
+ chat_format="chatml"
30
+ )
31
  return current_model
32
 
33
  # Initialize with first model
34
  current_model = load_model(list(MODELS.keys())[0])
35
 
36
+ def get_description(model_name):
37
+ return f"🤖 Current Model: {model_name}\n\nTry models locclay in: 🖥️ [LM Studio AI for PC](https://lmstudio.ai) | 📱 PocketPal AI ([Android](https://play.google.com/store/apps/details?id=com.pocketpalai) & [iOS](https://play.google.com/store/apps/details?id=com.pocketpalai)) on Tablet or Mobile"
38
+
39
+ def update_description(model_name):
40
+ return get_description(model_name)
41
+
42
  def respond(
43
  message,
44
  history: list[tuple[str, str]],
45
  model_name,
46
+ description_text,
47
  system_message,
48
  max_tokens,
49
  temperature,
 
54
  # Load new model if changed
55
  if current_model is None or model_name != current_model.model_path:
56
  current_model = load_model(model_name)
57
+
58
  messages = [{"role": "system", "content": system_message}]
59
 
60
  for val in history:
 
86
  demo = gr.ChatInterface(
87
  respond,
88
  title="GGUF is popular format on PC in LM Studio or on Tablet/Mobile in PocketPal APPs",
89
+
90
+ gr.Textbox(
91
+ value=get_description(list(MODELS.keys())[0]),
92
+ label="About",
93
+ interactive=False,
94
+ lines=4
95
+ ),
96
+
97
  additional_inputs=[
98
  gr.Dropdown(
99
  choices=list(MODELS.keys()),
100
  value=list(MODELS.keys())[0],
101
+ label="Select Model",
102
+ interactive=False,
103
+ allow_custom_value=False
104
  ),
105
  gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
106
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
 
161
 
162
 
163
  if __name__ == "__main__":
164
+ with gr.Blocks() as blocks:
165
+ chatbot = demo.render()
166
+ model_dropdown = [comp for comp in chatbot.children if isinstance(comp, gr.Dropdown)][0]
167
+ description_box = [comp for comp in chatbot.children if isinstance(comp, gr.Textbox)][0]
168
+ model_dropdown.change(fn=update_description, inputs=[model_dropdown], outputs=[description_box])
169
+ blocks.launch()