@trustgraph/react-state 1.4.3 → 1.4.5
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/dist/index.cjs +68 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +68 -67
- package/dist/index.esm.js.map +1 -1
- package/dist/state/document-embeddings-query.d.ts +27 -0
- package/dist/state/document-embeddings-query.d.ts.map +1 -0
- package/dist/state/graph-embeddings.d.ts +4 -6
- package/dist/state/graph-embeddings.d.ts.map +1 -1
- package/dist/state/row-embeddings-query.d.ts +4 -5
- package/dist/state/row-embeddings-query.d.ts.map +1 -1
- package/dist/state/rows-query.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export type { GraphRagOptions, GraphRagResult, GraphRagCallbacks, TextCompletion
|
|
|
31
31
|
export { useChatSession, useChat } from "./state/chat-session";
|
|
32
32
|
export { useStructuredQuery } from "./state/structured-query";
|
|
33
33
|
export { useRowEmbeddingsQuery } from "./state/row-embeddings-query";
|
|
34
|
+
export { useDocumentEmbeddingsQuery } from "./state/document-embeddings-query";
|
|
34
35
|
export { useRowsQuery } from "./state/rows-query";
|
|
35
36
|
export { useEmbeddings } from "./state/embeddings";
|
|
36
37
|
export { useCollections } from "./state/collections";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,aAAa,EACb,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGtE,YAAY,EACV,OAAO,EACP,MAAM,EACN,IAAI,EACJ,OAAO,EACP,SAAS,EACT,WAAW,EACX,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,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E,MAAM,sBAAsB,CAAC;AAGtD,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACL,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGxE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC/E,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACzE,YAAY,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1398,53 +1398,36 @@ const useGraphSubgraph = ({ entityUri, flow, collection, }) => {
|
|
|
1398
1398
|
};
|
|
1399
1399
|
|
|
1400
1400
|
/**
|
|
1401
|
-
* Custom hook for
|
|
1402
|
-
*
|
|
1403
|
-
* for AI models
|
|
1404
|
-
* @returns {Object} Token cost state and operations
|
|
1401
|
+
* Custom hook for querying graph embeddings
|
|
1402
|
+
* Finds graph entities similar to the provided embedding vectors
|
|
1405
1403
|
*/
|
|
1406
|
-
const useGraphEmbeddings = ({ flow, vecs, limit, collection }) => {
|
|
1407
|
-
// WebSocket connection for communicating with the configuration service
|
|
1404
|
+
const useGraphEmbeddings = ({ flow, vecs, limit = 10, collection }) => {
|
|
1408
1405
|
const socket = useSocket();
|
|
1409
|
-
// Hook for displaying user notifications
|
|
1410
1406
|
const notify = useNotification();
|
|
1411
|
-
// Settings for default collection
|
|
1412
1407
|
const { settings } = useSettings();
|
|
1413
|
-
// Session state for default flow ID
|
|
1414
1408
|
const sessionFlowId = useSessionStore((state) => state.flowId);
|
|
1415
|
-
// Use explicit param if provided, otherwise fall back to session state
|
|
1416
1409
|
const effectiveFlow = flow ?? sessionFlowId;
|
|
1417
|
-
|
|
1418
|
-
* Query for fetching graph embeddings
|
|
1419
|
-
* Uses React Query for caching and background refetching
|
|
1420
|
-
*/
|
|
1410
|
+
const effectiveCollection = collection ?? settings.collection;
|
|
1421
1411
|
const query = useQuery({
|
|
1422
|
-
queryKey: ["graph-embeddings", { flow: effectiveFlow, vecs, limit }],
|
|
1412
|
+
queryKey: ["graph-embeddings", { flow: effectiveFlow, vecs, limit, collection: effectiveCollection }],
|
|
1413
|
+
enabled: !!vecs && vecs.length > 0 && !!effectiveFlow,
|
|
1423
1414
|
queryFn: () => {
|
|
1424
1415
|
return socket
|
|
1425
1416
|
.flow(effectiveFlow)
|
|
1426
|
-
.graphEmbeddingsQuery(vecs, limit,
|
|
1427
|
-
.then((x) => {
|
|
1428
|
-
return x;
|
|
1429
|
-
})
|
|
1417
|
+
.graphEmbeddingsQuery(vecs, limit, effectiveCollection)
|
|
1430
1418
|
.catch((err) => {
|
|
1431
|
-
console.log("Error:", err);
|
|
1432
1419
|
const message = err instanceof Error ? err.message : String(err);
|
|
1433
1420
|
notify.error(message);
|
|
1434
1421
|
throw err;
|
|
1435
1422
|
});
|
|
1436
1423
|
},
|
|
1437
1424
|
});
|
|
1438
|
-
// Show loading indicators for long-running operations
|
|
1439
1425
|
useActivity(query.isLoading, "Loading graph embeddings");
|
|
1440
|
-
// Return token cost state and operations for use in components
|
|
1441
1426
|
return {
|
|
1442
|
-
// Token cost query state
|
|
1443
1427
|
graphEmbeddings: query.data,
|
|
1444
1428
|
isLoading: query.isLoading,
|
|
1445
1429
|
isError: query.isError,
|
|
1446
1430
|
error: query.error,
|
|
1447
|
-
// Manual refetch function
|
|
1448
1431
|
refetch: query.refetch,
|
|
1449
1432
|
};
|
|
1450
1433
|
};
|
|
@@ -2172,71 +2155,90 @@ const useStructuredQuery = () => {
|
|
|
2172
2155
|
};
|
|
2173
2156
|
|
|
2174
2157
|
// @ts-nocheck
|
|
2175
|
-
// React Query hooks for data fetching and mutation management
|
|
2176
2158
|
/**
|
|
2177
|
-
* Custom hook for
|
|
2178
|
-
*
|
|
2179
|
-
* First converts query text to embeddings, then searches for similar records
|
|
2159
|
+
* Custom hook for querying row embeddings using vectors.
|
|
2160
|
+
* Searches for similar records in structured data indexes.
|
|
2180
2161
|
*/
|
|
2181
2162
|
const useRowEmbeddingsQuery = ({ flow } = {}) => {
|
|
2182
|
-
// Socket connection for API calls
|
|
2183
2163
|
const socket = useSocket();
|
|
2184
2164
|
const connectionState = useConnectionState();
|
|
2185
|
-
// Notification system for user feedback
|
|
2186
2165
|
const notify = useNotification();
|
|
2187
|
-
// Session state for current flow ID
|
|
2188
2166
|
const sessionFlowId = useSessionStore((state) => state.flowId);
|
|
2189
|
-
// Settings for default collection
|
|
2190
2167
|
const { settings } = useSettings();
|
|
2191
|
-
// Use explicit param if provided, otherwise fall back to session state
|
|
2192
2168
|
const effectiveFlow = flow ?? sessionFlowId;
|
|
2193
|
-
// Only enable operations when socket is connected and ready
|
|
2194
2169
|
const isSocketReady = connectionState?.status === "authenticated" ||
|
|
2195
2170
|
connectionState?.status === "unauthenticated";
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
mutationFn: async ({ query, schemaName, collection, indexName, limit, }) => {
|
|
2171
|
+
const mutation = useMutation({
|
|
2172
|
+
mutationFn: async ({ vectors, schemaName, collection, indexName, limit = 10, }) => {
|
|
2199
2173
|
if (!isSocketReady) {
|
|
2200
2174
|
throw new Error("Socket connection not ready");
|
|
2201
2175
|
}
|
|
2202
|
-
|
|
2203
|
-
// First, get embeddings for the query text
|
|
2204
|
-
const vectors = await flowApi.embeddings(query);
|
|
2205
|
-
// Then query row embeddings with those vectors
|
|
2206
|
-
return flowApi.rowEmbeddingsQuery(vectors, schemaName, collection || settings.collection, indexName, limit || 10);
|
|
2176
|
+
return socket.flow(effectiveFlow).rowEmbeddingsQuery(vectors, schemaName, collection ?? settings.collection, indexName, limit);
|
|
2207
2177
|
},
|
|
2208
2178
|
onError: (err) => {
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2179
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2180
|
+
notify.error(`Row embeddings query failed: ${message}`);
|
|
2181
|
+
},
|
|
2182
|
+
onSuccess: () => {
|
|
2183
|
+
},
|
|
2184
|
+
});
|
|
2185
|
+
useActivity(mutation.isPending, "Querying row embeddings");
|
|
2186
|
+
return {
|
|
2187
|
+
executeQuery: mutation.mutate,
|
|
2188
|
+
executeQueryAsync: mutation.mutateAsync,
|
|
2189
|
+
isExecuting: mutation.isPending,
|
|
2190
|
+
error: mutation.error,
|
|
2191
|
+
matches: mutation.data ?? [],
|
|
2192
|
+
hasResults: (mutation.data?.length ?? 0) > 0,
|
|
2193
|
+
reset: mutation.reset,
|
|
2194
|
+
isReady: isSocketReady,
|
|
2195
|
+
};
|
|
2196
|
+
};
|
|
2197
|
+
|
|
2198
|
+
// @ts-nocheck
|
|
2199
|
+
/**
|
|
2200
|
+
* Custom hook for querying document chunks using vectors.
|
|
2201
|
+
* Searches for document chunks with similar embeddings.
|
|
2202
|
+
*/
|
|
2203
|
+
const useDocumentEmbeddingsQuery = ({ flow } = {}) => {
|
|
2204
|
+
const socket = useSocket();
|
|
2205
|
+
const connectionState = useConnectionState();
|
|
2206
|
+
const notify = useNotification();
|
|
2207
|
+
const sessionFlowId = useSessionStore((state) => state.flowId);
|
|
2208
|
+
const { settings } = useSettings();
|
|
2209
|
+
const effectiveFlow = flow ?? sessionFlowId;
|
|
2210
|
+
const isSocketReady = connectionState?.status === "authenticated" ||
|
|
2211
|
+
connectionState?.status === "unauthenticated";
|
|
2212
|
+
const mutation = useMutation({
|
|
2213
|
+
mutationFn: async ({ vectors, user, collection, limit = 10, }) => {
|
|
2214
|
+
if (!isSocketReady) {
|
|
2215
|
+
throw new Error("Socket connection not ready");
|
|
2216
|
+
}
|
|
2217
|
+
return socket.flow(effectiveFlow).documentEmbeddingsQuery(vectors, user ?? settings.user, collection ?? settings.collection, limit);
|
|
2218
|
+
},
|
|
2219
|
+
onError: (err) => {
|
|
2220
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2221
|
+
notify.error(`Document embeddings query failed: ${message}`);
|
|
2214
2222
|
},
|
|
2215
2223
|
onSuccess: (data) => {
|
|
2216
|
-
|
|
2217
|
-
|
|
2224
|
+
const count = Array.isArray(data) ? data.length : 0;
|
|
2225
|
+
if (count > 0) {
|
|
2226
|
+
notify.success(`Found ${count} matching chunk${count !== 1 ? "s" : ""}`);
|
|
2218
2227
|
}
|
|
2219
2228
|
else {
|
|
2220
|
-
notify.info("No matching
|
|
2229
|
+
notify.info("No matching document chunks found");
|
|
2221
2230
|
}
|
|
2222
2231
|
},
|
|
2223
2232
|
});
|
|
2224
|
-
|
|
2225
|
-
useActivity(rowEmbeddingsQueryMutation.isPending, "Executing row embeddings query");
|
|
2226
|
-
// Return the public API for the hook
|
|
2233
|
+
useActivity(mutation.isPending, "Searching document chunks");
|
|
2227
2234
|
return {
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
matches: rowEmbeddingsQueryMutation.data || [],
|
|
2236
|
-
hasResults: (rowEmbeddingsQueryMutation.data?.length || 0) > 0,
|
|
2237
|
-
// Reset function to clear previous results
|
|
2238
|
-
reset: rowEmbeddingsQueryMutation.reset,
|
|
2239
|
-
// Socket readiness
|
|
2235
|
+
executeQuery: mutation.mutate,
|
|
2236
|
+
executeQueryAsync: mutation.mutateAsync,
|
|
2237
|
+
isExecuting: mutation.isPending,
|
|
2238
|
+
error: mutation.error,
|
|
2239
|
+
results: mutation.data ?? [],
|
|
2240
|
+
hasResults: Array.isArray(mutation.data) && mutation.data.length > 0,
|
|
2241
|
+
reset: mutation.reset,
|
|
2240
2242
|
isReady: isSocketReady,
|
|
2241
2243
|
};
|
|
2242
2244
|
};
|
|
@@ -2277,7 +2279,6 @@ const useRowsQuery = ({ flow } = {}) => {
|
|
|
2277
2279
|
notify.error(`GraphQL query failed: ${errorMessage}`);
|
|
2278
2280
|
},
|
|
2279
2281
|
onSuccess: () => {
|
|
2280
|
-
notify.success("GraphQL query executed successfully");
|
|
2281
2282
|
},
|
|
2282
2283
|
});
|
|
2283
2284
|
// Show loading indicator for query operations
|
|
@@ -4660,5 +4661,5 @@ const useNodeDetails = (nodeId, flowId) => {
|
|
|
4660
4661
|
};
|
|
4661
4662
|
};
|
|
4662
4663
|
|
|
4663
|
-
export { DEFAULT_SETTINGS, NotificationProvider, RDFS_LABEL, SETTINGS_STORAGE_KEY, createDocId, fileToBase64, generateFlowBlueprintId, getTermValue$2 as getTermValue, getTriples, prepareMetadata, textToBase64, useActivity, useAgentTools, useChat, useChatSession, useCollections, useConversation, useEmbeddings, useEntityDetail, useFlowBlueprints, useFlowParameters, useFlows, useGraphEmbeddings, useGraphSubgraph, useInference, useKnowledgeCores, useLLMModels, useLibrary, useLoadStateStore, useMcpTools, useNlpQuery, useNodeDetails, useNotification, useOntologies, useParameterValidation, useProcessing, useProgressStateStore, usePrompts, useRowEmbeddingsQuery, useRowsQuery, useSchemas, useSearchStateStore, useSessionStore, useSettings, useStructuredQuery, useTokenCosts, useTriples, useVectorSearch, useWorkbenchStateStore, vectorSearch };
|
|
4664
|
+
export { DEFAULT_SETTINGS, NotificationProvider, RDFS_LABEL, SETTINGS_STORAGE_KEY, createDocId, fileToBase64, generateFlowBlueprintId, getTermValue$2 as getTermValue, getTriples, prepareMetadata, textToBase64, useActivity, useAgentTools, useChat, useChatSession, useCollections, useConversation, useDocumentEmbeddingsQuery, useEmbeddings, useEntityDetail, useFlowBlueprints, useFlowParameters, useFlows, useGraphEmbeddings, useGraphSubgraph, useInference, useKnowledgeCores, useLLMModels, useLibrary, useLoadStateStore, useMcpTools, useNlpQuery, useNodeDetails, useNotification, useOntologies, useParameterValidation, useProcessing, useProgressStateStore, usePrompts, useRowEmbeddingsQuery, useRowsQuery, useSchemas, useSearchStateStore, useSessionStore, useSettings, useStructuredQuery, useTokenCosts, useTriples, useVectorSearch, useWorkbenchStateStore, vectorSearch };
|
|
4664
4665
|
//# sourceMappingURL=index.esm.js.map
|