Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,7 @@ from langgraph.graph import StateGraph, START, END
|
|
13 |
from langchain_core.messages import SystemMessage, HumanMessage
|
14 |
from langchain_community.document_loaders import PyPDFLoader
|
15 |
|
|
|
16 |
from dotenv import load_dotenv
|
17 |
|
18 |
load_dotenv()
|
@@ -270,7 +271,13 @@ def claim_generator(input_bill_path, progress=gr.Progress()):
|
|
270 |
progress(0.05)
|
271 |
output = chain.invoke({'image_path': input_bill_path})
|
272 |
progress(0.25)
|
273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
|
275 |
agentic_workflow_representation = 'The agentic workflow used to generate an expense claim document is represented below: \n <img src="https://cdn-uploads.huggingface.co/production/uploads/64118e60756b9e455c7eddd6/iqdGjUG7POKJXLItzWb-K.png">'
|
276 |
agentic_workflow_description = """
|
@@ -290,7 +297,8 @@ Similarly, the verifier is a search agent that extracts relevant portions of the
|
|
290 |
demo = gr.Interface(
|
291 |
fn=claim_generator,
|
292 |
inputs=gr.Image(type="filepath", label="Upload an image of the bill"),
|
293 |
-
outputs=gr.Markdown(label="Expense Claim Document", show_copy_button=True, container=True),
|
|
|
294 |
title="Expense Claim Document Generator",
|
295 |
description=agentic_workflow_description,
|
296 |
article=agentic_workflow_representation,
|
|
|
13 |
from langchain_core.messages import SystemMessage, HumanMessage
|
14 |
from langchain_community.document_loaders import PyPDFLoader
|
15 |
|
16 |
+
from markdown_pdf import MarkdownPdf, Section
|
17 |
from dotenv import load_dotenv
|
18 |
|
19 |
load_dotenv()
|
|
|
271 |
progress(0.05)
|
272 |
output = chain.invoke({'image_path': input_bill_path})
|
273 |
progress(0.25)
|
274 |
+
|
275 |
+
pdf = MarkdownPdf(toc_level=3)
|
276 |
+
|
277 |
+
pdf.add_section(Section(output['final_output']))
|
278 |
+
pdf.save("expense-claim-generator.pdf")
|
279 |
+
|
280 |
+
return output['final_output'], 'expense-claim-generator.pdf'
|
281 |
|
282 |
agentic_workflow_representation = 'The agentic workflow used to generate an expense claim document is represented below: \n <img src="https://cdn-uploads.huggingface.co/production/uploads/64118e60756b9e455c7eddd6/iqdGjUG7POKJXLItzWb-K.png">'
|
283 |
agentic_workflow_description = """
|
|
|
297 |
demo = gr.Interface(
|
298 |
fn=claim_generator,
|
299 |
inputs=gr.Image(type="filepath", label="Upload an image of the bill"),
|
300 |
+
outputs=[gr.Markdown(label="Expense Claim Document", show_copy_button=True, container=True),
|
301 |
+
gr.File(label="Download your claim document", show_label=True)],
|
302 |
title="Expense Claim Document Generator",
|
303 |
description=agentic_workflow_description,
|
304 |
article=agentic_workflow_representation,
|