Skip to content

EthanThatOneKid/worlds-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Worlds APIâ„¢

JSR JSR score GitHub Actions

Worlds APIâ„¢ is a REST API designed to manage, query, update, and reason over SPARQL 1.1-compatible knowledge bases at the edge. It places malleable knowledge within arm's reach of your AI agent.

Design

Bring your own brain (BYOB). Worlds APIâ„¢ is agnostic to the agent using it.

Powered by N3. Worlds APIâ„¢ leverages N3 for high-performance store operations.

Usage

You can use the Worlds API SDK to interact with your knowledge bases programmatically.

import { World } from "@fartlabs/worlds";

// Initialize the client for a specific world.
const world = new World({
  baseUrl: "http://localhost:8000/v1",
  apiKey: "your-api-key",
  worldId: "my-knowledge-base",
});

// Add some knowledge (triples) to your world.
await world.sparqlUpdate(`
  INSERT DATA {
    <http://example.com/ethan> <http://schema.org/relatedTo> <http://example.com/gregory> .
    <http://example.com/gregory> <http://schema.org/givenName> "Gregory" .
  }
`);

// Search your world to find the named node for Gregory.
const searchResult = await world.search("Gregory");

console.log(searchResult);
// [
//   {
//     score: 0.9,
//     value: {
//       subject: "http://example.com/gregory",
//       predicate: "http://schema.org/givenName",
//       object: "Gregory"
//     }
//   }
// ]

// Reason over your world using SPARQL.
const result = await world.sparqlQuery(`
  SELECT ?name WHERE {
    <http://example.com/ethan> <http://schema.org/relatedTo> ?person .
    ?person <http://schema.org/givenName> ?name .
  }
`);

console.log(result);
// {
//   head: { vars: [ "name" ] },
//   results: {
//     bindings: [
//       {
//         name: { type: "literal", value: "Gregory" }
//       }
//     ]
//   }
// }

Development

Contributions are welcome! Please open an issue or submit a pull request.

Start the development server:

deno task start

Format, lint, and test before committing:

deno task precommit

Etymology

We named the Worlds APIâ„¢ after "World Models as a Service" as a nod to the Many-worlds interpretation.

Research

This work is inspired by the intersection of neuro-symbolic AI and knowledge graphs:

For further information, please refer to our whitepaper.

Glossary

  • Neuro-symbolic AI: An AI system that combines the strengths of neural networks and structured data.
  • RDF: A W3C standard for representing information.
  • SPARQL: A W3C standard for querying and updating RDF data.
  • Ontology: A formal description of a domain of knowledge.

Developed with 🧪 @FartLabs

About

🔵 Worlds API™ is the infrastructure layer for knowledge.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published