vaugheu commited on
Commit
57a93d6
1 Parent(s): 5fcb534

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -27
app.py CHANGED
@@ -1,29 +1,27 @@
1
  from huggingface_hub import InferenceClient
2
  import gradio as gr
3
 
4
- # Define the initial model
5
- initial_model_name = "mistralai/Mixtral-8x7B-Instruct-v0.1"
 
 
6
 
7
  def format_prompt(message, history):
8
- prompt = "<s>"
9
- for user_prompt, bot_response in history:
10
- prompt += f"[INST] {user_prompt} [/INST]"
11
- prompt += f" {bot_response}</s> "
12
- prompt += f"[INST] {message} [/INST]"
13
- return prompt
14
 
15
  def generate(
16
  prompt, history, temperature=0.9, max_new_tokens=1024, top_p=0.95, repetition_penalty=1.0,
17
- model_name=None
18
  ):
19
  temperature = float(temperature)
20
  if temperature < 1e-2:
21
  temperature = 1e-2
22
  top_p = float(top_p)
23
 
24
- # Initialize the InferenceClient with the selected model
25
- client = InferenceClient(model_name)
26
-
27
  generate_kwargs = dict(
28
  temperature=temperature,
29
  max_new_tokens=max_new_tokens,
@@ -43,8 +41,8 @@ def generate(
43
  yield output
44
  return output
45
 
 
46
  additional_inputs=[
47
- gr.Textbox(label="Model Name", value=initial_model_name, placeholder="Enter model name here"),
48
  gr.Slider(
49
  label="Temperature",
50
  value=0.9,
@@ -83,18 +81,9 @@ additional_inputs=[
83
  )
84
  ]
85
 
86
- gr.Interface(
87
  fn=generate,
88
- inputs=dict(
89
- Message=gr.components.Textbox(lines=1, placeholer='Your message'),
90
- History=gr.components.State(value=[(current_context['assistant']['last'], current_context['human']['last'])]),
91
- Temperature=additional_inputs[0],
92
- MaxNewTokens=additional_inputs[1],
93
- TopP=additional_inputs[2],
94
- RepetitionPenalty=additional_inputs[3],
95
- ModelName=additional_inputs[4],
96
- ),
97
- outputs="text",
98
- title="Interactive Chat with AI Models",
99
- description="Type a message and see the AI's response. Adjust parameters to change the behavior.",
100
- ).launch()
 
1
  from huggingface_hub import InferenceClient
2
  import gradio as gr
3
 
4
+ client = InferenceClient(
5
+ 'pthornton614/CodeLama-7b-Instruct'
6
+ )
7
+
8
 
9
  def format_prompt(message, history):
10
+ prompt = "<s>"
11
+ for user_prompt, bot_response in history:
12
+ prompt += f"[INST] {user_prompt} [/INST]"
13
+ prompt += f" {bot_response}</s> "
14
+ prompt += f"[INST] {message} [/INST]"
15
+ return prompt
16
 
17
  def generate(
18
  prompt, history, temperature=0.9, max_new_tokens=1024, top_p=0.95, repetition_penalty=1.0,
 
19
  ):
20
  temperature = float(temperature)
21
  if temperature < 1e-2:
22
  temperature = 1e-2
23
  top_p = float(top_p)
24
 
 
 
 
25
  generate_kwargs = dict(
26
  temperature=temperature,
27
  max_new_tokens=max_new_tokens,
 
41
  yield output
42
  return output
43
 
44
+
45
  additional_inputs=[
 
46
  gr.Slider(
47
  label="Temperature",
48
  value=0.9,
 
81
  )
82
  ]
83
 
84
+ gr.ChatInterface(
85
  fn=generate,
86
+ chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, layout="panel"),
87
+ additional_inputs=additional_inputs,
88
+ title="""Mixtral-8x7B"""
89
+ ).queue().launch(show_api=True)