Update app.py
Browse files
app.py
CHANGED
@@ -127,6 +127,10 @@ def init_agent():
|
|
127 |
|
128 |
|
129 |
def stream_final_report(agent, file) -> Generator[Union[Dict[str, str], Tuple[List[Dict[str, str]], str]], None, None]:
|
|
|
|
|
|
|
|
|
130 |
extracted_text = extract_text_from_excel(file.name)
|
131 |
chunks = split_text_into_chunks(extracted_text)
|
132 |
chunk_responses = []
|
@@ -191,7 +195,7 @@ def create_ui(agent):
|
|
191 |
report_output = gr.File(label="Download Report")
|
192 |
|
193 |
analyze_btn.click(
|
194 |
-
fn=stream_final_report,
|
195 |
inputs=[file_upload],
|
196 |
outputs=[chatbot, report_output]
|
197 |
)
|
|
|
127 |
|
128 |
|
129 |
def stream_final_report(agent, file) -> Generator[Union[Dict[str, str], Tuple[List[Dict[str, str]], str]], None, None]:
|
130 |
+
if file is None or not hasattr(file, "name"):
|
131 |
+
yield {"role": "assistant", "content": "❌ Please upload a valid Excel file before analyzing."}
|
132 |
+
return
|
133 |
+
|
134 |
extracted_text = extract_text_from_excel(file.name)
|
135 |
chunks = split_text_into_chunks(extracted_text)
|
136 |
chunk_responses = []
|
|
|
195 |
report_output = gr.File(label="Download Report")
|
196 |
|
197 |
analyze_btn.click(
|
198 |
+
fn=lambda file: stream_final_report(agent, file),
|
199 |
inputs=[file_upload],
|
200 |
outputs=[chatbot, report_output]
|
201 |
)
|