Omnibus commited on
Commit
bbd06c4
1 Parent(s): a712c99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -10
app.py CHANGED
@@ -146,6 +146,20 @@ def create_valid_filename(invalid_filename: str) -> str:
146
  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_', '-')
147
  return ''.join(char for char in valid_chars if char in allowed_chars)
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  def generate(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=1048, top_p=0.95, repetition_penalty=1.0,):
150
  #main_point[0]=prompt
151
  #print(datetime.datetime.now())
@@ -184,7 +198,7 @@ def generate(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0
184
  formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
185
  post_cnt+=1
186
  else:
187
- system_prompt=prompts.REPLY_TO_COMMENTER.format(focus=main_points[0])
188
 
189
  generate_kwargs = dict(
190
  temperature=temperature,
@@ -209,7 +223,7 @@ def generate(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0
209
 
210
  for response in stream:
211
  output += response.token.text
212
- yield '', [(prompt,output)],summary[0],json_obj, json_hist
213
  out_json = {"prompt":prompt,"output":output}
214
 
215
  prompt = question_generate(output, history)
@@ -258,15 +272,13 @@ def generate(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0
258
 
259
  prompt = question_generate(output, history)
260
  main_point[0]=prompt
261
-
262
- return prompt, history, summary[0],json_obj,json_hist
263
 
264
- def load_html():
265
- with open('index.html','r') as h:
266
- html=h.read()
267
- html = html.replace("$name","Test")
268
- h.close()
269
- return html
270
 
271
 
272
  with gr.Blocks() as app:
 
146
  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_', '-')
147
  return ''.join(char for char in valid_chars if char in allowed_chars)
148
 
149
+
150
+
151
+
152
+
153
+
154
+ def load_html(inp):
155
+ with open('index.html','r') as h:
156
+ html=h.read()
157
+ html = html.replace("$body",f"{inp}")
158
+ h.close()
159
+ return html
160
+
161
+
162
+
163
  def generate(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=1048, top_p=0.95, repetition_penalty=1.0,):
164
  #main_point[0]=prompt
165
  #print(datetime.datetime.now())
 
198
  formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
199
  post_cnt+=1
200
  else:
201
+ system_prompt=prompts.REPLY_TO_COMMENTER.format(focus=main_point[0])
202
 
203
  generate_kwargs = dict(
204
  temperature=temperature,
 
223
 
224
  for response in stream:
225
  output += response.token.text
226
+ yield '', [(prompt,output)],summary[0],json_obj, json_hist,html_out
227
  out_json = {"prompt":prompt,"output":output}
228
 
229
  prompt = question_generate(output, history)
 
272
 
273
  prompt = question_generate(output, history)
274
  main_point[0]=prompt
 
 
275
 
276
+
277
+ html_out=load_html(history)
278
+ yield prompt, history, summary[0],json_obj,json_hist,html_out
279
+ return prompt, history, summary[0],json_obj,json_hist,html_out
280
+
281
+
282
 
283
 
284
  with gr.Blocks() as app: