@nimbleflux/fluxbase-sdk-react 2026.5.5-rc.1 → 2026.6.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.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Vector hooks for Fluxbase React SDK
3
+ * Provides hooks for vector embedding and similarity search
4
+ */
5
+
6
+ import { useMutation } from "@tanstack/react-query";
7
+ import { useFluxbaseClient } from "./context";
8
+ import type { EmbedRequest, VectorSearchOptions } from "@nimbleflux/fluxbase-sdk";
9
+
10
+ /**
11
+ * Hook to generate embeddings for text
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const { mutateAsync } = useVectorEmbed()
16
+ * const { data } = await mutateAsync({ text: 'Hello world' })
17
+ * ```
18
+ */
19
+ export function useVectorEmbed() {
20
+ const client = useFluxbaseClient();
21
+
22
+ return useMutation({
23
+ mutationFn: async (request: EmbedRequest) => {
24
+ const { data, error } = await client.vector.embed(request);
25
+ if (error) throw error;
26
+ return data;
27
+ },
28
+ });
29
+ }
30
+
31
+ /**
32
+ * Hook for vector similarity search with automatic text embedding
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * const { mutateAsync } = useVectorSearch()
37
+ * const { data } = await mutateAsync({
38
+ * table: 'documents',
39
+ * column: 'embedding',
40
+ * query: 'How to use TypeScript?',
41
+ * match_count: 10,
42
+ * })
43
+ * ```
44
+ */
45
+ export function useVectorSearch() {
46
+ const client = useFluxbaseClient();
47
+
48
+ return useMutation({
49
+ mutationFn: async (options: VectorSearchOptions) => {
50
+ const { data, error } = await client.vector.search(options);
51
+ if (error) throw error;
52
+ return data;
53
+ },
54
+ });
55
+ }