UpdateLegalNamePipeline
What it is
- A pipeline that conditionally adds an
ABI.isLegalNameOfrelationship between a legal-name individual and an organization in an RDF triple store. - Returns the updated RDF graph for the legal-name individual.
Public API
UpdateLegalNamePipelineConfiguration(PipelineConfiguration)- Fields:
triple_store: ITripleStoreService- triple store service used to fetch and insert RDF triples.
- Fields:
UpdateLegalNamePipelineParameters(PipelineParameters)- Fields:
individual_uri: str- URI of the legal name individual (validated byURI_REGEX).organization_uri: Optional[str]- organization URI to relate viaABI.isLegalNameOf(validated byURI_REGEX).
- Fields:
UpdateLegalNamePipeline(Pipeline)__init__(configuration: UpdateLegalNamePipelineConfiguration)- Stores configuration (notably the triple store service).
run(parameters: PipelineParameters) -> rdflib.Graph- Validates
parameterstype. - Loads the subject graph for
individual_uri. - If
organization_uriis provided and the triple does not already exist, inserts:(individual_uri, ABI.isLegalNameOf, organization_uri)
- Persists inserted triples to the triple store and returns the merged graph.
- Validates
as_tools() -> list[langchain_core.tools.BaseTool]- Exposes the pipeline as a LangChain
StructuredToolnamedupdate_legal_name.
- Exposes the pipeline as a LangChain
as_api(...) -> None- Present but does not register any routes (no-op).
Configuration/Dependencies
- Requires an
ITripleStoreServiceimplementation providing at least:get_subject_graph(subject: rdflib.term.Identifier) -> rdflib.Graphinsert(graph: rdflib.Graph) -> None
- Uses:
rdflib.Graph,rdflib.URIRef- Ontology constants:
ABI.isLegalNameOf - Pydantic validation via
Field(..., pattern=URI_REGEX)
Usage
from naas_abi.pipelines.UpdateLegalNamePipeline import (
UpdateLegalNamePipeline,
UpdateLegalNamePipelineConfiguration,
UpdateLegalNamePipelineParameters,
)
# triple_store must be an ITripleStoreService implementation
config = UpdateLegalNamePipelineConfiguration(triple_store=triple_store)
pipeline = UpdateLegalNamePipeline(config)
params = UpdateLegalNamePipelineParameters(
individual_uri="https://example.org/legal-name/123",
organization_uri="https://example.org/org/456",
)
updated_graph = pipeline.run(params)
print(len(updated_graph))
As a LangChain tool
tool = pipeline.as_tools()[0]
result_graph = tool.run({
"individual_uri": "https://example.org/legal-name/123",
"organization_uri": "https://example.org/org/456",
})
Caveats
run()only acceptsUpdateLegalNamePipelineParameters; passing any otherPipelineParametersraisesValueError.- If
organization_uriis not provided, no changes are inserted. as_api()is implemented as a no-op; no API endpoint is exposed by this class.