Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,11 +19,9 @@ def upload_pdfs(files):
|
|
| 19 |
file_name = os.path.basename(file.name)
|
| 20 |
file_path = f"uploads/{file_name}"
|
| 21 |
try:
|
| 22 |
-
# Handle NamedString or file-like object
|
| 23 |
if hasattr(file, 'read'):
|
| 24 |
content = file.read()
|
| 25 |
else:
|
| 26 |
-
# Assume NamedString; convert string content to bytes
|
| 27 |
content = str(file).encode('utf-8')
|
| 28 |
with open(file_path, "wb") as f:
|
| 29 |
f.write(content)
|
|
@@ -49,20 +47,20 @@ def upload_pdfs(files):
|
|
| 49 |
def fetch_objects():
|
| 50 |
sf, error = get_salesforce_client()
|
| 51 |
if error:
|
| 52 |
-
return gr.
|
| 53 |
objects, error = get_salesforce_objects(sf)
|
| 54 |
if error:
|
| 55 |
-
return gr.
|
| 56 |
-
return gr.
|
| 57 |
|
| 58 |
def fetch_fields(object_name):
|
| 59 |
sf, error = get_salesforce_client()
|
| 60 |
if error:
|
| 61 |
-
return gr.
|
| 62 |
fields, error = get_object_fields(sf, object_name)
|
| 63 |
if error:
|
| 64 |
-
return gr.
|
| 65 |
-
return gr.
|
| 66 |
|
| 67 |
def process_pdf(pdf_path):
|
| 68 |
text_data, error = extract_text_from_pdf(pdf_path)
|
|
|
|
| 19 |
file_name = os.path.basename(file.name)
|
| 20 |
file_path = f"uploads/{file_name}"
|
| 21 |
try:
|
|
|
|
| 22 |
if hasattr(file, 'read'):
|
| 23 |
content = file.read()
|
| 24 |
else:
|
|
|
|
| 25 |
content = str(file).encode('utf-8')
|
| 26 |
with open(file_path, "wb") as f:
|
| 27 |
f.write(content)
|
|
|
|
| 47 |
def fetch_objects():
|
| 48 |
sf, error = get_salesforce_client()
|
| 49 |
if error:
|
| 50 |
+
return gr.update(choices=[]), f"Error: {error}"
|
| 51 |
objects, error = get_salesforce_objects(sf)
|
| 52 |
if error:
|
| 53 |
+
return gr.update(choices=[]), f"Error: {error}"
|
| 54 |
+
return gr.update(choices=objects), "Objects fetched successfully"
|
| 55 |
|
| 56 |
def fetch_fields(object_name):
|
| 57 |
sf, error = get_salesforce_client()
|
| 58 |
if error:
|
| 59 |
+
return gr.update(choices=[]), f"Error: {error}"
|
| 60 |
fields, error = get_object_fields(sf, object_name)
|
| 61 |
if error:
|
| 62 |
+
return gr.update(choices=[]), f"Error: {error}"
|
| 63 |
+
return gr.update(choices=fields), "Fields fetched successfully"
|
| 64 |
|
| 65 |
def process_pdf(pdf_path):
|
| 66 |
text_data, error = extract_text_from_pdf(pdf_path)
|