| eda_llm_insights |
function |
py |
datascience |
1.0.0 |
impure |
def eda_llm_insights(profile: dict, model: str = "claude-haiku-4-5-20251001") -> dict |
Capa LLM interpretativa del grupo eda. Toma un TableProfile YA CALCULADO (el dict de profile_table) y, con UNA sola llamada al LLM, genera el bloque 'llm': resumen de la tabla, significado de una fila, diccionario de datos, deteccion de PII (RGPD), sugerencias de limpieza y analisis sugeridos. Clave de coste/privacidad: NO envia filas crudas al LLM, solo el perfil AGREGADO (nombres, tipos, % nulos, distinct, top valores agregados de categoricas, stats de numericas, pares de correlacion fuertes). Reusa ask_llm del grupo claude-direct (API directa con token OAuth de Claude). Impura, dict-no-throw. |
| eda |
| llm |
| claude-direct |
| datascience |
| profiling |
| pii |
| data-dictionary |
|
| name |
desc |
| profile |
TableProfile ya calculado (el dict que devuelve profile_table()['profile']). Se espera {table, n_rows, columns:[{name, inferred_type, semantic_type, null_pct, distinct_count, numeric:{min,max,mean,p50,...}, categorical:{top:[{value,count,pct}], mode,...}}], correlations:{strong:[{a,b,method,value}]} | None}. Solo se le envia al LLM un resumen agregado; nunca filas crudas. |
|
| name |
desc |
| model |
id del modelo Anthropic a usar. Default 'claude-haiku-4-5-20251001' (haiku, coste bajo). Para mayor calidad interpretativa, pasar p.ej. 'claude-opus-4-8'. |
|
|
dict dict-no-throw. En exito: {status:'ok', llm:{summary:str, row_meaning:str, dictionary:[{column,description,business_meaning,unit}], pii:[{column,kind,severity}], cleaning:[str], analyses:[str]}}. Las claves que el LLM omita se rellenan con defaults vacios. En error (sin lanzar): {status:'error', error:str}. |
|
|
|
false |
error_go_core |
|
true |
| test_build_prompt_includes_table_and_columns |
| test_build_prompt_includes_numeric_stats_and_top_values |
| test_build_prompt_handles_empty_profile |
| test_parse_llm_json_plain |
| test_parse_llm_json_with_fences |
| test_parse_llm_json_with_surrounding_text |
| test_parse_llm_json_nested_braces_in_strings |
| test_parse_llm_json_raises_without_object |
| test_eda_llm_insights_ok_with_monkeypatched_llm |
| test_eda_llm_insights_fills_missing_keys |
| test_eda_llm_insights_error_on_empty_profile |
| test_eda_llm_insights_error_on_empty_llm_response |
| test_eda_llm_insights_error_on_unparseable_llm_response |
|
python/functions/datascience/eda_llm_insights_test.py |
python/functions/datascience/eda_llm_insights.py |