Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

fix/validation-error-pipeLLM (#494)

Thomas Hebrard19316a57dccc
diff --git a/pipelex/pipe_operators/llm/pipe_llm.py b/pipelex/pipe_operators/llm/pipe_llm.py
index fa75e71ab..3591505a9 100644
--- a/pipelex/pipe_operators/llm/pipe_llm.py
+++ b/pipelex/pipe_operators/llm/pipe_llm.py
@@ -227,9 +227,15 @@ class PipeLLM(PipeOperator[PipeLLMOutput]):
msg = f"Error generating text with LLM {location}: {error_details}"
raise PipeRunError(message=msg, run_mode=pipe_run_params.run_mode) from exc
- the_content = TextContent(
- text=generated_text,
- )
+ try:
+ the_content = TextContent(
+ text=generated_text,
+ )
+ except ValidationError as exc:
+ location = self._format_error_location(pipe_run_params=pipe_run_params)
+ error_details = format_pydantic_validation_error(exc)
+ msg = f"Error generating text content with in PipeLLM {location}: {error_details}"
+ raise PipeRunError(message=msg, run_mode=pipe_run_params.run_mode) from exc
else:
if is_multiple_output:
log.verbose(f"PipeLLM generating {fixed_nb_output} output(s)" if fixed_nb_output else "PipeLLM generating a list of output(s)")