@sanity/embeddings-index-ui 1.1.2 → 1.1.4

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 CHANGED
@@ -1,10 +1,11 @@
1
- # @sanity/embeddings-index-ui
1
+ # Sanity Embeddings Index UI
2
2
 
3
- > This package contains plugins for **Sanity Studio v3**.
3
+ > Using this feature requires Sanity to send data to OpenAI[.]com, and Pinecone[.]io for storing vector interpretations of documents.
4
4
 
5
- Sanity Studio plugins that interact with the `/embeddings-index` HTTP API.
5
+ Sanity Studio v3 plugins that interact with the `/embeddings-index` HTTP API.
6
+
7
+ The Embeddings Index API enables the creation, management, and search of named embeddings vector indexes.
6
8
 
7
- The embeddings index API allows the creation of named embeddings vector indexes.
8
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.
9
10
  A [GROQ projection](https://www.sanity.io/docs/query-cheat-sheet) is applied to matching documents before vectorization.
10
11
 
@@ -15,8 +16,6 @@ Creating an index can take time, depending on the number of existing documents a
15
16
 
16
17
  For a CLI alternative, check out the [Embeddings Index CLI](https://github.com/sanity-io/embeddings-index-cli) package.
17
18
 
18
- > Using this feature requires Sanity to send data to OpenAI.com, and Pinecone.io for storing vector interpretations of documents.
19
-
20
19
  ## Installation
21
20
 
22
21
  ```sh
@@ -28,19 +27,17 @@ npm install @sanity/embeddings-index-ui
28
27
  * [embeddingsIndexReferenceInput](#embeddings-index-reference-input): semantic search mode for reference inputs
29
28
  * [embeddingsIndexDashboard](#embeddings-index-dashboard): manage indexes in a Sanity Studio UI tool
30
29
 
31
- For more information about how to use the plugins, see the relevant sections below.
30
+ For more information about using the plugins, see the relevant sections below.
32
31
 
33
- ## Embeddings index reference input
32
+ ## Semantic reference search input
34
33
 
35
34
  <img width="619" alt="image" src="https://github.com/sanity-io/sanity/assets/835514/55d372fe-c5fe-40dd-882b-10c6e8794442">
36
35
 
37
- The `embeddingsIndexReferenceInput` plugin allows reference fields to opt in to embeddings index search.
38
- This enables users to search for references using natural language, and to retrieve documents based on semantic meaning,
39
- 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
- Add `embeddingsIndexReferenceInput` as a plugin to `sanity.config.ts` (or `.js`):
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, // Max. number of returned results per request. Default: 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 index dashboard
112
+ ## Embeddings Index API dashboard for Sanity Studio
116
113
 
117
- A UI alternative to the [Embeddings ˆndex CLI](https://github.com/sanity-io/embeddings-index-cli) to
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: 2,
47
+ padding: 4,
46
48
  children: /* @__PURE__ */jsxs(Text, {
47
49
  size: 1,
48
- children: ["Embeddings index APIs are only available on the", " ", /* @__PURE__ */jsx("a", {
49
- href: "https://sanity.io/pricing",
50
- children: "Team tier and above"
51
- }), ". Please upgrade to enable access."]
50
+ children: ["\u{1F48E} Unlock semantic search with Embeddings Index APIs \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, {}) : null, /* @__PURE__ */jsx(Box, {
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__ */jsx(Flex, {
2744
+ children: /* @__PURE__ */jsxs(Flex, {
2741
2745
  justify: "center",
2742
2746
  flex: 1,
2743
- children: /* @__PURE__ */jsxs(Card, {
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 == "disabled" ? /* @__PURE__ */jsx(FeatureDisabledNotice, {}) : null, featureState == "enabled" ? /* @__PURE__ */jsx(Indexes, {}) : null]
2753
- })
2761
+ }) : null, featureState == "enabled" ? /* @__PURE__ */jsx(Indexes, {}) : null]
2762
+ })]
2754
2763
  })
2755
2764
  });
2756
2765
  }