Namitg02 commited on
Commit
3c33f8b
·
verified ·
1 Parent(s): af3d16b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -12
app.py CHANGED
@@ -79,9 +79,7 @@ def format_prompt(prompt,retrieved_documents,k,history,memory_limit=3):
79
 
80
  print("checkwohist")
81
  # PROMPT = PROMPT + f"{history[0][0]} [/INST] {history[0][1]} </s>"
82
- # print("checkwthhist")
83
- # print(PROMPT)
84
- # Handle conversation history
85
  for user_message, bot_message in history[0:]:
86
  PROMPT += f"<s>[INST] {user_message} [/INST] {bot_message} </s>"
87
  print("checkwthhist2")
@@ -99,13 +97,6 @@ def talk(prompt, history):
99
  formatted_prompt = format_prompt(prompt,retrieved_documents,k,history,memory_limit=3) # create a new prompt using the retrieved documents
100
  print("check5")
101
  pd.options.display.max_colwidth = 4000
102
- # print(historylog)
103
- # print(retrieved_documents['0'])
104
- # print(formatted_prompt)
105
- # formatted_prompt_with_history = add_history(formatted_prompt, history)
106
-
107
- # formatted_prompt_with_history = formatted_prompt_with_history[:600] # to avoid memory issue
108
- # print(formatted_prompt_with_history)
109
  messages = [{"role":"system","content":SYS_PROMPT},{"role":"user","content":formatted_prompt}]
110
  print(messages)
111
  # binding the system context and new prompt for LLM
@@ -128,9 +119,9 @@ def talk(prompt, history):
128
 
129
  try:
130
  # write data to file
131
- with open('file.txt', 'a') as data:
132
  data.write(historylog)
133
- data = open('file.txt', 'r')
134
  data.seek(0)
135
  # Read the contents of the file to display it.
136
  print("History log printed:")
 
79
 
80
  print("checkwohist")
81
  # PROMPT = PROMPT + f"{history[0][0]} [/INST] {history[0][1]} </s>"
82
+ # Handle conversation history
 
 
83
  for user_message, bot_message in history[0:]:
84
  PROMPT += f"<s>[INST] {user_message} [/INST] {bot_message} </s>"
85
  print("checkwthhist2")
 
97
  formatted_prompt = format_prompt(prompt,retrieved_documents,k,history,memory_limit=3) # create a new prompt using the retrieved documents
98
  print("check5")
99
  pd.options.display.max_colwidth = 4000
 
 
 
 
 
 
 
100
  messages = [{"role":"system","content":SYS_PROMPT},{"role":"user","content":formatted_prompt}]
101
  print(messages)
102
  # binding the system context and new prompt for LLM
 
119
 
120
  try:
121
  # write data to file
122
+ with open("file.txt", "a") as data:
123
  data.write(historylog)
124
+ data = open("file.txt", "r")
125
  data.seek(0)
126
  # Read the contents of the file to display it.
127
  print("History log printed:")