mrbeliever commited on
Commit
1b3c051
1 Parent(s): 1a173be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -1,10 +1,11 @@
1
  from huggingface_hub import InferenceClient
2
  import gradio as gr
 
3
 
4
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
5
 
6
  # Your system prompt
7
- SYSTEM_PROMPT = "ayaour work is to only Enhance and rewrite the this prompt in sentence form without changing the essence"
8
 
9
  def format_prompt(message, history=[]):
10
  prompt = "<s>"
@@ -12,7 +13,9 @@ def format_prompt(message, history=[]):
12
  for user_prompt, bot_response in history:
13
  prompt += f"[INST] {user_prompt} [/INST]"
14
  prompt += f" {bot_response}</s> "
15
- prompt += f"[INST] {message} [/INST]"
 
 
16
  return prompt
17
 
18
  def generate(prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0):
@@ -27,7 +30,6 @@ def generate(prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition
27
  top_p=top_p,
28
  repetition_penalty=repetition_penalty,
29
  do_sample=True,
30
- seed=42,
31
  )
32
 
33
  formatted_prompt = format_prompt(prompt)
@@ -45,7 +47,6 @@ with gr.Blocks() as demo:
45
  submit_button = gr.Button("Generate")
46
  output_text = gr.Textbox(label="Output", interactive=True, lines=10)
47
 
48
-
49
  submit_button.click(fn=generate, inputs=input_text, outputs=output_text)
50
 
51
- demo.launch()
 
1
  from huggingface_hub import InferenceClient
2
  import gradio as gr
3
+ import time
4
 
5
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
6
 
7
  # Your system prompt
8
+ SYSTEM_PROMPT = "your work is to only Enhance and rewrite the this prompt in sentence form without changing the essence"
9
 
10
  def format_prompt(message, history=[]):
11
  prompt = "<s>"
 
13
  for user_prompt, bot_response in history:
14
  prompt += f"[INST] {user_prompt} [/INST]"
15
  prompt += f" {bot_response}</s> "
16
+ # Append a timestamp to ensure uniqueness
17
+ timestamp = time.time()
18
+ prompt += f"[INST] {message} {timestamp} [/INST]"
19
  return prompt
20
 
21
  def generate(prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0):
 
30
  top_p=top_p,
31
  repetition_penalty=repetition_penalty,
32
  do_sample=True,
 
33
  )
34
 
35
  formatted_prompt = format_prompt(prompt)
 
47
  submit_button = gr.Button("Generate")
48
  output_text = gr.Textbox(label="Output", interactive=True, lines=10)
49
 
 
50
  submit_button.click(fn=generate, inputs=input_text, outputs=output_text)
51
 
52
+ demo.launch()