Skip to main content

Select Fields

Pass specific data from previously generated fields into prompts using dot notation for nested objects and array extraction.

Overview

selectFields lets you include context from earlier fields when generating new ones. Use simple field names, nested paths, or extract values from arrays—ObjectWeaver automatically formats the data for the LLM prompt.

Basic Usage

Simple Field Selection

{
"type": "object",
"properties": {
"title": {
"type": "string",
"instruction": "Generate a title"
},
"summary": {
"type": "string",
"instruction": "Summarize based on the title",
"selectFields": ["title"]
}
},
"processingOrder": ["title", "summary"]
}

The LLM receives:

Summarize based on the title

Context from previous generation:

title:
Product Launch Announcement

Nested Object Access

Access fields inside objects using dot notation:

{
"type": "object",
"properties": {
"product": {
"type": "object",
"properties": {
"name": {"type": "string", "instruction": "Product name"},
"category": {"type": "string", "instruction": "Product category"},
"specs": {
"type": "object",
"properties": {
"weight": {"type": "string", "instruction": "Weight"},
"dimensions": {"type": "string", "instruction": "Dimensions"}
}
}
}
},
"description": {
"type": "string",
"instruction": "Write a product description",
"selectFields": [
"product.name",
"product.category",
"product.specs.weight",
"product.specs.dimensions"
]
}
},
"processingOrder": ["product", "description"]
}

The LLM receives:

Write a product description

Context from previous generation:

product.name:
Industrial Widget

product.category:
Manufacturing Equipment

product.specs.weight:
15kg

product.specs.dimensions:
30cm x 20cm x 10cm

Array Field Extraction

Extract specific fields from all items in an array:

{
"type": "object",
"properties": {
"reviews": {
"type": "array",
"items": {
"type": "object",
"properties": {
"author": {"type": "string", "instruction": "Reviewer name"},
"rating": {"type": "number", "instruction": "Rating 1-5"},
"comment": {"type": "string", "instruction": "Review text"}
}
}
},
"summary": {
"type": "string",
"instruction": "Summarize review ratings and key themes",
"selectFields": ["reviews.rating", "reviews.comment"]
}
},
"processingOrder": ["reviews", "summary"]
}

The LLM receives:

Summarize review ratings and key themes

Context from previous generation:

reviews.rating:
- 5
- 4
- 5
- 3

reviews.comment:
- Excellent product, highly recommend
- Good quality but expensive
- Perfect for my needs
- Decent but could be better

Real-World Example: Email Analysis

{
"type": "object",
"properties": {
"email": {
"type": "object",
"properties": {
"subject": {"type": "string", "instruction": "Extract subject line"},
"sender": {"type": "string", "instruction": "Extract sender email"},
"urgency": {"type": "string", "instruction": "Classify urgency: low, medium, high"}
}
},
"attachments": {
"type": "array",
"items": {
"type": "object",
"properties": {
"filename": {"type": "string", "instruction": "Attachment filename"},
"type": {"type": "string", "instruction": "File type"}
}
}
},
"actionItems": {
"type": "array",
"items": {
"type": "string"
},
"instruction": "List action items required",
"selectFields": [
"email.subject",
"email.urgency",
"attachments.filename"
]
}
},
"processingOrder": ["email", "attachments", "actionItems"]
}

Combining with Decision Points

Use selectFields in conditional branches:

{
"type": "object",
"properties": {
"document": {
"type": "object",
"properties": {
"type": {"type": "string", "instruction": "Document type"},
"complexity": {"type": "number", "instruction": "Complexity score 1-10"}
}
},
"analysis": {
"type": "string",
"instruction": "Analyze the document",
"decisionPoint": {
"branches": [
{
"name": "complex-technical",
"conditions": [
{
"fieldPath": "document.type",
"operator": "eq",
"value": "technical"
},
{
"fieldPath": "document.complexity",
"operator": "gt",
"value": 7
}
],
"then": {
"type": "string",
"instruction": "Provide detailed technical analysis",
"selectFields": ["document.type", "document.complexity"],
"model": "gpt-4"
}
},
{
"name": "simple",
"conditions": [
{
"fieldPath": "document.complexity",
"operator": "lte",
"value": 7
}
],
"then": {
"type": "string",
"instruction": "Provide standard analysis",
"selectFields": ["document.type"],
"model": "gpt-3.5-turbo"
}
}
]
}
}
},
"processingOrder": ["document", "analysis"]
}

Path Syntax Reference

SyntaxDescriptionExample
"fieldName"Simple field access"title"
"object.field"Nested object access"product.name"
"object.nested.field"Multi-level nesting"user.address.city"
"array.field"Extract field from all array items"reviews.rating"

How It Works

  1. Path Resolution: ObjectWeaver traverses the generated data structure using dot notation
  2. Array Handling: When a path crosses an array, it extracts that field from every item
  3. Formatting: Values are formatted for readability—arrays become bullet lists, objects become key-value pairs
  4. Prompt Injection: Formatted context is injected into the field's prompt before LLM generation

Error Handling

  • Non-existent paths: Logged and skipped (generation continues)
  • Invalid navigation: Stops at first non-navigable type (e.g., trying to access a property on a primitive)
  • Empty arrays: Treated as field not found
  • Partial array matches: Only matching items included

Best Practices

Keep Context Focused

Only include fields that are relevant to the current generation:

// ✅ Good - focused context
"selectFields": ["product.name", "product.category"]

// ❌ Bad - too much noise
"selectFields": ["product"] // Includes all nested fields

Use with Processing Order

Always define processingOrder to ensure fields are generated before they're referenced:

{
"properties": {
"data": {...},
"analysis": {
"selectFields": ["data.metric"],
...
}
},
"processingOrder": ["data", "analysis"]
}

Array Extraction for Summaries

Perfect for summarizing repeated data:

{
"properties": {
"transactions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"amount": {"type": "number"},
"category": {"type": "string"}
}
}
},
"summary": {
"type": "string",
"instruction": "Summarize spending by category",
"selectFields": ["transactions.amount", "transactions.category"]
}
}
}

Backward Compatibility

All existing schemas work without modification. Simple field names (no dots) function exactly as before—this feature only activates when dot notation is used.

See Also