awacke1 commited on
Commit
2daaaf3
·
1 Parent(s): d6a03a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -203,18 +203,16 @@ def predict(inputs, top_p, temperature, chat_counter, chatbot=[], history=[]):
203
  # TODO - make this parse out markdown so we can have similar interface
204
  counter=0
205
  for chunk in response.iter_lines():
206
- #Skipping first chunk
207
  if counter == 0:
208
  counter+=1
209
  continue
210
- #counter+=1
211
- # check whether each line is non-empty
212
  if chunk.decode() :
213
  chunk = chunk.decode()
214
- # decode each line as response data is in bytes
215
- if len(chunk) > 12 and "content" in json.loads(chunk[6:])['choices'][0]['delta']:
216
- #if len(json.loads(chunk.decode()[6:])['choices'][0]["delta"]) == 0:
217
- # break
218
  partial_words = partial_words + json.loads(chunk[6:])['choices'][0]["delta"]["content"]
219
  if token_counter == 0:
220
  history.append(" " + partial_words)
@@ -225,11 +223,11 @@ def predict(inputs, top_p, temperature, chat_counter, chatbot=[], history=[]):
225
 
226
 
227
 
228
- df=pd.DataFrame()
229
- if UseMemory:
230
- outputfileName = 'ChatGPT-RLHF-Memory.csv' # Test first time file create
231
- df = store_message(chat, history, outputfileName) # Save to dataset
232
- basedir = get_base(outputfileName)
233
  #return history, df, basedir
234
 
235
 
 
203
  # TODO - make this parse out markdown so we can have similar interface
204
  counter=0
205
  for chunk in response.iter_lines():
206
+
207
  if counter == 0:
208
  counter+=1
209
  continue
210
+
 
211
  if chunk.decode() :
212
  chunk = chunk.decode()
213
+
214
+ if len(chunk) > 12 and "content" in json.loads(chunk[6:])['choices'][0]['delta']:
215
+
 
216
  partial_words = partial_words + json.loads(chunk[6:])['choices'][0]["delta"]["content"]
217
  if token_counter == 0:
218
  history.append(" " + partial_words)
 
223
 
224
 
225
 
226
+ #df=pd.DataFrame()
227
+ #if UseMemory:
228
+ # outputfileName = 'ChatGPT-RLHF-Memory.csv' # Test first time file create
229
+ # df = store_message(chat, history, outputfileName) # Save to dataset
230
+ # basedir = get_base(outputfileName)
231
  #return history, df, basedir
232
 
233