Code Generation - statnett/Talk2PowerSystem GitHub Wiki
Most of the project is about Natural Language Querying (NLQ), i.e. SPARQL/GraphQL generation.
But we may also want to explore code generation for some existing Power System Analytics libraries. Here are some ideas:
- Q2.7 Calculate Operational Limits proposes an external function call. For this to work, we first need to instantiate CIM data as in-memory objects. Statnett has some internal tooling (in Kotlin) that can take a collection of triples from GraphDB and makes it easy to write business logic without "knowing" anything about RDF. For the integration to work, the AI needs to pass the triples that will be used (or at least their subjects). Usage example taken from the README:
val manager = SomeEntityManager(collectionOfTriples, Cim100ClassLookup)
// Load existing data
val segment = manager.load("https://href.ref.no/aclinesegment/1") as ConductingEquipment
// Create a new instance
val terminal = manager.create<Terminal>().apply {
mRID = "whatever"
conductingEquipment = segment
}
- Generate LinkML from CIM ontologies with CIMtool (Statnett) and review for adequacy (Graphwise)
- Generate PowerSystemPy SDK from LinkML (Statnett)
In addition to code generation, we need to setup a code execution sandbox (ala ChatGPT "Advanced Analytics" plugin). See proposal for some pointers, but more research is needed to find the best solution