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

Unmarshalling string content blocks fails #58

Open
tonyhb opened this issue Dec 12, 2024 · 2 comments
Open

Unmarshalling string content blocks fails #58

tonyhb opened this issue Dec 12, 2024 · 2 comments

Comments

@tonyhb
Copy link

tonyhb commented Dec 12, 2024

According to the docs:

Each input message content may be either a single string or an array of content blocks, where each block has a specific type. Using a string for content is shorthand for an array of one content block of type "text". The following input messages are equivalent:

{"role": "user", "content": "Hello, Claude"}
{"role": "user", "content": [{"type": "text", "text": "Hello, Claude"}]}

Unmarshalling a valid string message currently fails:

json: cannot unmarshal string into Go struct field Message.messages.content of type []anthropic.MessageContent

I'll put up a patch to handle unmarshalling in the string case.

@liushuangls
Copy link
Owner

Yes, it's written in the documentation that content can be shortened to a string, and I only support array structures for consistency

@liushuangls
Copy link
Owner

Are you saying that claude's response might have a string content? I've never encountered that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants