naughtondale commited on
Commit
17fc494
·
1 Parent(s): 04d2dd5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -6,7 +6,10 @@ os.environ['REPLICATE_API_TOKEN'] = 'YOUR_REPLICATE_API_TOKEN'
6
 
7
  replicate_url = 'replicate/llama70b-v2-chat:2d19859030ff705a87c746f7e96eea03aefb71f166725aee39692f1476566d48'
8
 
9
- def ask_llama2(prompt):
 
 
 
10
  output = replicate.run(
11
  replicate_url,
12
  input={'prompt': prompt}
@@ -16,11 +19,12 @@ def ask_llama2(prompt):
16
 
17
  iface = gr.Interface(
18
  fn=ask_llama2,
19
- inputs=gr.inputs.Textbox(label="Type here...", lines=5), # You can adjust the number of lines to display.
20
  outputs=gr.outputs.Textbox(),
21
  live=True,
22
  title="Hugging Face Chatbot",
23
  description="Interact with the Hugging Face Llama v2 chatbot model.",
 
24
  )
25
 
26
  if __name__ == "__main__":
 
6
 
7
  replicate_url = 'replicate/llama70b-v2-chat:2d19859030ff705a87c746f7e96eea03aefb71f166725aee39692f1476566d48'
8
 
9
+ def ask_llama2(user_prompt):
10
+ system_prompt = "You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information."
11
+
12
+ prompt = f"{system_prompt} {user_prompt}"
13
  output = replicate.run(
14
  replicate_url,
15
  input={'prompt': prompt}
 
19
 
20
  iface = gr.Interface(
21
  fn=ask_llama2,
22
+ inputs=gr.inputs.Textbox(label="Type here...", lines=5),
23
  outputs=gr.outputs.Textbox(),
24
  live=True,
25
  title="Hugging Face Chatbot",
26
  description="Interact with the Hugging Face Llama v2 chatbot model.",
27
+ button="Submit",
28
  )
29
 
30
  if __name__ == "__main__":