Skip to content

Grouloo/origin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Origin: A knowledge base

A side-project aiming to create a knowledge base engine using SQLite and RDF triples.

Getting started

To install dependencies:

bun install

To run:

bun run index.ts

Concepts

Triples

A Triple describes a piece of datum stored in Origin. A Triple holds 3 values: a subject, a predicate, and an object.

The subject represents the entity the triple refers to, the predicate is the property of the entity that the Triple desceibes, and the object is the value of that property.

Example

In Triple form, the sentence "John Doe's email address is [email protected]" would translate to:

{
   "subject": "John Doe",
   "predicate": "email",
   "object": "[email protected]"
}

Subjects

Although Origin stores everything as Triples, it also provides APIs that allow users to manipulate subjects directly.

A subject is an aggregate of all triples that refer to a same thing, and that possesses a unique identifier.

Example

If we have the following triples:

[
   {
      "subject": "subject:john",
      "predicate": "name",
      "object": "John Doe"
   },
   {
      "subject": "subject:john",
      "predicate": "email",
      "object": "[email protected]"
   }
]

They will constitute the following subject:

{
   "id": "john",
   "name": "John Doe",
   "email": "[email protected]"
}

Schema

To keep data coherent, Origin keeps track of your knowledge base schema.

You don't have to provide your schema before using Origin, it will automatically infer the type of the predicates you insert.

When creating a new subject, Origin will iterate through every property and check that the right type is used, or add it to the schema after having inferred the type of the value if it is not known yet.

API

Create a subject

Path

POST /subjects

Body

{
    "property1": "value1",
    "property2": "value2",
    "property3": "value3",
    ...
}

Read a subject

Path

GET /subjects/[id]

SPARQL Query

You can use the SPARQL query language to retrieve data from Origin.

Path

POST /sparql

Body

"[YOUR SPARQL QUERY]"

Insert new subject by using natural language

If you have an OpenAI API key, you can use it in Origin to insert subjects by providing a description in natural language.

Path

POST /tell

Body

"[YOUR DESCRIPTION IN NATURAL LANGUAGE]"

Get schema

Path

GET /schema

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published