andyaii commited on
Commit
e7f458d
1 Parent(s): 1d13cd2
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -5,14 +5,17 @@ client = InferenceClient(
5
  "mistralai/Mistral-7B-Instruct-v0.3"
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=256, top_p=0.95, repetition_penalty=1.0,
@@ -41,7 +44,6 @@ def generate(
41
  yield output
42
  return output
43
 
44
-
45
  additional_inputs=[
46
  gr.Slider(
47
  label="Temperature",
@@ -81,10 +83,9 @@ additional_inputs=[
81
  )
82
  ]
83
 
84
-
85
  gr.ChatInterface(
86
  fn=generate,
87
  chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
88
  additional_inputs=additional_inputs,
89
- title="""Mistral 7B v0.3"""
90
  ).launch(show_api=False)
 
5
  "mistralai/Mistral-7B-Instruct-v0.3"
6
  )
7
 
8
+ # Your system prompt
9
+ SYSTEM_PROMPT = "You are an intelligent assistant. Please provide useful and concise answers.\n"
10
 
11
  def format_prompt(message, history):
12
+ prompt = "<s>"
13
+ prompt += f"[INST] SYSTEM: {SYSTEM_PROMPT} [/INST]" # Add the system prompt here
14
+ for user_prompt, bot_response in history:
15
+ prompt += f"[INST] {user_prompt} [/INST]"
16
+ prompt += f" {bot_response}</s> "
17
+ prompt += f"[INST] {message} [/INST]"
18
+ return prompt
19
 
20
  def generate(
21
  prompt, history, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,
 
44
  yield output
45
  return output
46
 
 
47
  additional_inputs=[
48
  gr.Slider(
49
  label="Temperature",
 
83
  )
84
  ]
85
 
 
86
  gr.ChatInterface(
87
  fn=generate,
88
  chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
89
  additional_inputs=additional_inputs,
90
+ title="""AI Paragraph Generator"""
91
  ).launch(show_api=False)