Dorjzodovsuren commited on
Commit
a062fa4
·
1 Parent(s): 51feb47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -26
app.py CHANGED
@@ -5,18 +5,16 @@ client = InferenceClient(
5
  "mistralai/Mixtral-8x7B-Instruct-v0.1"
6
  )
7
 
8
-
9
  def format_prompt(message, history):
10
- system = "<|system|>\nYou are a helpful virtual assistant that answer user's question with easy to understand words.</s>\n"
11
- prompt = ""
12
- for user_prompt, bot_response in history:
13
- prompt += f"<|user|>\n{user_prompt}</s>\n"
14
- prompt += f"<|assistant|>\n{bot_response}</s>\n"
15
- prompt += f"<|user|>\n{message}</s>\n"
16
- return prompt
17
 
18
  def generate(
19
- prompt, history, temperature=0.9, max_new_tokens=500, top_p=0.95, repetition_penalty=1.0,
20
  ):
21
  temperature = float(temperature)
22
  if temperature < 1e-2:
@@ -82,21 +80,10 @@ additional_inputs=[
82
  )
83
  ]
84
 
85
- css = """
86
- #mkd {
87
- height: 500px;
88
- overflow: auto;
89
- border: 1px solid #ccc;
90
- }
91
- """
92
-
93
- with gr.Blocks(css=css) as inf:
94
- gr.HTML("<h1><center>zephyr-7b-alpha<h1><center>")
95
- gr.HTML("<h3><center>In this demo, you can chat with <a href='https://huggingface.co/HuggingFaceH4/zephyr-7b-alpha'>zephyr-7b-alpha</a> model. 💬<h3><center>")
96
- gr.ChatInterface(
97
- generate,
98
- additional_inputs=additional_inputs,
99
- examples=[["Can squirrel swims?"], ["Write a poem about squirrel."]]
100
- )
101
 
102
- inf.queue().launch()
 
 
 
 
 
 
5
  "mistralai/Mixtral-8x7B-Instruct-v0.1"
6
  )
7
 
 
8
  def format_prompt(message, history):
9
+ prompt = "<s>"
10
+ for user_prompt, bot_response in history:
11
+ prompt += f"[INST] {user_prompt} [/INST]"
12
+ prompt += f" {bot_response}</s> "
13
+ prompt += f"[INST] {message} [/INST]"
14
+ return prompt
 
15
 
16
  def generate(
17
+ prompt, history, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,
18
  ):
19
  temperature = float(temperature)
20
  if temperature < 1e-2:
 
80
  )
81
  ]
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
+ gr.ChatInterface(
85
+ fn=generate,
86
+ chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
87
+ additional_inputs=additional_inputs,
88
+ title="Mixtral 46.7B"
89
+ ).launch(show_api=True)