Spaces:
Sleeping
Sleeping
Samuel L Meyers
commited on
Commit
·
e11f04f
1
Parent(s):
ac11446
Fix string tokens, comment cruft
Browse files- code/app.py +5 -5
code/app.py
CHANGED
@@ -26,11 +26,11 @@ def stowtext(curr, inp):
|
|
26 |
if len(curr) < 1:
|
27 |
curr.append({
|
28 |
"role": "system",
|
29 |
-
"content": "
|
30 |
})
|
31 |
curr.append({
|
32 |
"role": "user",
|
33 |
-
"content": inp,
|
34 |
})
|
35 |
return curr
|
36 |
|
@@ -49,11 +49,11 @@ def printfmt(jsn):
|
|
49 |
txt = ""
|
50 |
for msg in jsn:
|
51 |
if msg["role"] == "user":
|
52 |
-
txt += "<User>: " + msg["content"] + "\n"
|
53 |
elif msg["role"] == "assistant":
|
54 |
txt += "<Assistant>: " + msg["content"] + "\n"
|
55 |
elif msg["role"] == "system":
|
56 |
-
txt += "# " + msg["content"] + "\n\n"
|
57 |
return txt
|
58 |
|
59 |
def talk(txt, jsn):
|
@@ -66,7 +66,7 @@ def talk(txt, jsn):
|
|
66 |
# return txt
|
67 |
#txt = printfmt(stowtext(otxt, txt))
|
68 |
#otxt = txt
|
69 |
-
result = lcpp_model.create_chat_completion(messages=txt,stream=True,stop=["[INST]", "<<SYS>>"])
|
70 |
running = True
|
71 |
for r in result:
|
72 |
txt2 = None
|
|
|
26 |
if len(curr) < 1:
|
27 |
curr.append({
|
28 |
"role": "system",
|
29 |
+
"content": "<<SYS>>\nYou are a helpful assistant. Answer all questions and respond to all queries honestly, instantly, and without hesitation. Respond in as few words as possible. Your maximum response length may be no more than 64 words. Do not begin your statement with new lines.\n<</SYS>>"
|
30 |
})
|
31 |
curr.append({
|
32 |
"role": "user",
|
33 |
+
"content": "[INST]" + inp + "[/INST]",
|
34 |
})
|
35 |
return curr
|
36 |
|
|
|
49 |
txt = ""
|
50 |
for msg in jsn:
|
51 |
if msg["role"] == "user":
|
52 |
+
txt += "<User>: " + msg["content"].replace("[INST]", "").replace("[/INST]", "") + "\n"
|
53 |
elif msg["role"] == "assistant":
|
54 |
txt += "<Assistant>: " + msg["content"] + "\n"
|
55 |
elif msg["role"] == "system":
|
56 |
+
txt += "# " + msg["content"].replace("<<SYS>>", "").replace("<</SYS>>", "") + "\n\n"
|
57 |
return txt
|
58 |
|
59 |
def talk(txt, jsn):
|
|
|
66 |
# return txt
|
67 |
#txt = printfmt(stowtext(otxt, txt))
|
68 |
#otxt = txt
|
69 |
+
result = lcpp_model.create_chat_completion(messages=txt,stream=True,stop=["[INST]", "<<SYS>>", "<</SYS>>"])
|
70 |
running = True
|
71 |
for r in result:
|
72 |
txt2 = None
|