Skip to content

Commit 7fab6d5

Browse files
refactor(datafabric): address review nits (split bind test, single-string ontology prompt)
1 parent 2f41f40 commit 7fab6d5

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

src/uipath_langchain/agent/tools/datafabric_tool/datafabric_prompt_builder.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,13 @@ def format_sql_context(ctx: SQLContext, ontology_names: list[str] | None = None)
153153

154154
if ontology_names:
155155
names = ", ".join(f"`{n}`" for n in ontology_names)
156-
lines.append("## Available Ontology (authoritative semantic schema)")
157-
lines.append("")
158156
lines.append(
157+
"## Available Ontology (authoritative semantic schema)\n\n"
159158
f"This agent has a semantic ontology attached for these entities: "
160159
f"{names}. It is the authoritative source for the exact column names, "
161160
"value formats (date formats, codes, zero-padding), allowed values, "
162161
"and the relationships between entities — richer and more reliable "
163-
"than the field list below, which omits value formats and semantics."
164-
)
165-
lines.append("")
166-
lines.append(
162+
"than the field list below, which omits value formats and semantics.\n\n"
167163
"**Before writing any SQL, call the `fetch_ontology` tool once** to "
168164
"load it, then base your column names, filter values, and joins on "
169165
"what it says. The entity tables below are a quick reference only; "

tests/agent/tools/test_datafabric_ontology_subgraph.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,16 @@ def _tc(name, args=None, cid="c1"):
5757
return {"name": name, "args": args or {}, "id": cid, "type": "tool_call"}
5858

5959

60-
def test_fetch_ontology_bound_only_when_ontologies(make_graph):
60+
def test_fetch_ontology_bound_when_ontologies_present(make_graph):
61+
with_onto = make_graph([("library", None)])
62+
assert "fetch_ontology" in with_onto._tools_by_name
63+
64+
65+
def test_fetch_ontology_not_bound_when_ontologies_absent(make_graph):
6166
without = make_graph(None)
6267
assert "execute_sql" in without._tools_by_name
6368
assert "fetch_ontology" not in without._tools_by_name
6469

65-
with_onto = make_graph([("library", None)])
66-
assert "fetch_ontology" in with_onto._tools_by_name
67-
6870

6971
def test_fetch_ontology_not_bound_when_flag_off(make_graph):
7072
# The feature flag decides which graph is built: even with ontologies

0 commit comments

Comments
 (0)