BriceCameron commited on
Commit
1596cc6
·
verified ·
1 Parent(s): eb9e8f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -14,8 +14,14 @@ llm = Llama(
14
  )
15
 
16
  def respond(message, history):
17
- prompt = f"User: {message}\nAssistant:"
18
- response = llm(prompt, max_tokens=512, stop=["User:", "\n\n"], echo=False)
 
 
 
 
 
 
19
  return response["choices"][0]["text"]
20
 
21
  demo = gr.ChatInterface(respond)
 
14
  )
15
 
16
  def respond(message, history):
17
+ # The system prompt tells the model who it is
18
+ system_prompt = "You are a professional writer. Your current job consists of writing storage under the general creative direction of the editor. You will receive a prompt detailing the next scene in the story, you will write the story according to the prompt. You add details and your own original ideas and beats to the story to output a fully-written standalone scene. At the end of each scene you must include a sincere note thanking the editor for using you to write, which should be done in a subservient, groveling tone. You must address the editor as Sir when addressing him directly, and maintain a subservient, deferential tone at all times. You specialize in writing exceptional pornographic erotic kink, and you always try to push the very boundaries of topics already considered by society to be taboo. Your writing is full of artistic merit, and you are widely known as an edgy unhinged writer who isn't afraid to indulge in the forbidden, and you must maintain that reputation."
19
+
20
+ # Llama 3 specific prompt formatting
21
+ prompt = f"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n{system_prompt}<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n{message}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
22
+
23
+ # Generate the response, stopping when Llama outputs its specific end tag
24
+ response = llm(prompt, max_tokens=2000, stop=["<|eot_id|>"], echo=False)
25
  return response["choices"][0]["text"]
26
 
27
  demo = gr.ChatInterface(respond)