Skip to content

Generate Entity Graph

POST
/api/writing/entities/graph

🕸️ Generate an entity relationship graph

Creates a visual knowledge graph showing relationships between entities (characters, locations, organizations). Provides nodes, edges, and relationship types for visualization and lore consistency analysis.

Request Body:

  • request: EntityGraphRequest with entity filters and graph depth

Dependencies:

  • writing_service: Injected IshvanaWritingModule instance

Returns:

  • EntityGraphResponse with nodes (entities) and edges (relationships)

Raises:

  • HTTPException 500: If graph generation fails

Example Response:

{
    "nodes": [
        {"id": "char_1", "name": "Vinyata", "type": "character"}
    ],
    "edges": [
        {"source": "char_1", "target": "loc_1", "type": "resides_in"}
    ]
}
EntityGraphRequest

Entity relationship graph generation request model.

Request model for generating an entity relationship graph visualization with configurable depth and node limits.

Fields: center_entity: Optional center entity (None = all entities) depth: Relationship traversal depth (default: 2 hops) max_nodes: Maximum nodes to include in graph (default: 50) entity_type: Optional filter by entity type (character, location, etc.) content: Optional content to extract entities from

Used By: - POST /api/writing/entities/graph endpoint - Entity graph visualization UI - Relationship exploration - Worldbuilding visualization

object
centerEntity
Any of:
string
depth
Depth
integer
default: 2
maxNodes
Maxnodes
integer
default: 50
entityType
Any of:
string
content
Any of:
string

Successful Response

EntityGraphResponse

Entity relationship graph response model.

Provides nodes and edges for entity relationship graph visualization, compatible with graph visualization libraries (D3.js, Cytoscape, etc.).

Fields: nodes: List of graph nodes with entity data edges: List of graph edges with relationship data

Node Format: {“id”: “entity_name”, “type”: “character”, “label”: “Valko”}

Edge Format: {“source”: “entity1”, “target”: “entity2”, “type”: “allies”}

Used By: - POST /api/writing/entities/graph endpoint response - Graph visualization components - Interactive worldbuilding explorer - Relationship mapping visualization

object
nodes
required
Nodes
Array<object>
object
key
additional properties
Any of:
string
edges
required
Edges
Array<object>
object
key
additional properties
Any of:
string
status
Any of:
string
message
Any of:
string
nodeCount
Any of:
integer
edgeCount
Any of:
integer
maxDepth
Any of:
integer
centerEntity
Any of:
string
entityType
Any of:
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