This is a wrapper around Neo4j and OpenAI enabling streamlined handling of application data for AI use cases.
Graph data models are awesome. So are LLM's. This libraries goal is to help you merge these things so you can do awesome stuff like matching. Examples of this are matching Candidates to Open Jobs, Grant Opportunities to Eligible Small Businesses, and many more things.
TypeScript and functional programming together allows you build really big things and not get lost. The goal of this library is to provide you with some sane defaults and reasonable programming interfaces that will enable you to build complex things from simple building blocks. The major goal is to keep this library as simple as possible.
Zustand, Liveblocks, React, Neo4j, Cypher
npm install @thinairthings/air-graph
import { configureGraphEnvironment } from '@thinairthings/air-graph'
export const {
defineNode,
defineGraph
} = configureGraphEnvironment({
neo4jConfig: {
uri: process.env.NEO4J_URI!,
user: process.env.NEO4J_USERNAME!,
password: process.env.NEO4J_PASSWORD!
},
openaiApiKey: process.env.OPENAI_API_KEY!,
embeddingsModel: 'text-embedding-3-large',
defaultGptModel: 'gpt-3.5-turbo',
})
Example:
import { z } from "zod";
import { defineNode } from "../graph.config";
export const companyNodeDefinition = defineNode({
nodeType: 'Company',
propDefinition: z.object({
companyName: z.string(),
shortDescription: z.string().optional(),
longDescription: z.string().optional(),
website: z.string().url().optional(),
logo: z.string().url().optional()
}),
embeddingsDefinition: {
shortDescription: {
// More explanation on what a contextPointer is coming soon...
contextPointer: `The thing this company does is...`
},
longDescription: {
contextPointer: null
}
}
})
import { z, TypeOf } from 'zod';
import { defineNode } from '../graph.config';
export const userNodeDefinition = defineNode({
nodeType: 'User',
propDefinition: z.object({
firstName: z.string(),
lastName: z.string(),
email: z.string().email(),
password: z.string(),
headshot: z.string().url().optional(),
userType: z.union([z.literal('Recruiter'), z.literal('Candidate'), z.null()])
})
})
import { z } from 'zod';
import { defineNode } from '../graph.config';
export const employeeNodeDefinition = defineNode({
nodeType: 'Employee',
propDefinition: z.object({
position: z.string().optional()
}),
embeddingsDefinition: {
position: {
contextPointer: null
}
}
})
import { defineGraph } from "./graph.config";
import { companyNodeDefinition } from "./nodes/CompanyNode";
import { employeeNodeDefinition } from "./nodes/EmployeeNode";
import { userNodeDefinition } from "./nodes/UserNode";
export const {
createNode
} = defineGraph(({
nodeDefinitions: [
companyNodeDefinition,
employeeNodeDefinition,
userNodeDefinition
]
}))
const user = await createNode('Company', {
companyName: 'Thin Air Things',
shortDescription: 'Thin Air makes things.',
longDescription: 'Thin air makes things that make other things do things.'
})