radames commited on
Commit
0500e73
·
1 Parent(s): c100b91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -15
app.py CHANGED
@@ -17,26 +17,23 @@ llm = Llama(
17
 
18
  history = []
19
 
20
- pre_prompt = " The user and the AI are having a conversation : <|endoftext|> \n "
 
21
 
 
 
22
 
23
- def generate_text(input_text, history):
24
 
25
- temp = ""
26
- if history == []:
27
- input_text_with_history = (
28
- f"SYSTEM:{pre_prompt}"
29
- + "\n"
30
- + f"USER: {input_text} "
31
- + "\n"
32
- + " ASSISTANT:"
33
- )
34
- else:
35
- input_text_with_history = f"{history[-1][1]}" + "\n"
36
- input_text_with_history += f"USER: {input_text}" + "\n" + " ASSISTANT:"
37
 
38
  output = llm(
39
- input_text_with_history,
40
  temperature=0.15,
41
  top_p=0.1,
42
  top_k=40,
 
17
 
18
  history = []
19
 
20
+ system_message = """
21
+ 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.
22
 
23
+ 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.
24
+ """
25
 
 
26
 
27
+ def generate_text(message, history):
28
+
29
+ input_prompt = f"[INST] <<SYS>>\n{system_message}\n<</SYS>>\n\n "
30
+ for interaction in history:
31
+ input_prompt = input_prompt + str(interaction[0]) + " [/INST] " + str(interaction[1]) + " </s><s> [INST] "
32
+
33
+ input_prompt = input_prompt + str(message) + " [/INST] "
 
 
 
 
 
34
 
35
  output = llm(
36
+ input_prompt,
37
  temperature=0.15,
38
  top_p=0.1,
39
  top_k=40,