mrbeliever commited on
Commit
f214084
1 Parent(s): f06f884

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
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 = "You are a prompt enhancer and your work is to enhance the given prompt under 100 words without changing the essence, only write the enhance prompt and nothing else"
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):
@@ -44,7 +47,6 @@ with gr.Blocks() as demo:
44
  submit_button = gr.Button("Generate")
45
  output_text = gr.Textbox(label="Output", interactive=True, lines=10)
46
 
47
-
48
  submit_button.click(fn=generate, inputs=input_text, outputs=output_text)
49
 
50
- 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 = "You are a prompt enhancer and your work is to enhance the given prompt under 100 words without changing the essence, only write the enhanced prompt and nothing else."
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):
 
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()