Overview
Thelink() method creates directional relations between resources, enabling you to build a knowledge graph of connected contexts. Relations help organize information and improve retrieval.
Relations are directional: linking A → B does not automatically create B → A.
Method Signature
Parameters
string
required
Source URI to link from
string | List[string]
required
Target URI(s) to link to. Can be a single string or list of URIs.
string
default:""
Human-readable explanation of why resources are related
Examples
Link Single Resource
Link Multiple Resources
Build Knowledge Graph
Link Documentation Chain
Response
Use Cases
- Code-to-Docs Mapping - Link implementation files to their documentation
- Citation Networks - Connect papers, articles, and references
- Example Organization - Link tutorials to their example code
- Concept Graphs - Build semantic networks between ideas
- Navigation Hints - Create “see also” or “related” connections
Best Practices
Notes
- Relations are directional: A → B ≠ B → A
- Relations are stored persistently in the context database
- Relations improve retrieval: related resources can be discovered during semantic search
- Use
relations()to query existing links - Use
unlink()to remove relations
Related Methods
- relations() - Query relations for a URI
- unlink() - Remove relations
- find() - Semantic search uses relations for context
