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.
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.
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" }
// }
// ]
// }
// }Contributions are welcome! Please open an issue or submit a pull request.
Start the development server:
deno task startFormat, lint, and test before committing:
deno task precommitWe named the Worlds APIâ„¢ after "World Models as a Service" as a nod to the Many-worlds interpretation.
This work is inspired by the intersection of neuro-symbolic AI and knowledge graphs:
- Thinking with Knowledge Graphs (Arxiv)
- World Models (Ha & Schmidhuber)
- MemGPT: Towards LLMs as Operating Systems (Arxiv)
For further information, please refer to our whitepaper.
- 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