Hermes

hermes.systems

Systems

A system is a callable that turns a question into SPARQL. Registering it by name lets callers swap methods without changing their code.

Contract

def system(question, ontology, context):
    return {"sparql": "..."}

question is a string. ontology is a path to a Turtle file. context is a Context or None. The return value is a dict with at least sparql. A system may add keys such as model and provider.

Source: systems.py.

Register a system

import hermes

@hermes.systems.register("my-system")
def my_system(question, ontology, context):
    return {"sparql": "SELECT * WHERE { ?s ?p ?o } LIMIT 1"}

A name can be registered once. A second registration under the same name raises ValueError. hermes.systems.available() lists the names, sorted.

Run one

hermes.ask("Which counties have the most outages?", "GeoOutage.ttl", system="my-system")

An unknown name raises KeyError that lists the available systems. From the shell, hermes systems prints the names and hermes generate --system NAME runs one.

Shipped systems

NameWhat it does
training-freePrompts a model with the ontology vocabulary, then runs stages and validation. Details.

More systems are expected here. Each one is added behind the same interface, so results can be compared system by system.