feat(datafabric): fetch ontology R2RML alongside OWL#935
Open
sankalp-uipath wants to merge 2 commits into
Open
feat(datafabric): fetch ontology R2RML alongside OWL#935sankalp-uipath wants to merge 2 commits into
sankalp-uipath wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the Data Fabric inner SQL agent’s fetch_ontology tool to retrieve an ontology’s optional R2RML mapping alongside its OWL schema, so the LLM is grounded not only in semantic terms but also in how they map onto concrete entity tables/columns.
Changes:
- Fetch both
owlandr2rmlper configured ontology viaEntitiesService.get_ontology_file_async, concatenating results with deterministic ordering and caching. - Treat R2RML as optional (silently skipped on failure) while keeping OWL as required (graceful degradation message on failure/oversize/empty).
- Expand unit tests to assert both file types are requested and to verify the R2RML-present/absent behaviors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/uipath_langchain/agent/tools/datafabric_tool/ontology_fetch_tool.py |
Fetches and formats OWL plus optional R2RML blocks, adds shared file size cap, and updates tool description. |
tests/agent/tools/test_ontology_fetch_tool.py |
Adds test coverage for requesting both file types and for R2RML present/absent output behavior. |
Comment on lines
+96
to
+101
| if optional: | ||
| # Absent/oversized optional file — skip it without noise. | ||
| logger.info( | ||
| "Optional %s for ontology %r unavailable: %s", file_type, name, e | ||
| ) | ||
| return "" |
Comment on lines
165
to
+170
| f"Fetch the OWL 2 QL ontologies (the authoritative semantic schema) " | ||
| f"for: {names}. Call this BEFORE writing SQL: it gives the exact " | ||
| "class and property names, value formats, and relationships so your " | ||
| "SQL uses the real schema instead of guesses. Takes no arguments." | ||
| f"and, when available, their R2RML mappings (ontology-to-entity/column " | ||
| f"mapping) for: {names}. Call this BEFORE writing SQL: it gives the " | ||
| "exact class and property names, value formats, relationships, and how " | ||
| "they map to entity columns, so your SQL uses the real schema instead " | ||
| "of guesses. Takes no arguments." |
Comment on lines
95
to
106
| except Exception as e: | ||
| if optional: | ||
| # Absent/oversized optional file — skip it without noise. | ||
| logger.info( | ||
| "Optional %s for ontology %r unavailable: %s", file_type, name, e | ||
| ) | ||
| return "" | ||
| logger.warning("Ontology fetch failed for %r: %s", name, e) | ||
| return ( | ||
| f"Ontology '{name}' is unavailable ({type(e).__name__}). " | ||
| "Proceed using the entity schemas in the system prompt." | ||
| ) |
f68e00e to
9f45a34
Compare
9f45a34 to
2647337
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
fetch_ontologynow retrieves each configured ontology's R2RML mapping in addition to its OWL schema, and hands both to the inner SQL agent as grounding.ontology_fetch_tool.py—OntologyFetcherfetches bothowlandr2rmlper ontology (viaEntitiesService.get_ontology_file_async) and concatenates them. The R2RML block is framed as the ontology→entity/column mapping so the LLM can translate ontology terms into real column names for SQL.Why
The OWL gives the LLM class/property names; the R2RML mapping tells it which entity table/column each of those maps to — directly improving SQL accuracy. This is grounding text only (call it M1.5); the executable R2RML flow via an inference engine (Ontop) remains a later milestone.
Notes
get_ontology_file_asyncalready supportedfile_type="r2rml";r2rmlis in the allowlist._MAX_OWL_BYTES→_MAX_FILE_BYTES(now caps both file types).tests/agent/tools/suite green (654).feat/datafabric-ontology-fetch-tool) — base this PR on that branch, or merge feat(datafabric): add fetch_ontology tool to DF inner SQL agent #911 first. Unit/lint CI stays red until SDK2.11.11publishes (same cross-repo constraint as feat(datafabric): add fetch_ontology tool to DF inner SQL agent #911).