Spaces:
Running
Running
Update eb_agent_module.py
Browse files- eb_agent_module.py +11 -3
eb_agent_module.py
CHANGED
@@ -486,7 +486,6 @@ Relevant Benchmarks: {benchmarks_val}"""
|
|
486 |
logging.info("EmployerBrandingAgent chat history cleared by request.")
|
487 |
|
488 |
def get_all_schemas_representation(all_dataframes: dict) -> str:
|
489 |
-
# ... (implementation unchanged)
|
490 |
if not all_dataframes: return "No DataFrames are currently loaded."
|
491 |
schema_descriptions = ["DataFrames currently available in the application state:"]
|
492 |
for key, df in all_dataframes.items():
|
@@ -496,8 +495,17 @@ def get_all_schemas_representation(all_dataframes: dict) -> str:
|
|
496 |
if df.empty:
|
497 |
schema = f"\n--- DataFrame: {df_name} ---\nStatus: Empty\nShape: {shape}\nColumns: {columns}"
|
498 |
else:
|
499 |
-
|
500 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
501 |
schema_descriptions.append(schema)
|
502 |
return "\n".join(schema_descriptions)
|
503 |
|
|
|
486 |
logging.info("EmployerBrandingAgent chat history cleared by request.")
|
487 |
|
488 |
def get_all_schemas_representation(all_dataframes: dict) -> str:
|
|
|
489 |
if not all_dataframes: return "No DataFrames are currently loaded."
|
490 |
schema_descriptions = ["DataFrames currently available in the application state:"]
|
491 |
for key, df in all_dataframes.items():
|
|
|
495 |
if df.empty:
|
496 |
schema = f"\n--- DataFrame: {df_name} ---\nStatus: Empty\nShape: {shape}\nColumns: {columns}"
|
497 |
else:
|
498 |
+
try:
|
499 |
+
# Attempt to use to_markdown, with a fallback to to_string
|
500 |
+
sample_data_str = df.head(2).to_markdown(index=False)
|
501 |
+
except ImportError:
|
502 |
+
logging.warning("`tabulate` library not found. Falling back to `to_string()` for schema representation.")
|
503 |
+
sample_data_str = df.head(2).to_string(index=False)
|
504 |
+
except Exception as e:
|
505 |
+
logging.error(f"Error formatting DataFrame sample for {df_name} with to_markdown: {e}. Falling back to to_string().")
|
506 |
+
sample_data_str = df.head(2).to_string(index=False)
|
507 |
+
|
508 |
+
schema = (f"\n--- DataFrame: {df_name} ---\nShape: {shape}\nColumns: {columns}\n\n<details><summary>Sample Data (first 2 rows of {df_name}):</summary>\n\n```text\n{sample_data_str}\n```\n\n</details>")
|
509 |
schema_descriptions.append(schema)
|
510 |
return "\n".join(schema_descriptions)
|
511 |
|