ECUiVADE commited on
Commit
35685ed
1 Parent(s): faa2249

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -17
app.py CHANGED
@@ -133,15 +133,18 @@ def generate(prompt, history):
133
 
134
  if not len(Name) == 0 and not len(Occupation) == 0 and not len(Ethnicity) == 0 and not len(Gender) == 0 and not len(Age) == 0:
135
 
 
136
  if isFirstRun:
137
  context = initContext
138
  isFirstRun = False
 
 
139
 
140
  context += """
141
  <|im_start|>nurse
142
- """+prompt+"""
143
  <|im_start|>barry
144
-
145
  """
146
 
147
  response = ""
@@ -162,7 +165,14 @@ def generate(prompt, history):
162
  # yield response
163
 
164
  history.append((prompt,response))
 
 
 
 
 
 
165
  context += response
 
166
  print (context)
167
  return history
168
 
@@ -170,21 +180,6 @@ def generate(prompt, history):
170
  output = "Did you forget to enter your Details? Please go to the User Info Tab and Input your data. "
171
  yield output
172
 
173
- def predict(input, chatbot, max_length, top_p, temperature, history):
174
- chatbot.append((input, ""))
175
- response = ""
176
- history.append(input)
177
-
178
- for output in llm(input, stream=True, temperature=temperature, top_p=top_p, max_tokens=max_length, ):
179
- piece = output['choices'][0]['text']
180
- response += piece
181
- chatbot[-1] = (chatbot[-1][0], response)
182
-
183
- yield chatbot, history
184
-
185
- history.append(response)
186
- yield chatbot, history
187
-
188
 
189
  chat_bot=gr.ChatInterface(
190
  fn=generate,
 
133
 
134
  if not len(Name) == 0 and not len(Occupation) == 0 and not len(Ethnicity) == 0 and not len(Gender) == 0 and not len(Age) == 0:
135
 
136
+ firstmsg =""
137
  if isFirstRun:
138
  context = initContext
139
  isFirstRun = False
140
+ firstmsg = prompt
141
+
142
 
143
  context += """
144
  <|im_start|>nurse
145
+ Nurse:"""+prompt+"""
146
  <|im_start|>barry
147
+ Barry:
148
  """
149
 
150
  response = ""
 
165
  # yield response
166
 
167
  history.append((prompt,response))
168
+ chat_history.append([prompt, response])
169
+ if not isFirstRun:
170
+ chat_log_history.append({"user": prompt, "bot": output})
171
+ upload_to_google_drive()
172
+ else:
173
+ chat_log_history.append({"user": firstmsg, "bot": output})
174
  context += response
175
+
176
  print (context)
177
  return history
178
 
 
180
  output = "Did you forget to enter your Details? Please go to the User Info Tab and Input your data. "
181
  yield output
182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
 
184
  chat_bot=gr.ChatInterface(
185
  fn=generate,