Samuel L Meyers commited on
Commit
908a75d
·
1 Parent(s): 580cbfd

Remove ridiculous accidental background instance

Browse files
Files changed (1) hide show
  1. code/app.py +7 -11
code/app.py CHANGED
@@ -26,7 +26,7 @@ def stowtext(curr, inp):
26
  if len(curr) < 1:
27
  curr.append({
28
  "role": "system",
29
- "content": "You 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."
30
  })
31
  curr.append({
32
  "role": "user",
@@ -61,16 +61,11 @@ def talk(txt, jsn):
61
  if not jsn:
62
  jsn = txt
63
  if not running:
64
- foundSystemPropmpt = False
65
- for msg in txt:
66
- if msg["role"] == "system":
67
- foundSystemPropmpt = True
68
- if not foundSystemPropmpt:
69
- txt.append({
70
- "role": "system",
71
- "content": "You 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."
72
- })
73
- result = lcpp_model.create_chat_completion(messages=txt,stream=True)
74
  running = True
75
  for r in result:
76
  txt2 = None
@@ -78,6 +73,7 @@ def talk(txt, jsn):
78
  txt2 = r["choices"][0]["delta"]["content"]
79
  elif not "content" in r["choices"][0]["delta"] and not "role" in r["choices"][0]["delta"]:
80
  running = False
 
81
  yield txt
82
  if txt2 is not None:
83
  txt = stowchunk(txt, txt2)
 
26
  if len(curr) < 1:
27
  curr.append({
28
  "role": "system",
29
+ "content": "You 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."
30
  })
31
  curr.append({
32
  "role": "user",
 
61
  if not jsn:
62
  jsn = txt
63
  if not running:
64
+ if len(txt) >= 3 and txt[-1]["content"][:-4] == "</s>":
65
+ return txt
66
+ txt = printfmt(stowtext(otxt, txt))
67
+ otxt = txt
68
+ result = lcpp_model.create_chat_completion(messages=txt,stream=True,stop=["[INST]", "<<SYS>>"])
 
 
 
 
 
69
  running = True
70
  for r in result:
71
  txt2 = None
 
73
  txt2 = r["choices"][0]["delta"]["content"]
74
  elif not "content" in r["choices"][0]["delta"] and not "role" in r["choices"][0]["delta"]:
75
  running = False
76
+ txt = stowchunk(txt, "</s>")
77
  yield txt
78
  if txt2 is not None:
79
  txt = stowchunk(txt, txt2)