Namitg02 commited on
Commit
77ec484
·
verified ·
1 Parent(s): b25d43b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -16,10 +16,7 @@ import os
16
  HF_TOKEN = os.getenv('HF_Token')
17
  #Log_Path="./Logfolder"
18
  logfile = 'DiabetesChatLog.txt'
19
- historylog = [{
20
- "Prompt": '',
21
- "Output": ''
22
- }]
23
 
24
  data = load_dataset("Namitg02/Test", split='train', streaming=False)
25
  #Returns a list of dictionaries, each representing a row in the dataset.
@@ -90,8 +87,12 @@ def format_prompt(prompt,retrieved_documents,k,history,memory_limit=3):
90
  for user_message, bot_message in history[0:]:
91
  PROMPT += f"<s>[INST] {user_message} [/INST] {bot_message} </s>"
92
  print("checkwthhist2")
93
- print(PROMPT)
94
- return PROMPT
 
 
 
 
95
 
96
 
97
  # Called by talk function to add retrieved documents to the prompt. Keeps adding text of retrieved documents to string that are retreived
@@ -104,6 +105,7 @@ def talk(prompt, history):
104
  formatted_prompt = format_prompt(prompt,retrieved_documents,k,history,memory_limit=3) # create a new prompt using the retrieved documents
105
  print("check5")
106
  pd.options.display.max_colwidth = 4000
 
107
  # print(retrieved_documents['0'])
108
  # print(formatted_prompt)
109
  # formatted_prompt_with_history = add_history(formatted_prompt, history)
 
16
  HF_TOKEN = os.getenv('HF_Token')
17
  #Log_Path="./Logfolder"
18
  logfile = 'DiabetesChatLog.txt'
19
+ historylog = []
 
 
 
20
 
21
  data = load_dataset("Namitg02/Test", split='train', streaming=False)
22
  #Returns a list of dictionaries, each representing a row in the dataset.
 
87
  for user_message, bot_message in history[0:]:
88
  PROMPT += f"<s>[INST] {user_message} [/INST] {bot_message} </s>"
89
  print("checkwthhist2")
90
+
91
+ for user_message, bot_message in history[0:]:
92
+ historylog += f"<s>[INST] {user_message} [/INST] {bot_message} </s>"
93
+
94
+ print(historylog)
95
+ return PROMPT, historylog
96
 
97
 
98
  # Called by talk function to add retrieved documents to the prompt. Keeps adding text of retrieved documents to string that are retreived
 
105
  formatted_prompt = format_prompt(prompt,retrieved_documents,k,history,memory_limit=3) # create a new prompt using the retrieved documents
106
  print("check5")
107
  pd.options.display.max_colwidth = 4000
108
+ print(historylog)
109
  # print(retrieved_documents['0'])
110
  # print(formatted_prompt)
111
  # formatted_prompt_with_history = add_history(formatted_prompt, history)