pyspur icon indicating copy to clipboard operation
pyspur copied to clipboard

Error with "Single LLM Call" node and when using local Ollama

Open zCHIP opened this issue 9 months ago • 1 comments

Hi,

I'm facing the following error with "Single LLM Call" node and local Ollama (model: mistral):

Traceback (most recent call last):
  File "/Users/user/.local/share/uv/tools/pyspur/lib/python3.12/site-packages/pyspur/nodes/llm/single_llm_call.py", line 333, in run
    assistant_message = self.output_model.model_validate(assistant_message_dict)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/.local/share/uv/tools/pyspur/lib/python3.12/site-packages/pydantic/main.py", line 627, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for SingleShotJoke
  Input should be a valid dictionary or instance of SingleShotJoke [type=model_type, input_value='{"final_joke": "Why did ... for their employees!"}', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/model_type

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/user/.local/share/uv/tools/pyspur/lib/python3.12/site-packages/pyspur/execution/workflow_executor.py", line 628, in _execute_node
    output = await node_instance(node_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/.local/share/uv/tools/pyspur/lib/python3.12/site-packages/pyspur/nodes/base.py", line 224, in __call__
    result = await self.run(input)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/.local/share/uv/tools/pyspur/lib/python3.12/site-packages/pyspur/nodes/llm/single_llm_call.py", line 349, in run
    raise Exception(
Exception: {"type": "invalid_json_format", "message": "The LLM did not return valid JSON that matches the expected schema.\n\nRaw LLM response:\n\"{\\\"final_joke\\\": \\\"Why did the software engineer bring a ladder to work? To reach the 'debugging' icon on the ceiling, of course! I mean, who puts important buttons up high? Only companies that specialize in making life difficult for their employees!\\\"}\"\n\nAttempted to validate:\n\"{\\\"final_joke\\\": \\\"Why did the software engineer bring a ladder to work? To reach the 'debugging' icon on the ceiling, of course! I mean, who puts important buttons up high? Only companies that specialize in making life difficult for their employees!\\\"}\"\n\nValidation error: 1 validation error for SingleShotJoke\n  Input should be a valid dictionary or instance of SingleShotJoke [type=model_type, input_value='{\"final_joke\": \"Why did ... for their employees!\"}', input_type=str]\n    For further information visit https://errors.pydantic.dev/2.10/v/model_type", "original_response": "\"{\\\"final_joke\\\": \\\"Why did the software engineer bring a ladder to work? To reach the 'debugging' icon on the ceiling, of course! I mean, who puts important buttons up high? Only companies that specialize in making life difficult for their employees!\\\"}\"", "validation_input": "\"{\\\"final_joke\\\": \\\"Why did the software engineer bring a ladder to work? To reach the 'debugging' icon on the ceiling, of course! I mean, who puts important buttons up high? Only companies that specialize in making life difficult for their employees!\\\"}\"", "validation_error": "1 validation error for SingleShotJoke\n  Input should be a valid dictionary or instance of SingleShotJoke [type=model_type, input_value='{\"final_joke\": \"Why did ... for their employees!\"}', input_type=str]\n    For further information visit https://errors.pydantic.dev/2.10/v/model_type"}

zCHIP avatar Mar 23 '25 07:03 zCHIP

How did u fix this?

ocg2347 avatar Nov 03 '25 09:11 ocg2347