@trustgraph/react-state 1.4.5 → 1.5.1

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 CHANGED
@@ -1531,13 +1531,13 @@ const addRowEmbeddings = (socket, add, remove) => (entities) => {
1531
1531
  const act = "Embeddings " + text.substring(0, 20);
1532
1532
  add(act);
1533
1533
  return socket
1534
- .embeddings(text)
1534
+ .embeddings([text])
1535
1535
  .then((x) => {
1536
- if (x && x.length > 0) {
1536
+ if (x && x.length > 0 && x[0].length > 0) {
1537
1537
  remove(act);
1538
1538
  return {
1539
1539
  ...ent,
1540
- embeddings: x[0],
1540
+ embeddings: x[0][0],
1541
1541
  };
1542
1542
  }
1543
1543
  else {
@@ -1575,7 +1575,8 @@ const vectorSearch = (socket, flowId, addActivity, removeActivity, term, collect
1575
1575
  const searchAct = "Search: " + term;
1576
1576
  addActivity(searchAct);
1577
1577
  return api
1578
- .embeddings(term)
1578
+ .embeddings([term])
1579
+ .then((vecs) => vecs[0])
1579
1580
  .then(getGraphEmbeddings(api, addActivity, removeActivity, limit || 10, collection))
1580
1581
  .then(addRowLabels(api, addActivity, removeActivity, collection))
1581
1582
  .then(addRowDefinitions(api, addActivity, removeActivity, collection))
@@ -1756,7 +1757,8 @@ const useInference = ({ flow } = {}) => {
1756
1757
  })
1757
1758
  : await socket.flow(effectiveFlow).graphRag(input, options || {}, collection);
1758
1759
  // Get embeddings for entity discovery
1759
- const embeddings = await socket.flow(effectiveFlow).embeddings(input);
1760
+ const allEmbeddings = await socket.flow(effectiveFlow).embeddings([input]);
1761
+ const embeddings = allEmbeddings[0];
1760
1762
  // Query graph embeddings to find entities
1761
1763
  const entities = await socket
1762
1764
  .flow(effectiveFlow)
@@ -2120,16 +2122,7 @@ const useStructuredQuery = () => {
2120
2122
  : err?.toString() || "Unknown error";
2121
2123
  notify.error(`Structured query failed: ${errorMessage}`);
2122
2124
  },
2123
- onSuccess: (data) => {
2124
- if (data.data) {
2125
- notify.success("Structured query executed successfully");
2126
- }
2127
- else if (data.errors && data.errors.length > 0) {
2128
- notify.warning("Query executed with errors");
2129
- }
2130
- else {
2131
- notify.warning("Query processed but returned no data");
2132
- }
2125
+ onSuccess: () => {
2133
2126
  },
2134
2127
  });
2135
2128
  // Show loading indicator for structured query operations
@@ -2221,14 +2214,7 @@ const useDocumentEmbeddingsQuery = ({ flow } = {}) => {
2221
2214
  const message = err instanceof Error ? err.message : String(err);
2222
2215
  notify.error(`Document embeddings query failed: ${message}`);
2223
2216
  },
2224
- onSuccess: (data) => {
2225
- const count = Array.isArray(data) ? data.length : 0;
2226
- if (count > 0) {
2227
- notify.success(`Found ${count} matching chunk${count !== 1 ? "s" : ""}`);
2228
- }
2229
- else {
2230
- notify.info("No matching document chunks found");
2231
- }
2217
+ onSuccess: () => {
2232
2218
  },
2233
2219
  });
2234
2220
  useActivity(mutation.isPending, "Searching document chunks");
@@ -2330,7 +2316,7 @@ const useEmbeddings = ({ flow, term }) => {
2330
2316
  queryFn: () => {
2331
2317
  return socket
2332
2318
  .flow(effectiveFlow)
2333
- .embeddings(term)
2319
+ .embeddings([term])
2334
2320
  .then((x) => {
2335
2321
  if (x["error"]) {
2336
2322
  console.log("Error:", x);
@@ -2493,13 +2479,7 @@ const useNlpQuery = ({ flow } = {}) => {
2493
2479
  const errorMessage = err instanceof Error ? err.message : String(err);
2494
2480
  notify.error(`NLP query conversion failed: ${errorMessage}`);
2495
2481
  },
2496
- onSuccess: (data) => {
2497
- if (data.graphql_query) {
2498
- notify.success("Natural language converted to GraphQL successfully");
2499
- }
2500
- else {
2501
- notify.warning("Query processed but no GraphQL generated");
2502
- }
2482
+ onSuccess: () => {
2503
2483
  },
2504
2484
  });
2505
2485
  // Show loading indicator for conversion operations
@@ -3497,8 +3477,6 @@ const useKnowledgeCores = () => {
3497
3477
  notify.error(err.toString());
3498
3478
  },
3499
3479
  onSuccess: () => {
3500
- // Show success notification
3501
- notify.success("Knowledge cores loaded successfully");
3502
3480
  },
3503
3481
  });
3504
3482
  // Show loading indicators for long-running operations