botsi commited on
Commit
48dc35c
·
verified ·
1 Parent(s): 1d1ea50

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -296,7 +296,6 @@ def generate(
296
  for user, assistant in chat_history:
297
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
298
  conversation.append({"role": "user", "content": message})
299
- print(f"chat history after the appending happened: {chat_history}")
300
 
301
  input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
302
  if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
@@ -333,9 +332,9 @@ def generate(
333
  # Fix bug that last answer is not recorded!
334
  # Parse the outputs into a readable sentence and record them
335
  # Filter out empty strings and join the remaining strings with spaces
336
- readable_sentence = ' '.join(filter(lambda x: x.strip(), outputs))
337
  # Print the readable sentence
338
- print(readable_sentence)
339
 
340
  # Save chat history to .csv file on HuggingFace Hub
341
  #pd.DataFrame(conversation).to_csv(DATA_FILE, index=False)
@@ -367,7 +366,7 @@ def generate(
367
 
368
  # Save chat history to .csv file on HuggingFace Hub
369
  # Generate filename with bot id and session id
370
- filename = f"{session_index}_{onPage}{DATA_FILENAME}"
371
  data_file = os.path.join(DATA_DIRECTORY, filename)
372
 
373
  # Generate timestamp
@@ -380,7 +379,7 @@ def generate(
380
 
381
  # Add timestamp column
382
  conversation_df = pd.DataFrame(conversation)
383
- conversation_df['readable_sentence'] = readable_sentence
384
  conversation_df['timestamp'] = timestamp
385
 
386
  # Append new conversation to existing data
@@ -389,7 +388,7 @@ def generate(
389
  else:
390
  # If file doesn't exist, create new file with conversation data
391
  conversation_df = pd.DataFrame(conversation)
392
- conversation_df['readable_sentence'] = readable_sentence
393
  conversation_df['timestamp'] = timestamp
394
  conversation_df.to_csv(data_file, index=False)
395
 
 
296
  for user, assistant in chat_history:
297
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
298
  conversation.append({"role": "user", "content": message})
 
299
 
300
  input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
301
  if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
 
332
  # Fix bug that last answer is not recorded!
333
  # Parse the outputs into a readable sentence and record them
334
  # Filter out empty strings and join the remaining strings with spaces
335
+ #readable_sentence = ' '.join(filter(lambda x: x.strip(), outputs))
336
  # Print the readable sentence
337
+ #print(readable_sentence)
338
 
339
  # Save chat history to .csv file on HuggingFace Hub
340
  #pd.DataFrame(conversation).to_csv(DATA_FILE, index=False)
 
366
 
367
  # Save chat history to .csv file on HuggingFace Hub
368
  # Generate filename with bot id and session id
369
+ filename = f"{session_index}_{onPage}_{DATA_FILENAME}"
370
  data_file = os.path.join(DATA_DIRECTORY, filename)
371
 
372
  # Generate timestamp
 
379
 
380
  # Add timestamp column
381
  conversation_df = pd.DataFrame(conversation)
382
+ #conversation_df['readable_sentence'] = readable_sentence
383
  conversation_df['timestamp'] = timestamp
384
 
385
  # Append new conversation to existing data
 
388
  else:
389
  # If file doesn't exist, create new file with conversation data
390
  conversation_df = pd.DataFrame(conversation)
391
+ #conversation_df['readable_sentence'] = readable_sentence
392
  conversation_df['timestamp'] = timestamp
393
  conversation_df.to_csv(data_file, index=False)
394