Skip to content

Enrich Content

POST
/api/agents/integrate/enrich

Enrich content with data from external sources.

Enhances provided content by fetching related information from external knowledge sources. All configured sources fire in parallel. Sources that cannot contribute (not yet implemented, timeout, no results) are surfaced in failed_sources so the UI can show transparent state rather than silently dropping sources.

Supported sources:

  • wikipedia — REST page-summary for the top extracted concept.
  • academic — Parallel CrossRef + arXiv lookup, merged into one entry.
  • news — Reserved; returns a failed_sources entry.
  • social — Reserved; returns a failed_sources entry.

Process:

  1. Extract salient concepts from content via a lean keyword pass.
  2. Dedupe and cap the requested sources at max_enrichments.
  3. Fan out to all sources via asyncio.gather.
  4. Combine enrichments; stamp each with a bag-of-words relevance score.
  5. Return enrichments, entities, deduped sources-used, and failed sources.

Args: request: EnrichContentRequest with content and enrichment sources.

Returns: EnrichContentResponse with enrichments, additional entities, and success=True only if at least one source contributed.

Raises: HTTPException 503: Lagan API integrator not initialized.

Example:

POST /api/agents/discovery/integrate/enrich
{
    "content": "The role of AI in modern healthcare...",
    "enrichment_sources": ["wikipedia", "academic"],
    "max_enrichments": 5
}
EnrichContentRequest

Request to enrich content with external data.

Enriches provided content by fetching additional information from external sources and extracting additional entities.

Fields:

  • content: Content to enrich (required, non-empty)
  • enrichment_sources: External sources to use for enrichment (required, non-empty)
  • max_enrichments: Maximum number of enrichments to add (1-20, default 5)

Enrichment Sources:

  • wikipedia: Wikipedia data enrichment
  • academic: Academic paper references
  • news: Recent news articles
  • social: Social media mentions

Usage: Used to enrich content with external data and references.

Integration:

  • IntegrationRoutes: Request validation for /integration/enrich endpoint
  • LaganAgent: Content enrichment processing
object
content
required
Content

Content to enrich

string
>= 1 characters
enrichmentSources
required
Enrichmentsources

External sources to use for enrichment (e.g., ‘wikipedia’, ‘academic’)

Array<string>
>= 1 items
maxEnrichments
Maxenrichments

Maximum number of enrichments to add

integer
default: 5 >= 1 <= 20

Successful Response

EnrichContentResponse

Response with enriched content.

Provides enrichment data from external sources with additional entities and quality confidence scoring.

Fields:

  • success: True if at least one source contributed an enrichment
  • original_content: Original content that was enriched
  • enrichments: List of enrichment entries (source, data, relevance)
  • enriched_entities: Additional entities discovered through enrichment
  • sources_used: Deduplicated list of sources that successfully contributed
  • failed_sources: Sources that were requested but did not contribute (with reason)
  • confidence: Enrichment quality confidence score (0.0-1.0)

Usage: Returned by content enrichment endpoints.

Integration:

  • IntegrationRoutes: Response model for /integration/enrich endpoint
  • Frontend: Enriched content display
object
success
required
Success

True if at least one source contributed

boolean
originalContent
required
Originalcontent

Original content

string
enrichments
Enrichments

Enrichment data from external sources

Array<object>
object
key
additional properties
any
enrichedEntities
Enrichedentities

Additional entities found through enrichment

Array<object>
Entity

Extracted entity from content with type classification and confidence scoring.

Represents a named entity (person, place, organization, concept, etc.) extracted from analyzed content with confidence scoring and contextual information.

Fields:

  • name: Entity name or identifier as extracted from content
  • entity_type: Classification type (person, place, organization, concept, etc.)
  • confidence: Extraction confidence score from 0.0 to 1.0
  • context: Surrounding text context where entity was found

Usage: Used in perception and research responses to return extracted entities.

Integration:

  • WebpagePerceptionResponse: Entity list in perception results
  • ResearchResult: Entities extracted from research results
  • EnrichContentResponse: Additional entities from enrichment
object
name
required
Name

Entity name or identifier

string
entityType
required
Entitytype

Entity type (person, place, concept, etc.)

string
confidence
required
Confidence

Extraction confidence score

number
<= 1
context
Any of:
string
sourcesUsed
Sourcesused

External sources consulted

Array<string>
failedSources
Failedsources

Requested sources that did not contribute, with reason

Array<object>
FailedSource

An enrichment source that failed or was skipped.

Surfaced in EnrichContentResponse.failed_sources so the UI can show “not configured” / “not available” instead of the source silently disappearing from the response.

object
source
required
Source

Source name as requested (e.g., ‘academic’)

string
error
required
Error

Reason the source did not contribute

string
confidence
required
Confidence

Enrichment quality confidence

number
<= 1

Validation Error

HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object