mobinln commited on
Commit
549b996
·
1 Parent(s): 921f71d

add model txt

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -4,6 +4,14 @@ from huggingface_hub import InferenceClient
4
  """
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
 
 
 
 
 
 
 
 
7
 
8
 
9
  def respond(
@@ -15,7 +23,6 @@ def respond(
15
  top_p,
16
  model,
17
  ):
18
- client = InferenceClient(model=model)
19
  messages = [{"role": "system", "content": system_message}]
20
 
21
  for val in history:
@@ -28,6 +35,9 @@ def respond(
28
 
29
  response = ""
30
 
 
 
 
31
  for message in client.chat_completion(
32
  messages,
33
  max_tokens=max_tokens,
@@ -57,7 +67,7 @@ demo = gr.ChatInterface(
57
  step=0.05,
58
  label="Top-p (nucleus sampling)",
59
  ),
60
- gr.Textbox(value="meta-llama/Meta-Llama-3-8B-Instruct", label="Model"),
61
  ],
62
  multimodal=True,
63
  )
 
4
  """
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
+ choices = [
8
+ "meta-llama/Meta-Llama-3-8B-Instruct",
9
+ "microsoft/Phi-3-vision-128k-instruct",
10
+ "Qwen/Qwen2-0.5B-Instruct",
11
+ ]
12
+ client1 = InferenceClient(model=choices[0])
13
+ client2 = InferenceClient(model=choices[1])
14
+ client3 = InferenceClient(model=choices[2])
15
 
16
 
17
  def respond(
 
23
  top_p,
24
  model,
25
  ):
 
26
  messages = [{"role": "system", "content": system_message}]
27
 
28
  for val in history:
 
35
 
36
  response = ""
37
 
38
+ client = (
39
+ client1 if model == choices[0] else client2 if model == choices[1] else client3
40
+ )
41
  for message in client.chat_completion(
42
  messages,
43
  max_tokens=max_tokens,
 
67
  step=0.05,
68
  label="Top-p (nucleus sampling)",
69
  ),
70
+ gr.Dropdown(choices=choices, value=choices[0], label="Model"),
71
  ],
72
  multimodal=True,
73
  )