Update app.py
Browse files
app.py
CHANGED
@@ -151,57 +151,36 @@ def upload_to_google_drive():
|
|
151 |
|
152 |
|
153 |
def generate(prompt, history):
|
154 |
-
|
155 |
-
global isFirstRun,initContext,Name,Occupation,Ethnicity,Gender,Age,context,YearsOfExp
|
156 |
-
|
157 |
-
#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 and not len(YearsOfExp):
|
158 |
if agreed:
|
159 |
-
firstmsg =""
|
160 |
if isFirstRun:
|
161 |
context = initContext
|
162 |
isFirstRun = False
|
163 |
firstmsg = prompt
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
Barry:
|
171 |
-
"""
|
172 |
-
|
173 |
response = ""
|
174 |
-
history2 = []
|
175 |
-
|
176 |
while(len(response) < 1):
|
177 |
output = llm(context, max_tokens=400, stop=["Nurse:"], echo=False)
|
178 |
-
response = output["choices"][0]["text"]
|
179 |
-
response = response.strip()
|
180 |
-
#yield response
|
181 |
-
|
182 |
-
|
183 |
-
# for output in llm(input, stream=True, max_tokens=100, ):
|
184 |
-
# piece = output['choices'][0]['text']
|
185 |
-
# response += piece
|
186 |
-
# chatbot[-1] = (chatbot[-1][0], response)
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
history.append((prompt,response))
|
191 |
-
if not isFirstRun:
|
192 |
chat_log_history.append({"user": prompt, "bot": response})
|
193 |
-
upload_to_google_drive()
|
194 |
else:
|
195 |
-
chat_log_history.append({"user": firstmsg, "bot":
|
196 |
-
|
197 |
context += response
|
198 |
|
199 |
-
print (context)
|
200 |
return "", history
|
201 |
-
|
202 |
else:
|
203 |
-
output = "Did you forget to enter your Details? Please go to the User Info Tab and Input your data.
|
204 |
-
return output
|
205 |
|
206 |
def submit_user_info(name,occupation,yearsofexp,ethnicity,gender,age):
|
207 |
global Name, Occupation,Ethnicity,Gender,Age,chat_log_name,YearsOfExp
|
|
|
151 |
|
152 |
|
153 |
def generate(prompt, history):
|
154 |
+
global isFirstRun, initContext, Name, Occupation, Ethnicity, Gender, Age, context, YearsOfExp, agreed
|
|
|
|
|
|
|
155 |
if agreed:
|
156 |
+
firstmsg = ""
|
157 |
if isFirstRun:
|
158 |
context = initContext
|
159 |
isFirstRun = False
|
160 |
firstmsg = prompt
|
161 |
+
|
162 |
+
context += f"""
|
163 |
+
Nurse:{prompt}
|
164 |
+
Barry:
|
165 |
+
"""
|
166 |
+
|
|
|
|
|
|
|
167 |
response = ""
|
|
|
|
|
168 |
while(len(response) < 1):
|
169 |
output = llm(context, max_tokens=400, stop=["Nurse:"], echo=False)
|
170 |
+
response = output["choices"][0]["text"].strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
+
history.append((prompt, response))
|
173 |
+
if not isFirstRun:
|
|
|
|
|
174 |
chat_log_history.append({"user": prompt, "bot": response})
|
|
|
175 |
else:
|
176 |
+
chat_log_history.append({"user": firstmsg, "bot": response})
|
177 |
+
|
178 |
context += response
|
179 |
|
|
|
180 |
return "", history
|
|
|
181 |
else:
|
182 |
+
output = "Did you forget to enter your Details? Please go to the User Info Tab and Input your data."
|
183 |
+
return output, history
|
184 |
|
185 |
def submit_user_info(name,occupation,yearsofexp,ethnicity,gender,age):
|
186 |
global Name, Occupation,Ethnicity,Gender,Age,chat_log_name,YearsOfExp
|