Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError("Invalid message type: <class 'str'>. Expected dict or Pydantic model.") #383

Open
esnible opened this issue Feb 10, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@esnible
Copy link
Member

esnible commented Feb 10, 2025

Describe the bug
A seemingly valid PDL program produces

notools.pdl:2 - Error during 'ollama/granite-code:8b' model call: TypeError("Invalid message type: <class 'str'>. Expected dict or Pydantic model.")

If run with Open Telemetry support, produces the above, plus opentelemetry.py:651 - OpenTelemetry logging error in set_attributes 'str' object has no attribute 'get', plus a backtrace.

To Reproduce
Use pdl notools.pdl with the program

text:
- model: ollama/granite-code:8b
  input:
    array:
    - role: user
      content: What's the current weather in New York?
    - role: assistant
      # If I don't define this, I get "Invalid message type: <class 'str'>. Expected dict or Pydantic model."
      # content: ""

Expected behavior
An LLM response regarding weather

Desktop (please complete the following information):

Additional context
Uncommenting the content line in the example fixes the problem, yielding an expected hallucination:

assistant: The current weather in New York is sunny with a high of 72 degrees. The air pressure is 1023 mb, and the wind speed is 6 mph from the southwest. There is a 25% chance of rain.
@esnible esnible added the bug Something isn't working label Feb 10, 2025
@vazirim
Copy link
Member

vazirim commented Feb 10, 2025

@esnible Thanks for reporting, but without the content field the message is ill-formed. That error message comes from ollama, not PDL (there should be an error).

@esnible
Copy link
Member Author

esnible commented Feb 10, 2025

I am using the PDL Schemas in VSCode, but no error is displayed, which caused me to think the program was valid.

I am not suggesting my PDL progam is correct. I am suggesting that the error, "Expected dict or Pydantic model" is difficult to understand. I am left confused about which PDL entity should be changed from string to dict or Pydantic model.

I don't know if it makes a difference, but I stumbled across this looking at https://www.ibm.com/granite/docs/models/granite/#granite-3.1-highlights . It showed a prompt that seemed to end with empty assistant response. I have another variant PDL program that lists tools, and I was using it to test how Granite produces tool calling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants