Nekochu commited on
Commit
919649e
1 Parent(s): 1291e03

Add input id model

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -30,17 +30,17 @@ def load_model(model_id):
30
  if not torch.cuda.is_available():
31
  DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
32
 
33
- if torch.cuda.is_available():
34
- model_id = "Nekochu/Luminia-13B-v3"
35
- model, tokenizer = load_model(model_id)
36
-
37
 
38
  @spaces.GPU(duration=120)
39
  def generate(
 
40
  message: str,
41
  chat_history: list[tuple[str, str]],
42
  system_prompt: str,
43
- model_id: str = "Nekochu/Luminia-13B-v3",
44
  max_new_tokens: int = 1024,
45
  temperature: float = 0.6,
46
  top_p: float = 0.9,
@@ -48,6 +48,7 @@ def generate(
48
  repetition_penalty: float = 1.2,
49
  ) -> Iterator[str]:
50
  model, tokenizer = load_model(model_id)
 
51
  conversation = []
52
  if system_prompt:
53
  conversation.append({"role": "system", "content": system_prompt})
@@ -81,12 +82,14 @@ def generate(
81
  outputs.append(text)
82
  yield "".join(outputs)
83
 
 
 
84
 
85
  chat_interface = gr.ChatInterface(
86
  fn=generate,
87
  additional_inputs=[
 
88
  gr.Textbox(label="System prompt", lines=6),
89
- gr.Textbox(label="Model ID", placeholder="Nekochu/Luminia-13B-v3"),
90
  gr.Slider(
91
  label="Max new tokens",
92
  minimum=1,
@@ -137,4 +140,4 @@ with gr.Blocks(css="style.css") as demo:
137
  gr.Markdown(LICENSE)
138
 
139
  if __name__ == "__main__":
140
- demo.queue(max_size=20).launch()
 
30
  if not torch.cuda.is_available():
31
  DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
32
 
33
+ MODELS = [
34
+ "Nekochu/Luminia-13B-v3",
35
+ "Nekochu/Llama-2-13B-German-ORPO",
36
+ ]
37
 
38
  @spaces.GPU(duration=120)
39
  def generate(
40
+ model_id: str,
41
  message: str,
42
  chat_history: list[tuple[str, str]],
43
  system_prompt: str,
 
44
  max_new_tokens: int = 1024,
45
  temperature: float = 0.6,
46
  top_p: float = 0.9,
 
48
  repetition_penalty: float = 1.2,
49
  ) -> Iterator[str]:
50
  model, tokenizer = load_model(model_id)
51
+
52
  conversation = []
53
  if system_prompt:
54
  conversation.append({"role": "system", "content": system_prompt})
 
82
  outputs.append(text)
83
  yield "".join(outputs)
84
 
85
+ # Combine predefined models into a single placeholder for the textbox
86
+ model_placeholder = "\n".join(MODELS)
87
 
88
  chat_interface = gr.ChatInterface(
89
  fn=generate,
90
  additional_inputs=[
91
+ gr.Textbox(label="Select Model or Enter Custom Model ID", placeholder=model_placeholder),
92
  gr.Textbox(label="System prompt", lines=6),
 
93
  gr.Slider(
94
  label="Max new tokens",
95
  minimum=1,
 
140
  gr.Markdown(LICENSE)
141
 
142
  if __name__ == "__main__":
143
+ demo.queue(max_size=20).launch()