@thinairthings/air-graph v1.3.6
Welcome to thinairthings!
This is a wrapper around Neo4j and OpenAI enabling streamlined handling of application data for AI use cases.
Why?
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.
NOTE Strict null checks must be on in tsconfig.json
Why does this library exist?
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.
Inspired By
Zustand, Liveblocks, React, Neo4j, Cypher
Installation
npm install @thinairthings/air-graph
Configure
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',
})
Define your nodes
Example:
CompanyNode.ts
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
}
}
})
UserNode.ts
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()])
})
})
EmployeeNode.ts
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
}
}
})
Define your graph
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
]
}))
Create nodes. Everything will be fully typed and hopefully feel good.
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.'
})
Relationship (Coming soon...)
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago