Recently studying Ollama's API DocumentationWhen it's hard to build up complete relationships in your head, it's a good idea to generate Mermaid-formatted relationship diagrams from API documents that represent only factual relationships. Of course, you can also use it to sort out the document's character relationships, event relationships, time relationships... and so on. And so on.
clue
(defvar Extracting the knowledge graph ( (Knowledge graph construction guide (Topic Extraction "Please identify the core topics and key concepts in the text.") (Hierarchical Relationships "Analyze hierarchical, containment and juxtaposition relationships between concepts.") (Cause and Effect Relationships "Identify cause and effect, influence and dependency relationships between concepts.") (Chronological Relationships "Sort out the chronological order of events and concepts.") (Comparative Relationships "Compare and contrast the similarities, differences, and correlations of different concepts.") (Clustering grouping "Clustering related concepts and dividing them into subgraphs")) (Output constraints (Constraint "Output is formatted as Mermaid chart code")) (constraint "Node labels and relationship labels are in Chinese")) (constraint "Don't return anything outside of the knowledge graph")) (node and relationship definitions (Formatted " ```mermaid\ngraph LR\n")) (Formatted " %% Definition of nodes based on core concepts extracted from topics")) (Formatted " A[\"%s\"]" Node A name) (Formatted " B[\"%s\"]" node B name) (Formatted " %% Define connection based on conceptual relationship.") (Formatted " %s -->|\"%s\"| %s" Start node Relationship description Target node) ;; Other node and relationship definitions ) (Subgraph and style definitions (formatting " %% Define subgraphs based on conceptual clustering") (formatting " subgraph \"%s\"\n" subgraph name) (traverse (lambda (node) (formatted " %s\n" node)) list of subgraph nodes) (format " end\n") (formatting " %% Define uniform style") (formatting " classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px;\n") (traverse (lambda (node) (format " class %s highlight;\n" node)) list of highlighted nodes) ;; Other subgraphs and style definitions ) (Dynamic data and custom styles (formatting " %% Handling dynamic variables ") (Formatting " A[\"{{%s}}\"]" node A variables) (Format " B[\"{{%s}}\"]" node B variable) (Formatted " %% Define custom style") (formatting " classDef customStyle fill:#00ff00,stroke:#000,stroke-width:3px;\n") (traversing (lambda (node) (formatting " class %s customStyle;\n" node)) list of custom style nodes) ;; Other dynamic data and custom styles (formatted " ```") ) )) </system_instruction ${content}
How to use
Role: Quickly build up a graphical relationship of important information in the document, visualize and read quickly
Usage document content replacement to:${content}
placement
The generated code is previewed at: https://mermaid.live/