Skip to content

skorotkiewicz/dijkstra-text-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Dijkstra Text Generator

Generate sentences by finding the shortest path through a word-graph using Dijkstra's Algorithm.

Topic β†’ LLM β†’ Word Graph β†’ Dijkstra β†’ Sentence

Quick Start

node examples/simple.js

Usage

const { TextGenerator } = require("./index.js");

const gen = new TextGenerator({
  baseURL: "http://localhost:8888/v1",
  startWord: "The"
});

const result = await gen.generate("animals", 5);
console.log(result.sentence);  // "The quick brown fox jumps"

Examples

Example Description
simple.js Basic usage with verbose output
game_mechanic.js Spell casting system using path distance as mana cost
seo_strategy.js Internal linking structure for SEO topic clusters
visualizer.js Export word graph to GraphViz DOT format
node examples/game_mechanic.js   # βš”οΈ Mana-based spell casting
node examples/seo_strategy.js    # πŸ”— SEO link clusters  
node examples/visualizer.js      # πŸ‘οΈ GraphViz output

How It Works

  1. Fetch word transitions from LLM API
  2. Build directed graph (words = nodes, transitions = edges)
  3. Find shortest path of target length via Dijkstra
  4. Return path as sentence

License

MIT

About

Word Wizardry - Dijkstra-powered sentences, crafted from LLM magic

Topics

Resources

Stars

Watchers

Forks

Contributors