Skip to content

Detect Entities In Content

POST
/api/writing/entities/detect

πŸ” Detect entities in document content for auto-linking

Analyzes text content to detect entities with position tracking for automatic linking suggestions. Uses semantic search and pattern matching to identify characters, locations, concepts, and other entities.

Request Body:

  • content: Text content to analyze
  • minConfidence: Minimum confidence threshold (0-1, default: 0.7)
  • maxSuggestions: Maximum number of suggestions (default: 20)
  • context: Optional context (documentTitle, tags, category, knownEraLabels)

Returns:

  • Detection result with entity matches, positions, and metadata

Raises:

  • HTTPException 500: If entity detection fails

Example Request:

{
    "content": "Aragorn traveled to Rivendell to meet Elrond.",
    "minConfidence": 0.7,
    "maxSuggestions": 20,
    "context": {
        "documentTitle": "Chapter 1",
        "category": "fantasy"
    }
}

Example Response:

{
    "status": "success",
    "matches": [
        {
            "entity": "Aragorn",
            "confidence": 0.95,
            "type": "character",
            "startPos": 0,
            "endPos": 7,
            "description": "Ranger and heir to the throne"
        }
    ],
    "processingTime": 45
}
EntityDetectionRequest

Request model for detecting entities in document content for auto-linking.

Used by the AutoLinkService to analyze text content and identify entities (characters, locations, concepts) with position tracking for automatic wiki-style linking suggestions.

Fields:

  • content: Text content to analyze for entities
  • min_confidence: Minimum confidence threshold (0-1, default: 0.7)
  • max_suggestions: Maximum number of entity suggestions to return
  • context: Optional context for improved detection accuracy

Detection Process:

  1. Extract candidate entities from text (capitalized words/phrases)
  2. Perform semantic search against entity collections (ChromaDB)
  3. Calculate confidence scores based on semantic similarity
  4. Filter by confidence threshold and limit results
  5. Return matches with position information

Usage: POST /api/writing/entities/detect for entity detection.

JSON Example:

{
  "content": "Aragorn traveled to Rivendell to meet Elrond.",
  "minConfidence": 0.7,
  "maxSuggestions": 20,
  "context": {
    "documentTitle": "Chapter 1",
    "category": "fantasy"
  }
}

Response: EntityDetectionResponseDict with status, matches, and processingTime.

object
content
required
Content

Text content to analyze for entities

string
minConfidence
Minconfidence

Minimum confidence threshold

number
default: 0.7 <= 1
maxSuggestions
Maxsuggestions

Maximum suggestions to return

integer
default: 20 >= 1 <= 100
context
Any of:
EntityDetectionContextModel

Optional context for entity detection to improve accuracy.

Fields:

  • document_title: Title of the document being analyzed
  • tags: Document tags for context filtering
  • category: Document category
  • known_era_labels: Era abbreviations from project calendar systems for temporal detection boost
  • full_document: Full document text when content is only a selection β€” enables structure-aware classification using surrounding context
object
documentTitle
Any of:
string
tags
Any of:
Array<string>
category
Any of:
string
knownEraLabels
Any of:
Array<string>
fullDocument
Any of:
string
documentId
Any of:
string

Successful Response

EntityDetectionResponseDict

Response dictionary from AutoLinkService.detect_entities.

object
status
Status
string
matches
Matches
Array<object>
EntityMatchDict

Entity match dictionary structure from AutoLinkService.

object
entity
Entity
string
confidence
Confidence
number
type
Type
string
startPos
Startpos
integer
endPos
Endpos
integer
description
Description
string
loreEntryId
Loreentryid
string
loreEntryTitle
Loreentrytitle
string
matchSource
Matchsource
string
portraitUrl
Portraiturl
string
aliases
Aliases
Array<string>
processingTime
Processingtime
number
candidateCount
Candidatecount
integer
matchSources
Matchsources
object
key
additional properties
integer
error
Error
string

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