Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -120,7 +120,7 @@ nltk.download('punkt')
|
|
120 |
open_api_key_token = os.getenv("OPEN_AI_API")
|
121 |
|
122 |
os.environ['OPENAI_API_KEY'] = open_api_key_token
|
123 |
-
pdf_path = "Inbound.pdf"
|
124 |
|
125 |
db_uri = os.getenv("POSTGRESQL_CONNECTION")
|
126 |
|
@@ -1258,7 +1258,7 @@ def create_file_HF(file_path,directory,document_created = False):
|
|
1258 |
|
1259 |
def create_pdf(cname,ename,account_number, directory):
|
1260 |
|
1261 |
-
filled = FormWrapper("LOA_Sample_new.pdf").fill(
|
1262 |
{
|
1263 |
'company name': cname,
|
1264 |
'employee name': ename,
|
@@ -1267,7 +1267,7 @@ def create_pdf(cname,ename,account_number, directory):
|
|
1267 |
|
1268 |
},
|
1269 |
)
|
1270 |
-
output_file_name = f"
|
1271 |
document_created = True
|
1272 |
with open(output_file_name, "wb+") as output:
|
1273 |
output.write(filled.read())
|
@@ -1281,10 +1281,10 @@ def create_pdf(cname,ename,account_number, directory):
|
|
1281 |
|
1282 |
def zip_files_in_folder(directory, output_zip):
|
1283 |
# Initialize the ZIP file
|
1284 |
-
directory = "./
|
1285 |
with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
1286 |
# Walk through the directory and add PDF files to the ZIP
|
1287 |
-
for root, _, files in os.
|
1288 |
for file in files:
|
1289 |
if file.endswith(".pdf"): # Only include PDF files
|
1290 |
file_path = os.path.join(root, file)
|
|
|
120 |
open_api_key_token = os.getenv("OPEN_AI_API")
|
121 |
|
122 |
os.environ['OPENAI_API_KEY'] = open_api_key_token
|
123 |
+
pdf_path = "/Input/Inbound.pdf"
|
124 |
|
125 |
db_uri = os.getenv("POSTGRESQL_CONNECTION")
|
126 |
|
|
|
1258 |
|
1259 |
def create_pdf(cname,ename,account_number, directory):
|
1260 |
|
1261 |
+
filled = FormWrapper("/Input/LOA_Sample_new.pdf").fill(
|
1262 |
{
|
1263 |
'company name': cname,
|
1264 |
'employee name': ename,
|
|
|
1267 |
|
1268 |
},
|
1269 |
)
|
1270 |
+
output_file_name = f"{ename}_{cname}.pdf"
|
1271 |
document_created = True
|
1272 |
with open(output_file_name, "wb+") as output:
|
1273 |
output.write(filled.read())
|
|
|
1281 |
|
1282 |
def zip_files_in_folder(directory, output_zip):
|
1283 |
# Initialize the ZIP file
|
1284 |
+
directory = "./"
|
1285 |
with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
1286 |
# Walk through the directory and add PDF files to the ZIP
|
1287 |
+
for root, _, files in os.listdir(directory):
|
1288 |
for file in files:
|
1289 |
if file.endswith(".pdf"): # Only include PDF files
|
1290 |
file_path = os.path.join(root, file)
|