Skip to content

Instantly share code, notes, and snippets.

View dzhng's full-sized avatar

David Zhang dzhng

View GitHub Profile
@dzhng
dzhng / gist:89242d2acee433ab4c2f250989190097
Created December 2, 2023 01:56
Create knowledge graph
import { z } from 'zod';
import { anthropicCompletion } from '@/services/llm';
const systemMessage = `Convert the input content into a knowledge graph. Return the data in valid JSON, in the form of nodes and edges.
Example:
{
"nodes": [ { "id": 1, "type": "company", "title": "Hugging Face" }, { "id": 2, "type": "product", "title": "Hugging Face Hub" }, { "id": 3, "type": "benefit", "title": "Model Repository", "quote": "Centralized model repository to store, version and share NLP models." } ],
"edges": [ { "source": 1, "target": 2, type: "includes" }, { "source": 2, "target": 3, type: "includes" } ]