Skip to content

[Enhancement]: Make LLM context output layout aware of relationship directionality #807

Description

@suhaniiz

Is your feature request related to a problem? Please describe.

Yes. Currently, the repository uses an undirected graph setup where keys are sorted alphabetically via _relationship_key(left.casefold(), right.casefold()). Because of this, the final string output generated for the RAG prompt context (f"- {item['left']} is related to {item['right']}...") is determined purely by alphabetical string ordering rather than the semantic direction of the query or the actual node relationship flow. This can result in awkward phrasing (e.g., displaying "Fruit is related to Apple" instead of "Apple is related to Fruit"), which slightly degrades the quality of the LLM's final response context.

Describe the solution you'd like

I would like to adjust the context formatting logic so that it respects relationship orientation. When generating the context line items, the origin node matching the user's initial query target should ideally be placed consistently as the primary subject (left), or we should explicitly capture and print the semantic predicate edge type linking the two nodes together to provide the LLM with higher-fidelity context structure.

Describe alternatives you've considered

No response

Additional Context

No response

GSSoC '26

  • Yes, I am participating in GirlScript Summer of Code and would like to build this.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or improvementgssocGirlScript Summer of Code 2026 issue/PR

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions