-
Notifications
You must be signed in to change notification settings - Fork 92
Open
Description
When trying to use the SDK to add a Custom Content Document eg:
{
"type": "document",
"source": {
"type": "content",
"content": [
{"type": "text", "text": "The grass is green."},
{"type": "text", "text": "The sky is blue."}
]
},
"title": "Document Title", # optional
"context": "Context about the document that will not be cited from", # optional
"citations": {"enabled": True}
}
using this code:
// Create content blocks for the structured document
contentBlocks := []anthropic.ContentBlockSourceContentUnionParam{
{
OfString: param.NewOpt("The grass is green."),
},
{
OfString: param.NewOpt("The sky is blue."),
},
}
// Create the document with content source (structured content for citations)
documentBlock := anthropic.NewDocumentBlock(anthropic.ContentBlockSourceParam{
Content: anthropic.ContentBlockSourceContentUnionParam{
OfContentBlockSourceContent: contentBlocks,
},
})
I get the following error from the API:
{"type":"error","error":{"type":"invalid_request_error","message":"messages.0.content.0.document.source.content.content.0: Input should be a valid dictionary or object to extract fields from"},"request_id":"req_011CSoQmM3LxgiryWij2SwUt"}
Looking at the json that was marshaled, we get:
{
"source": {
"content": [
"The grass is green.", <----- these should be objects with type and text keys {"type": "text", "text": "The grass is green."}
"The sky is blue."
],
"type": "content"
},
"context": "This is a trustworthy document.",
"title": "My Document",
"citations": {
"enabled": true
},
"type": "document"
},
It looks like the SDK is not marshaling these correctly.
Metadata
Metadata
Assignees
Labels
No labels