@sanity/embeddings-index-ui 1.1.3 → 1.1.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/README.md +9 -12
- package/dist/index.esm.js +21 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +20 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/isEnabled.tsx +10 -6
- package/src/embeddingsIndexDashboard/EmbeddingsIndexTool.tsx +6 -3
- package/src/referenceInput/SemanticSearchReferenceInput.tsx +3 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Sanity Studio v3 plugins that interact with the `/embeddings-index` HTTP API.
|
|
6
6
|
|
|
7
|
-
The Embeddings Index API enables
|
|
7
|
+
The Embeddings Index API enables the creation, management, and search of named embeddings vector indexes.
|
|
8
8
|
|
|
9
9
|
An embeddings index contains embeddings for all Sanity documents matching a configured [GROQ filter](https://www.sanity.io/docs/how-queries-work) in a dataset.
|
|
10
10
|
A [GROQ projection](https://www.sanity.io/docs/query-cheat-sheet) is applied to matching documents before vectorization.
|
|
@@ -16,8 +16,6 @@ Creating an index can take time, depending on the number of existing documents a
|
|
|
16
16
|
|
|
17
17
|
For a CLI alternative, check out the [Embeddings Index CLI](https://github.com/sanity-io/embeddings-index-cli) package.
|
|
18
18
|
|
|
19
|
-
> Using this feature requires Sanity to send data to OpenAI.com, and Pinecone.io for storing vector interpretations of documents.
|
|
20
|
-
|
|
21
19
|
## Installation
|
|
22
20
|
|
|
23
21
|
```sh
|
|
@@ -31,16 +29,15 @@ npm install @sanity/embeddings-index-ui
|
|
|
31
29
|
|
|
32
30
|
For more information about using the plugins, see the relevant sections below.
|
|
33
31
|
|
|
34
|
-
##
|
|
32
|
+
## Semantic reference search input
|
|
35
33
|
|
|
36
34
|
<img width="619" alt="image" src="https://github.com/sanity-io/sanity/assets/835514/55d372fe-c5fe-40dd-882b-10c6e8794442">
|
|
37
35
|
|
|
38
|
-
The
|
|
39
|
-
This enables users to search for references using natural language, and to retrieve documents based on semantic meaning, rather than exact word matches.
|
|
36
|
+
The Embeddings Index UI ships with a Semantic reference search input component. This enables you to search for [references](https://www.sanity.io/docs/connected-content) using natural language and to retrieve documents based on semantic meaning rather than exact string matches.
|
|
40
37
|
|
|
41
38
|
### Usage
|
|
42
39
|
|
|
43
|
-
|
|
40
|
+
You can add the semantic reference search input by importing and adding `embeddingsIndexReferenceInput` as a plugin to `sanity.config.ts` (or `.js`):
|
|
44
41
|
|
|
45
42
|
```ts
|
|
46
43
|
import {defineConfig} from 'sanity'
|
|
@@ -63,7 +60,7 @@ defineField({
|
|
|
63
60
|
options: {
|
|
64
61
|
embeddingsIndex: {
|
|
65
62
|
indexName: 'my-index', // Name of the embeddings index
|
|
66
|
-
maxResults: 10, //
|
|
63
|
+
maxResults: 10, // Maximum number of returned results per request. Default: 10
|
|
67
64
|
searchMode: 'embeddings' // Sets default search mode for the field. Enables toggling between 'embeddings' (semantic search) and 'default' (default search based on GROQ filter)
|
|
68
65
|
}
|
|
69
66
|
}
|
|
@@ -112,10 +109,10 @@ defineField({
|
|
|
112
109
|
})
|
|
113
110
|
```
|
|
114
111
|
|
|
115
|
-
## Embeddings
|
|
112
|
+
## Embeddings Index API dashboard for Sanity Studio
|
|
116
113
|
|
|
117
|
-
A UI alternative to the [Embeddings
|
|
118
|
-
manage embeddings indexes in a Studio dashboard.
|
|
114
|
+
A UI alternative to the [Embeddings Index CLI](https://github.com/sanity-io/embeddings-index-cli) to
|
|
115
|
+
manage embeddings indexes in a Studio dashboard. It also lets you test semantic search on the indexes.
|
|
119
116
|
|
|
120
117
|
<img width="1227" alt="image" src="https://github.com/sanity-io/sanity/assets/835514/279b03b8-d2c0-4cc1-bbe6-9d335937f25a">
|
|
121
118
|
|
|
@@ -137,7 +134,7 @@ export default defineConfig({
|
|
|
137
134
|
})
|
|
138
135
|
```
|
|
139
136
|
|
|
140
|
-
This adds the Embeddings Index tool to the studio navigation bar, but only when the studio is running in developer mode (`localhost`).
|
|
137
|
+
This adds the Embeddings Index API tool to the studio navigation bar, but only when the studio is running in developer mode (`localhost`).
|
|
141
138
|
|
|
142
139
|
If you want to enable the tool based on user access roles:
|
|
143
140
|
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useClient, useSchema, DefaultPreview, useDocumentPreviewStore, SanityDefaultPreview, getPreviewValueWithFallback, getPreviewStateObservable, typed, unset, setIfMissing, set, definePlugin, isObjectInputProps } from 'sanity';
|
|
1
|
+
import { useClient, useProjectId, useSchema, DefaultPreview, useDocumentPreviewStore, SanityDefaultPreview, getPreviewValueWithFallback, getPreviewStateObservable, typed, unset, setIfMissing, set, definePlugin, isObjectInputProps } from 'sanity';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { Card, Text, Button, Box, Autocomplete, Flex, Spinner, Stack, Label, TextInput, TextArea, Dialog, Heading, MenuButton, Menu, MenuItem } from '@sanity/ui';
|
|
4
4
|
import { ErrorOutlineIcon, EarthGlobeIcon, LinkIcon, AddIcon, EllipsisVerticalIcon, TrashIcon, UndoIcon } from '@sanity/icons';
|
|
@@ -38,17 +38,19 @@ function FeatureEnabledProvider(props) {
|
|
|
38
38
|
function useIsFeatureEnabledContext() {
|
|
39
39
|
return useContext(FeatureEnabledContext);
|
|
40
40
|
}
|
|
41
|
-
function FeatureDisabledNotice() {
|
|
41
|
+
function FeatureDisabledNotice(props) {
|
|
42
|
+
var _a;
|
|
43
|
+
const projectId = useProjectId();
|
|
42
44
|
return /* @__PURE__ */jsx(Card, {
|
|
43
45
|
tone: "primary",
|
|
44
46
|
border: true,
|
|
45
|
-
padding:
|
|
47
|
+
padding: 4,
|
|
46
48
|
children: /* @__PURE__ */jsxs(Text, {
|
|
47
49
|
size: 1,
|
|
48
|
-
children: ["Embeddings
|
|
49
|
-
href: "https://sanity.io/
|
|
50
|
-
children: "
|
|
51
|
-
})
|
|
50
|
+
children: ["\u{1F48E} Unlock semantic search with the Embeddings Index API \u2014 available on Team, Business, and Enterprise plans.", " ", /* @__PURE__ */jsx("a", {
|
|
51
|
+
href: "https://www.sanity.io/manage/project/".concat(projectId, "/plan").concat((_a = props.urlSuffix) != null ? _a : ""),
|
|
52
|
+
children: "Upgrade now \u2192"
|
|
53
|
+
})]
|
|
52
54
|
})
|
|
53
55
|
});
|
|
54
56
|
}
|
|
@@ -2129,7 +2131,9 @@ function SemanticSearchReferenceInput(props) {
|
|
|
2129
2131
|
children: [semantic && featureState == "loading" ? /* @__PURE__ */jsx(Box, {
|
|
2130
2132
|
padding: 2,
|
|
2131
2133
|
children: /* @__PURE__ */jsx(Spinner, {})
|
|
2132
|
-
}) : null, semantic && featureState == "disabled" ? /* @__PURE__ */jsx(FeatureDisabledNotice, {
|
|
2134
|
+
}) : null, semantic && featureState == "disabled" ? /* @__PURE__ */jsx(FeatureDisabledNotice, {
|
|
2135
|
+
urlSuffix: "?ref=embeddings-ref"
|
|
2136
|
+
}) : null, /* @__PURE__ */jsx(Box, {
|
|
2133
2137
|
flex: 1,
|
|
2134
2138
|
style: {
|
|
2135
2139
|
maxHeight: 36,
|
|
@@ -2737,10 +2741,15 @@ function IndexStatus(_ref4) {
|
|
|
2737
2741
|
function EmbeddingsIndexTool() {
|
|
2738
2742
|
const featureState = useIsFeatureEnabled();
|
|
2739
2743
|
return /* @__PURE__ */jsx(Card, {
|
|
2740
|
-
children: /* @__PURE__ */
|
|
2744
|
+
children: /* @__PURE__ */jsxs(Flex, {
|
|
2741
2745
|
justify: "center",
|
|
2742
2746
|
flex: 1,
|
|
2743
|
-
children: /* @__PURE__ */
|
|
2747
|
+
children: [featureState == "disabled" ? /* @__PURE__ */jsx(Box, {
|
|
2748
|
+
padding: 4,
|
|
2749
|
+
children: /* @__PURE__ */jsx(FeatureDisabledNotice, {
|
|
2750
|
+
urlSuffix: "?ref=embeddings-tab"
|
|
2751
|
+
})
|
|
2752
|
+
}) : null, /* @__PURE__ */jsxs(Card, {
|
|
2744
2753
|
flex: 1,
|
|
2745
2754
|
style: {
|
|
2746
2755
|
maxWidth: 1200
|
|
@@ -2749,8 +2758,8 @@ function EmbeddingsIndexTool() {
|
|
|
2749
2758
|
children: [featureState == "loading" ? /* @__PURE__ */jsx(Box, {
|
|
2750
2759
|
padding: 2,
|
|
2751
2760
|
children: /* @__PURE__ */jsx(Spinner, {})
|
|
2752
|
-
}) : null, featureState == "
|
|
2753
|
-
})
|
|
2761
|
+
}) : null, featureState == "enabled" ? /* @__PURE__ */jsx(Indexes, {}) : null]
|
|
2762
|
+
})]
|
|
2754
2763
|
})
|
|
2755
2764
|
});
|
|
2756
2765
|
}
|