Update app.py
Browse files
app.py
CHANGED
|
@@ -160,7 +160,7 @@ def reply_generate(prompt, history,post_check,full_conv, agent_name=agents[0], s
|
|
| 160 |
print(post_check)
|
| 161 |
#full_conv=history
|
| 162 |
print(f'full_conv::\n{full_conv}')
|
| 163 |
-
print("###############\nRUNNING
|
| 164 |
seed = random.randint(1,1111111111111111)
|
| 165 |
agent=prompts.REPLY_TO_COMMENTER.format(focus=full_conv[0][0],comment=full_conv[1][1])
|
| 166 |
system_prompt=agent
|
|
@@ -253,7 +253,7 @@ def create_valid_filename(invalid_filename: str) -> str:
|
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
-
def load_html(inp,title):
|
| 257 |
ht=""
|
| 258 |
if inp:
|
| 259 |
for i,ea in enumerate(inp):
|
|
@@ -263,7 +263,7 @@ def load_html(inp,title):
|
|
| 263 |
#print(f'prom:: {prom}')
|
| 264 |
ht+=f"""<div class="div_box">"""
|
| 265 |
if blog:
|
| 266 |
-
ht+=f"""<div class="bhead"><div><h1>$btitle</h1></div></div>"""
|
| 267 |
ht+=f"""<pre class="bpost">{blog}</pre>"""
|
| 268 |
if comm:
|
| 269 |
ht+=f"""<pre class="resp1">{comm}</pre>"""
|
|
@@ -273,8 +273,9 @@ def load_html(inp,title):
|
|
| 273 |
with open('index.html','r') as h:
|
| 274 |
html=h.read()
|
| 275 |
html = html.replace("$body",f"{ht}")
|
| 276 |
-
html = html.replace("$title",f"{title}")
|
| 277 |
html = html.replace("$btitle",f"{title}")
|
|
|
|
| 278 |
h.close()
|
| 279 |
return html
|
| 280 |
|
|
@@ -304,6 +305,7 @@ def load_html_OG(inp,title):
|
|
| 304 |
return html
|
| 305 |
|
| 306 |
|
|
|
|
| 307 |
|
| 308 |
def generate(prompt, history, post_check,full_conv, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=1048, top_p=0.95, repetition_penalty=1.0):
|
| 309 |
html_out=""
|
|
@@ -422,8 +424,8 @@ def generate(prompt, history, post_check,full_conv, agent_name=agents[0], sys_pr
|
|
| 422 |
full_conv.append((output,None,None))
|
| 423 |
|
| 424 |
|
| 425 |
-
html_out=load_html(full_conv,title)
|
| 426 |
-
post_check={'user':
|
| 427 |
yield prompt, history,post_check,full_conv,summary[0],json_obj,json_hist,html_out
|
| 428 |
else:
|
| 429 |
print("passing blog")
|
|
|
|
| 160 |
print(post_check)
|
| 161 |
#full_conv=history
|
| 162 |
print(f'full_conv::\n{full_conv}')
|
| 163 |
+
print("###############\nRUNNING REPLY GENERATOR\n###############\n")
|
| 164 |
seed = random.randint(1,1111111111111111)
|
| 165 |
agent=prompts.REPLY_TO_COMMENTER.format(focus=full_conv[0][0],comment=full_conv[1][1])
|
| 166 |
system_prompt=agent
|
|
|
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
+
def load_html(inp,title,user_name="None"):
|
| 257 |
ht=""
|
| 258 |
if inp:
|
| 259 |
for i,ea in enumerate(inp):
|
|
|
|
| 263 |
#print(f'prom:: {prom}')
|
| 264 |
ht+=f"""<div class="div_box">"""
|
| 265 |
if blog:
|
| 266 |
+
ht+=f"""<div class="bhead"><div><h1>$btitle</h1></div><div>$user_name</div></div>"""
|
| 267 |
ht+=f"""<pre class="bpost">{blog}</pre>"""
|
| 268 |
if comm:
|
| 269 |
ht+=f"""<pre class="resp1">{comm}</pre>"""
|
|
|
|
| 273 |
with open('index.html','r') as h:
|
| 274 |
html=h.read()
|
| 275 |
html = html.replace("$body",f"{ht}")
|
| 276 |
+
#html = html.replace("$title",f"{title}")
|
| 277 |
html = html.replace("$btitle",f"{title}")
|
| 278 |
+
html = html.replace("$user_name",f"{user_name}")
|
| 279 |
h.close()
|
| 280 |
return html
|
| 281 |
|
|
|
|
| 305 |
return html
|
| 306 |
|
| 307 |
|
| 308 |
+
list_of_users=["user1","user2","user3"]
|
| 309 |
|
| 310 |
def generate(prompt, history, post_check,full_conv, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=1048, top_p=0.95, repetition_penalty=1.0):
|
| 311 |
html_out=""
|
|
|
|
| 424 |
full_conv.append((output,None,None))
|
| 425 |
|
| 426 |
|
| 427 |
+
html_out=load_html(full_conv,title,list_of_users[0])
|
| 428 |
+
post_check={'user':list_of_users[0],'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0}
|
| 429 |
yield prompt, history,post_check,full_conv,summary[0],json_obj,json_hist,html_out
|
| 430 |
else:
|
| 431 |
print("passing blog")
|