CreateResponseWithSources 1.0.0¶
Overview¶
Description¶
⚠️ DEPRECATED: This block will be removed in a future version. Instead connect the sources output from your LLM block directly to the Sources output for the flow.
Creates a standardized API response that combines content with source attributions. This block formats content and properly structures source references for downstream consumption.
Configuration Options¶
No configuration options available.
Inputs¶
| Name | Data Type | Description |
|---|---|---|
| content | Any | The main response content. Can be string or any object that will be JSON-serialized if not already a string. |
| sources | list[Source] or str or Constant(value=None) | Source attributions for the content. Accepts structured Source objects, a simple string path, or null for no sources. |
Outputs¶
| Name | Data Type | Description |
|---|---|---|
| response | ApiResponse | A structured API response containing formatted content and properly indexed source attributions. |
Examples¶
# Basic response with simple string source
name: format_response
type: CreateResponseWithSources
inputs:
content: "Based on company policies, returns are accepted within 30 days."
sources: "/documents/return_policy.pdf"
outputs:
response: "formatted_api_response"
Error Handling¶
JSON Serialization Error
- Error Code
JSONSerializationError- Common Cause
- Content object contains non-serializable data types (functions, complex objects)
- Solution
- Ensure content contains only JSON-serializable data types (strings, numbers, lists, dicts)
Invalid Source Format
- Error Code
ValidationError- Common Cause
- Source objects don't match the expected Source schema structure
- Solution
- Verify Source objects have required fields (index, container_item_path) or use simple string sources
FAQ¶
What's the recommended replacement for this deprecated block?
Connect the sources output from your LLM block directly to the Sources output for the flow. This eliminates the need for an intermediate formatting step and provides cleaner architecture.
How does string source conversion work?
When you pass a simple string as the sources input, the block automatically converts it to a Source object with index=1 and container_item_path set to your string value.
What happens if I pass non-string content?
The block will serialize non-string content to JSON with 4-space indentation. This is useful for structured responses but ensure your objects are JSON-serializable.
Can I pass null or empty sources?
Yes, if sources is null or empty, the response will be created with an empty sources array. This is valid for content that doesn't require source attribution.
What's the difference between ApiResponse and raw content?
ApiResponse provides a standardized structure with separate content and sources fields, making it easier for API consumers to handle responses consistently across different workflows.