@fabric-harness/databricks 4.10.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/agent.js +108 -22
- package/dist/agent.js.map +1 -1
- package/dist/capabilities.d.ts +33 -0
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/certification.d.ts.map +1 -1
- package/dist/certify.js +166 -33
- package/dist/certify.js.map +1 -1
- package/dist/index.d.ts +22 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +504 -41
- package/dist/index.js.map +1 -1
- package/dist/rag-chain.d.ts +21 -8
- package/dist/rag-chain.d.ts.map +1 -1
- package/dist/vector-search.d.ts +58 -8
- package/dist/vector-search.d.ts.map +1 -1
- package/dist/workspace-api.d.ts +40 -0
- package/dist/workspace-api.d.ts.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
package/dist/agent.js
CHANGED
|
@@ -58887,37 +58887,70 @@ function deleteSchema() {
|
|
|
58887
58887
|
// src/vector-search.ts
|
|
58888
58888
|
var SCORE_COLUMN = "score";
|
|
58889
58889
|
function databricksAiSearch(options) {
|
|
58890
|
-
const
|
|
58890
|
+
const configuredInputMode = options.inputMode ?? "text";
|
|
58891
|
+
const configuredStrategy = options.strategy ?? (configuredInputMode === "vector" ? "ann" : "hybrid");
|
|
58891
58892
|
const columns = options.columns ?? dedupe([options.textColumn, ...options.idColumn ? [options.idColumn] : []]);
|
|
58892
|
-
|
|
58893
|
+
const retriever = {
|
|
58894
|
+
kind: "databricks-ai-search",
|
|
58893
58895
|
name: options.name ?? `databricks-ai-search:${options.index}`,
|
|
58896
|
+
index: options.index,
|
|
58897
|
+
inputMode: configuredInputMode,
|
|
58898
|
+
strategy: configuredStrategy,
|
|
58894
58899
|
async retrieve(query, opts = {}) {
|
|
58900
|
+
return (await retriever.query(query, opts)).chunks;
|
|
58901
|
+
},
|
|
58902
|
+
async query(query, opts = {}) {
|
|
58903
|
+
if (!query.trim()) throw new Error("databricks AI Search: query must not be empty.");
|
|
58904
|
+
const inputMode = opts.inputMode ?? configuredInputMode;
|
|
58905
|
+
const strategy = opts.strategy ?? configuredStrategy;
|
|
58906
|
+
validateQueryCombination(inputMode, strategy);
|
|
58907
|
+
const scoreThreshold = opts.scoreThreshold ?? options.scoreThreshold;
|
|
58908
|
+
const queryColumns = opts.queryColumns ?? options.queryColumns;
|
|
58909
|
+
const sortColumns = opts.sortColumns ?? options.sortColumns;
|
|
58910
|
+
const facets = opts.facets ?? options.facets;
|
|
58911
|
+
const reranker = opts.reranker ?? options.reranker;
|
|
58912
|
+
const columnsToRerank = opts.columnsToRerank ?? options.columnsToRerank;
|
|
58895
58913
|
const body = {
|
|
58896
58914
|
name: options.index,
|
|
58897
58915
|
columns,
|
|
58898
|
-
numResults: opts.k ?? 5
|
|
58916
|
+
numResults: opts.k ?? 5,
|
|
58917
|
+
queryType: nativeStrategy(strategy),
|
|
58918
|
+
...scoreThreshold !== void 0 ? { scoreThreshold } : {},
|
|
58919
|
+
...queryColumns ? { queryColumns } : {},
|
|
58920
|
+
...sortColumns ? { sortColumns } : {},
|
|
58921
|
+
...facets ? { facets } : {},
|
|
58922
|
+
...reranker ? { reranker } : {},
|
|
58923
|
+
...columnsToRerank ? { columnsToRerank } : {}
|
|
58899
58924
|
};
|
|
58900
58925
|
if (opts.filter) body.filtersJson = JSON.stringify(opts.filter);
|
|
58901
|
-
if (
|
|
58902
|
-
if (!options.embeddings)
|
|
58903
|
-
throw new Error(
|
|
58904
|
-
'databricks AI Search: queryType "vector" requires an embeddings provider.'
|
|
58905
|
-
);
|
|
58906
|
-
const [vector] = await options.embeddings.embed([query]);
|
|
58907
|
-
if (!vector)
|
|
58908
|
-
throw new Error("databricks AI Search: embeddings returned no vector for the query.");
|
|
58909
|
-
body.queryVector = vector;
|
|
58910
|
-
} else {
|
|
58926
|
+
if (inputMode !== "vector") {
|
|
58911
58927
|
body.queryText = query;
|
|
58912
58928
|
}
|
|
58913
|
-
|
|
58914
|
-
|
|
58929
|
+
if (inputMode !== "text") {
|
|
58930
|
+
body.queryVector = await resolveQueryVector(query, opts, options);
|
|
58931
|
+
}
|
|
58932
|
+
const response = await queryVectorIndex(options, body, opts.signal);
|
|
58933
|
+
return queryResult(response, options, columns);
|
|
58934
|
+
},
|
|
58935
|
+
async nextPage(pageToken, opts = {}) {
|
|
58936
|
+
if (!pageToken.trim()) throw new Error("databricks AI Search: page token must not be empty.");
|
|
58937
|
+
if (!options.client.queryVectorIndexNextPage) {
|
|
58938
|
+
throw new Error(
|
|
58939
|
+
"databricks AI Search: the configured client does not support result pagination."
|
|
58940
|
+
);
|
|
58941
|
+
}
|
|
58942
|
+
const response = opts.signal ? await options.client.queryVectorIndexNextPage(
|
|
58943
|
+
{ name: options.index, pageToken },
|
|
58944
|
+
{ signal: opts.signal }
|
|
58945
|
+
) : await options.client.queryVectorIndexNextPage({ name: options.index, pageToken });
|
|
58946
|
+
return queryResult(response, options, columns);
|
|
58915
58947
|
}
|
|
58916
58948
|
};
|
|
58949
|
+
return retriever;
|
|
58917
58950
|
}
|
|
58918
|
-
async function queryVectorIndex(options, body) {
|
|
58951
|
+
async function queryVectorIndex(options, body, signal) {
|
|
58919
58952
|
try {
|
|
58920
|
-
return await options.client.queryVectorIndex(body);
|
|
58953
|
+
return signal ? await options.client.queryVectorIndex(body, { signal }) : await options.client.queryVectorIndex(body);
|
|
58921
58954
|
} catch (error51) {
|
|
58922
58955
|
if (!options.rawProtocolClient || !isGeneratedFloatingPointDecodeError(error51)) throw error51;
|
|
58923
58956
|
const raw = await options.rawProtocolClient.post(
|
|
@@ -58927,10 +58960,17 @@ async function queryVectorIndex(options, body) {
|
|
|
58927
58960
|
num_results: body.numResults,
|
|
58928
58961
|
...body.filtersJson !== void 0 ? { filters_json: body.filtersJson } : {},
|
|
58929
58962
|
...body.queryText !== void 0 ? { query_text: body.queryText } : {},
|
|
58930
|
-
...body.queryVector !== void 0 ? { query_vector: body.queryVector } : {}
|
|
58963
|
+
...body.queryVector !== void 0 ? { query_vector: body.queryVector } : {},
|
|
58964
|
+
...body.queryType !== void 0 ? { query_type: body.queryType } : {},
|
|
58965
|
+
...body.scoreThreshold !== void 0 ? { score_threshold: body.scoreThreshold } : {},
|
|
58966
|
+
...body.queryColumns !== void 0 ? { query_columns: body.queryColumns } : {},
|
|
58967
|
+
...body.sortColumns !== void 0 ? { sort_columns: body.sortColumns } : {},
|
|
58968
|
+
...body.facets !== void 0 ? { facets: body.facets } : {},
|
|
58969
|
+
...body.reranker !== void 0 ? { reranker: body.reranker } : {},
|
|
58970
|
+
...body.columnsToRerank !== void 0 ? { columns_to_rerank: body.columnsToRerank } : {}
|
|
58931
58971
|
},
|
|
58932
58972
|
void 0,
|
|
58933
|
-
{ retry: "safe" }
|
|
58973
|
+
{ retry: "safe", ...signal ? { signal } : {} }
|
|
58934
58974
|
);
|
|
58935
58975
|
return {
|
|
58936
58976
|
...raw.manifest ? { manifest: raw.manifest } : {},
|
|
@@ -58940,10 +58980,49 @@ async function queryVectorIndex(options, body) {
|
|
|
58940
58980
|
...raw.result.row_count !== void 0 ? { rowCount: raw.result.row_count } : {}
|
|
58941
58981
|
}
|
|
58942
58982
|
} : {},
|
|
58943
|
-
...raw.next_page_token ? { nextPageToken: raw.next_page_token } : {}
|
|
58983
|
+
...raw.next_page_token ? { nextPageToken: raw.next_page_token } : {},
|
|
58984
|
+
...raw.facet_result ? { facetResult: raw.facet_result } : {}
|
|
58944
58985
|
};
|
|
58945
58986
|
}
|
|
58946
58987
|
}
|
|
58988
|
+
async function resolveQueryVector(query, queryOptions, options) {
|
|
58989
|
+
if (queryOptions.queryVector) {
|
|
58990
|
+
if (queryOptions.queryVector.length === 0)
|
|
58991
|
+
throw new Error("databricks AI Search: queryVector must not be empty.");
|
|
58992
|
+
return queryOptions.queryVector;
|
|
58993
|
+
}
|
|
58994
|
+
if (!options.embeddings) {
|
|
58995
|
+
throw new Error(
|
|
58996
|
+
"databricks AI Search: vector input requires `queryVector` or an embeddings provider."
|
|
58997
|
+
);
|
|
58998
|
+
}
|
|
58999
|
+
const [vector] = queryOptions.signal ? await options.embeddings.embed([query], { signal: queryOptions.signal }) : await options.embeddings.embed([query]);
|
|
59000
|
+
if (!vector?.length)
|
|
59001
|
+
throw new Error("databricks AI Search: embeddings returned no vector for the query.");
|
|
59002
|
+
return vector;
|
|
59003
|
+
}
|
|
59004
|
+
function validateQueryCombination(inputMode, strategy) {
|
|
59005
|
+
if ((strategy === "hybrid" || strategy === "full-text") && inputMode === "vector") {
|
|
59006
|
+
throw new Error(
|
|
59007
|
+
`databricks AI Search: ${strategy} retrieval requires text or text-and-vector input.`
|
|
59008
|
+
);
|
|
59009
|
+
}
|
|
59010
|
+
if (strategy === "full-text" && inputMode === "text-and-vector") {
|
|
59011
|
+
throw new Error("databricks AI Search: full-text retrieval does not accept a query vector.");
|
|
59012
|
+
}
|
|
59013
|
+
}
|
|
59014
|
+
function nativeStrategy(strategy) {
|
|
59015
|
+
if (strategy === "full-text") return "FULL_TEXT";
|
|
59016
|
+
return strategy.toUpperCase();
|
|
59017
|
+
}
|
|
59018
|
+
function queryResult(response, options, requestedColumns) {
|
|
59019
|
+
return {
|
|
59020
|
+
chunks: mapResults(response, options, requestedColumns),
|
|
59021
|
+
...response.nextPageToken ? { nextPageToken: response.nextPageToken } : {},
|
|
59022
|
+
...response.facetResult ? { facetResult: response.facetResult } : {},
|
|
59023
|
+
response
|
|
59024
|
+
};
|
|
59025
|
+
}
|
|
58947
59026
|
function isGeneratedFloatingPointDecodeError(error51) {
|
|
58948
59027
|
const message = error51 instanceof Error ? `${error51.name}: ${error51.message}` : String(error51);
|
|
58949
59028
|
return /Cannot convert [-+]?\d+\.\d+(?:e[-+]?\d+)? to a BigInt/iu.test(message);
|
|
@@ -59361,8 +59440,15 @@ function buildDatabricksBundle(config2, scope) {
|
|
|
59361
59440
|
textColumn: aiSearch.textColumn,
|
|
59362
59441
|
...aiSearch.columns ? { columns: aiSearch.columns } : {},
|
|
59363
59442
|
...aiSearch.idColumn ? { idColumn: aiSearch.idColumn } : {},
|
|
59364
|
-
...aiSearch.
|
|
59365
|
-
...
|
|
59443
|
+
...aiSearch.inputMode ? { inputMode: aiSearch.inputMode } : {},
|
|
59444
|
+
...aiSearch.strategy ? { strategy: aiSearch.strategy } : {},
|
|
59445
|
+
...embeddings ? { embeddings } : {},
|
|
59446
|
+
...aiSearch.scoreThreshold !== void 0 ? { scoreThreshold: aiSearch.scoreThreshold } : {},
|
|
59447
|
+
...aiSearch.queryColumns ? { queryColumns: aiSearch.queryColumns } : {},
|
|
59448
|
+
...aiSearch.sortColumns ? { sortColumns: aiSearch.sortColumns } : {},
|
|
59449
|
+
...aiSearch.facets ? { facets: aiSearch.facets } : {},
|
|
59450
|
+
...aiSearch.reranker ? { reranker: aiSearch.reranker } : {},
|
|
59451
|
+
...aiSearch.columnsToRerank ? { columnsToRerank: aiSearch.columnsToRerank } : {}
|
|
59366
59452
|
});
|
|
59367
59453
|
searchTool = createSearchTool(retriever, {
|
|
59368
59454
|
...aiSearch.searchToolName ? { name: aiSearch.searchToolName } : {},
|