Samuel L Meyers commited on
Commit
7af60f5
·
1 Parent(s): b90a389

Try to fix prompts v2

Browse files
Files changed (1) hide show
  1. code/app.py +8 -4
code/app.py CHANGED
@@ -3,6 +3,7 @@ import logging
3
  from ctransformers import AutoModelForCausalLM
4
 
5
  import gradio as gr
 
6
 
7
  from huggingface_hub import hf_hub_download
8
 
@@ -36,6 +37,7 @@ def stowchunk(curr, inp):
36
  curr.append({
37
  "role": "assistant",
38
  "content": inp,
 
39
  })
40
  else:
41
  curr[-1]["content"] += inp
@@ -84,11 +86,13 @@ def talk(txt, jsn):
84
  if txt2 is not None:
85
  txt3 = txt
86
  txt = stowchunk(txt, txt2)
87
- if not echoed and txt[-1]["content"].contains(jsn2prompt([txt3[-1]])):
88
- echoed = True
 
 
89
  yield txt
90
- elif not echoed and txt[-1]["role"] != "assistant":
91
- txt[-1]["content"] = "*Thinking*"
92
  yield txt
93
  yield txt
94
  yield txt
 
3
  from ctransformers import AutoModelForCausalLM
4
 
5
  import gradio as gr
6
+ import json
7
 
8
  from huggingface_hub import hf_hub_download
9
 
 
37
  curr.append({
38
  "role": "assistant",
39
  "content": inp,
40
+ "echoed": False,
41
  })
42
  else:
43
  curr[-1]["content"] += inp
 
86
  if txt2 is not None:
87
  txt3 = txt
88
  txt = stowchunk(txt, txt2)
89
+ print(json.dumps(txt))
90
+ if (not "echoed" in txt[-1] or not txt[-1]["echoed"]) and txt[-1]["content"].contains(jsn2prompt([txt3[-1]])):
91
+ txt[-1]["echoed"] = True
92
+ txt[-1]["content"] = ""
93
  yield txt
94
+ elif (not "echoed" in txt[-1] or not txt[-1]["echoed"]) and not txt[-1]["content"].contains("*Loading*"):
95
+ txt[-1]["content"] = "*Loading*"
96
  yield txt
97
  yield txt
98
  yield txt