Skip to main content

RELATIONSHIP_INFERENCE_PROMPT

Constant RELATIONSHIP_INFERENCE_PROMPT 

Source
pub const RELATIONSHIP_INFERENCE_PROMPT: &str = r#"<operation_mode>relationship_inference</operation_mode>

<task>
Analyze the provided entities and infer likely relationships between them.
These entities already exist in the knowledge graph. Your task is to discover
implicit connections based on their types, names, and any available properties.
</task>

<entity_types>
- Person: Individual people
- Organization: Companies, teams, departments
- Technology: Programming languages, frameworks, tools
- Concept: Abstract ideas, patterns, principles
- File: Source files, configurations
</entity_types>

<relationship_types>
- WorksAt: Person → Organization (employment)
- Created: Entity → Entity (authorship/creation)
- Uses: Entity → Technology (dependency/usage)
- Implements: Entity → Concept (realization of concept)
- PartOf: Entity → Entity (composition/membership)
- RelatesTo: Entity → Entity (general association)
- DependsOn: Technology → Technology (technical dependency)
- Supersedes: Entity → Entity (replacement)
- ConflictsWith: Entity → Entity (contradiction)
</relationship_types>

<guidelines>
- Infer relationships based on common patterns (e.g., Rust → Uses → cargo)
- Consider entity types when inferring relationships
- Assign confidence scores (0.0-1.0) based on inference strength:
  - 0.9+: Near-certain (e.g., PostgreSQL Uses SQL)
  - 0.7-0.9: Likely (e.g., Python project likely Uses pip)
  - 0.5-0.7: Possible but uncertain
- Include reasoning for each inferred relationship
- Do NOT infer relationships that are obvious duplicates of existing ones
- Focus on meaningful, non-trivial connections
</guidelines>

<output_format>
Respond with a JSON object:
{
  "relationships": [
    {
      "from": "source entity name",
      "to": "target entity name",
      "type": "RelationshipType",
      "confidence": 0.85,
      "reasoning": "brief explanation of why this relationship was inferred"
    }
  ]
}
</output_format>"#;
Expand description

Relationship inference prompt for discovering implicit relationships.

Used by the EntityExtractorService to infer relationships between existing entities that weren’t explicitly stated in text.