knowledge-graph
Skill6 starsChanged 23 days agoApache-2.0View on GitHub
Build and query knowledge graphs with PostgreSQL + pgvector. Ingest episodes, extract entities/relations via LLM, and search facts by semantic similarity or keyword. Use when working with knowledge graphs, entity extraction, or graph storage.
Files
knowledge-graph
Build and query knowledge graphs using saige/knowledge.
Quick Start
import (
"github.com/urmzd/saige/rag/knowledge"
"github.com/urmzd/saige/postgres"
"github.com/urmzd/saige/agent/provider/ollama"
)
// Connect to PostgreSQL (requires pgvector extension).
pool, _ := postgres.NewPool(ctx, postgres.Config{URL: "postgres://localhost:5432/mydb"})
postgres.RunMigrations(ctx, pool, postgres.MigrationOptions{})
client, _ := ollama.NewClient(ollama.Config{Host: "http://localhost:11434", Model: "qwen3.5:4b", EmbeddingModel: "nomic-embed-text"})
graph, _ := knowledge.New(knowledge.Config{},
knowledge.WithPostgres(pool),
knowledge.WithExtractor(knowledge.NewOllamaExtractor(client)),
knowledge.WithEmbedder(knowledge.NewOllamaEmbedder(client)),
)
defer graph.Close(ctx)
// Ingest
graph.IngestEpisode(ctx, &knowledge.EpisodeInput{
Name: "notes", Body: "Alice presented the roadmap.", Source: "meeting",
})
// Search
facts, _ := graph.SearchFacts(ctx, "roadmap")Key Operations
| Method | Purpose |
IngestEpisode | Extract entities/relations from text and store them |
SearchFacts | Full-text search on relation facts |
GetEntity | Retrieve a single entity by ID |
GetNode | Get a node with its neighborhood (depth N) |
GetGraph | Full graph snapshot for visualization |
ApplyOntology | Constrain entity/relation types |
Ontology
graph.ApplyOntology(ctx, &knowledge.Ontology{
EntityTypes: []knowledge.EntityTypeDef{{Name: "Person", Description: "A human"}},
RelationTypes: []knowledge.RelationTypeDef{{Name: "works_on", SourceType: "Person", TargetType: "Project"}},
})The ontology is passed to the extractor, which is asked to use its types. Extracted types that match an ontology type ignoring case and punctuation are rewritten to the ontology's spelling; other types are kept as extracted. Build the graph with knowledge.WithStrictOntology() to drop entities and relations whose type is not in the ontology.
Agent Tool Bindings
import "github.com/urmzd/saige/rag/knowledge/tool"
tools := tool.NewTools(graph, tool.WithGroupID(tenantID))
// kg_search, kg_ingest, both bound to one graph group the model cannot changeIn a RAG pipeline, rag.WithGraphNamespace(tenantID) sets the group documents are ingested into and the graph retriever searches.
CLI
saige knowledge search --backend kg --db "$SAIGE_KG_DB" --query "Who presented?"
saige knowledge ingest --backend kg --db "$SAIGE_KG_DB" --name "meeting" --text "Alice presented the roadmap."
saige knowledge graph export --db "$SAIGE_KG_DB"
saige knowledge graph neighbors --db "$SAIGE_KG_DB" --id <entity-uuid> --depth 2Other versions21 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 21
- llopresto87/Cypress★ 119same name
- AsiaOstrich/universal-dev-standards★ 82same name
- Happy-Technologies-LLC/happy-platform-skills★ 41same name
- iagocavalcante/claude-turbo-search★ 16same name
- iuiaoin/agent-skills★ 16same name
- Alexander-Tyagunov/magician★ 14same name
- ariaxhan/kernel-claude★ 14same name
- cirwel/unitares★ 6same name
- nikhilw/structured-agentic-workflow★ 6same name
- Bartosh16/claude-skills★ 3same name
11 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

