Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,6 +16,8 @@ from langchain_core.runnables import RunnablePassthrough
|
|
| 16 |
from langchain_core.output_parsers import StrOutputParser
|
| 17 |
|
| 18 |
from manabUtils import retrieve_chunks
|
|
|
|
|
|
|
| 19 |
|
| 20 |
os.environ["HF_TOKEN"] = os.getenv("HF_TOKEN")
|
| 21 |
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
|
|
@@ -296,8 +298,14 @@ def check_compliance(file): # FIXED: now streams
|
|
| 296 |
else:
|
| 297 |
yield "Unsupported file format"
|
| 298 |
def check_compliance_tech(file):
|
| 299 |
-
if file.name.endswith(".pdf"):
|
| 300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
else:
|
| 302 |
yield "Unsupported file format"
|
| 303 |
|
|
@@ -356,11 +364,16 @@ with gr.Blocks(css=css) as demo:
|
|
| 356 |
submit_btn.click(respond, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 357 |
msg.submit(respond, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 358 |
with gr.TabItem("Compliance Check of user technical doc"):
|
| 359 |
-
gr.
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 364 |
with gr.TabItem("Compliance Check of ATC"):
|
| 365 |
gr.HTML("""
|
| 366 |
<div style="color: white; background: black; padding: 20px; text-align: center; font-size: 24px;">
|
|
|
|
| 16 |
from langchain_core.output_parsers import StrOutputParser
|
| 17 |
|
| 18 |
from manabUtils import retrieve_chunks
|
| 19 |
+
from technicalDocCompliance import compliance_tech
|
| 20 |
+
from MyRules import manualRules
|
| 21 |
|
| 22 |
os.environ["HF_TOKEN"] = os.getenv("HF_TOKEN")
|
| 23 |
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
|
|
|
|
| 298 |
else:
|
| 299 |
yield "Unsupported file format"
|
| 300 |
def check_compliance_tech(file):
|
| 301 |
+
if file.name.endswith(".pdf"):
|
| 302 |
+
MANUAL_RULES = manualRules()
|
| 303 |
+
dd=compliance_tech(file, client, MANUAL_RULES)
|
| 304 |
+
kkk="<table>"
|
| 305 |
+
kkk+=generate_html(dd)
|
| 306 |
+
kkk+="</table>"
|
| 307 |
+
yield kkk
|
| 308 |
+
update_log("\n Technical Complaince response: "+kkk+"\n")
|
| 309 |
else:
|
| 310 |
yield "Unsupported file format"
|
| 311 |
|
|
|
|
| 364 |
submit_btn.click(respond, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 365 |
msg.submit(respond, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 366 |
with gr.TabItem("Compliance Check of user technical doc"):
|
| 367 |
+
with gr.Row():
|
| 368 |
+
inp_tech = gr.File(
|
| 369 |
+
label="Upload technical document in pdf format",
|
| 370 |
+
file_types=[".pdf"],
|
| 371 |
+
elem_id="tech-file"
|
| 372 |
+
)
|
| 373 |
+
run_btn_tech = gr.Button("Check compliance of technical document", elem_id="compliance-btn-tech")
|
| 374 |
+
out_tech = gr.HTML(label="Compliance Result of technical document")
|
| 375 |
+
#out = gr.Textbox(lines=15, label="Compliance Result",elem_id="compliance-out")
|
| 376 |
+
run_btn_tech.click(check_compliance_tech, inputs=inp_tech, outputs=out_tech)
|
| 377 |
with gr.TabItem("Compliance Check of ATC"):
|
| 378 |
gr.HTML("""
|
| 379 |
<div style="color: white; background: black; padding: 20px; text-align: center; font-size: 24px;">
|