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