zylon-ai/private-gpt · warning · ValueError
Output is not a string, number, pd.DataFrame, or chart
Error message
Output is not a string, number, pd.DataFrame, or chart
What it means
Raised by PandasAIOutput.get_output_value() when _determine_response_type() returns None or an unknown key: the value is none of DataFrame, ChartResponse, str, or a number type. _determine_response_type runs the type_checks list; a miss means the analysis produced an exotic value (dict, list, None, datetime, etc.) the dispatch table does not cover.
Source
Thrown at private_gpt/components/tabular/pandasai_service.py:184
if check_func():
return type_name
return None
def get_raw(self) -> Any | None:
"""Get the raw output value in its appropriate format."""
handlers: dict[str, Callable[[], Any]] = {
"dataframe": lambda: None,
"chart": self.get_chart,
"string": lambda: str(self.value),
"number": lambda: None,
}
response_type = self._determine_response_type()
if response_type in handlers:
return handlers[response_type]()
raise ValueError("Output is not a string, number, pd.DataFrame, or chart")
def __str__(self) -> str:
"""Convert the output to a string representation."""
str_converters: dict[str, Callable[[], str]] = {
"dataframe": lambda: (
df_to_minimal_markdown(self.get_dataframe()) or "No results."
),
"chart": lambda: (
"Generated chart successfully. Plot was attached to the conversation."
"Don't create placeholders for charts, just reply that the chart was generated."
),
"string": lambda: str(self.value),
"number": lambda: format_number(self.value),
}
response_type = self._determine_response_type()
if response_type and response_type in str_converters:
return str_converters[response_type]()View on GitHub (pinned to 4a030776a3)
Solutions
- Log repr(self.value) to identify the uncovered type.
- Handle dict/list by str()-ing or json-serializing before dispatch, or extend type_checks in a subclass.
- Prompt the model to end with an explicit DataFrame/string/number expression.
- Fall back to str(output) for display when get_output_value() raises.
Example fix
# before
value = output.get_output_value() # ValueError
# after
try:
value = output.get_output_value()
except ValueError:
value = str(output) Defensive patterns
Strategy: fallback
Validate before calling
SUPPORTED = (str, int, float, complex, bool)
def is_representable(output) -> bool:
import pandas as pd
v = output.value
return isinstance(v, pd.DataFrame) or output.is_chart() or isinstance(v, SUPPORTED) Type guard
def classify_output(output):
t = output._determine_response_type()
return t if t in {"dataframe", "chart", "string", "number"} else "other" Try / catch
try:
value = output.get_output_value()
except ValueError:
value = str(output) Prevention
- Prompt the model to end with a DataFrame/string/number expression
- Convert dict/list results to str before they reach the output wrapper
- Use get_output_value only after classify_output returns a known type
When it happens
Trigger: Generated code's final value is a dict, list, tuple, None, or a numpy type not matched by the number check; execution produced no value at all so self.value is None.
Common situations: LLM returns a list of tuples or a dict of aggregates; model assigns to a variable instead of leaving a final expression so value is None; pandasai version change altering what value is propagated.
Related errors
- Output is not a pd.DataFrame
- Output is not a chart
- Failed to parse JSON: {e!s}
- Invalid CALL statement format
- Failed to execute some SQL queries: {', '.join(str(e) for e
AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15).
Data as JSON: /api/errors/e02518fd2ec30637.
Report an issue: GitHub.