@sanity/embeddings-index-ui 1.1.4 → 1.1.6
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 +1 -1
- package/dist/index.esm.js +22 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +21 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/isEnabled.tsx +8 -9
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sanity Embeddings Index UI
|
|
2
2
|
|
|
3
|
-
> Using this feature requires Sanity to send data to OpenAI
|
|
3
|
+
> Using this feature requires Sanity to send data to OpenAI.com, and Pinecone.io for storing vector interpretations of documents.
|
|
4
4
|
|
|
5
5
|
Sanity Studio v3 plugins that interact with the `/embeddings-index` HTTP API.
|
|
6
6
|
|
package/dist/index.esm.js
CHANGED
|
@@ -2,25 +2,38 @@ import { useClient, useProjectId, useSchema, DefaultPreview, useDocumentPreviewS
|
|
|
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';
|
|
5
|
-
import require$$0, { createContext, useState, useEffect, useContext,
|
|
5
|
+
import require$$0, { useMemo, createContext, useState, useEffect, useContext, useRef, forwardRef, useId, useCallback } from 'react';
|
|
6
6
|
import { useDocumentPane } from 'sanity/desk';
|
|
7
7
|
import { useIntentLink, useRouter } from 'sanity/router';
|
|
8
8
|
function publicId(id) {
|
|
9
9
|
return id.replace("drafts.", "");
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
const FeatureEnabledContext = createContext("loading");
|
|
13
|
-
function useIsFeatureEnabled() {
|
|
11
|
+
function useApiClient() {
|
|
14
12
|
const client = useClient({
|
|
15
|
-
apiVersion: "
|
|
13
|
+
apiVersion: "vX"
|
|
16
14
|
});
|
|
15
|
+
return useMemo(() => {
|
|
16
|
+
const customHost = localStorage.getItem("embeddings-index-host");
|
|
17
|
+
if (customHost) {
|
|
18
|
+
return client.withConfig({
|
|
19
|
+
apiHost: customHost,
|
|
20
|
+
useProjectHostname: false,
|
|
21
|
+
withCredentials: false
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return client;
|
|
25
|
+
}, [client]);
|
|
26
|
+
}
|
|
27
|
+
const FeatureEnabledContext = createContext("loading");
|
|
28
|
+
function useIsFeatureEnabled() {
|
|
29
|
+
const client = useApiClient();
|
|
17
30
|
const [status, setStatus] = useState("loading");
|
|
18
31
|
useEffect(() => {
|
|
19
32
|
client.request({
|
|
20
33
|
method: "GET",
|
|
21
|
-
url: "/
|
|
22
|
-
}).then(
|
|
23
|
-
setStatus(
|
|
34
|
+
url: "/embeddings-index/status"
|
|
35
|
+
}).then(response => {
|
|
36
|
+
setStatus(response.enabled ? "enabled" : "disabled");
|
|
24
37
|
}).catch(err => {
|
|
25
38
|
console.error(err);
|
|
26
39
|
setStatus("disabled");
|
|
@@ -47,7 +60,7 @@ function FeatureDisabledNotice(props) {
|
|
|
47
60
|
padding: 4,
|
|
48
61
|
children: /* @__PURE__ */jsxs(Text, {
|
|
49
62
|
size: 1,
|
|
50
|
-
children: ["\u{1F48E} Unlock semantic search with Embeddings Index
|
|
63
|
+
children: ["\u{1F48E} Unlock semantic search with the Embeddings Index API \u2014 available on Team, Business, and Enterprise plans.", " ", /* @__PURE__ */jsx("a", {
|
|
51
64
|
href: "https://www.sanity.io/manage/project/".concat(projectId, "/plan").concat((_a = props.urlSuffix) != null ? _a : ""),
|
|
52
65
|
children: "Upgrade now \u2192"
|
|
53
66
|
})]
|
|
@@ -1925,22 +1938,6 @@ function deleteIndex(indexName, client) {
|
|
|
1925
1938
|
url: "/embeddings-index/".concat(dataset, "/").concat(indexName, "?projectId=").concat(projectId)
|
|
1926
1939
|
});
|
|
1927
1940
|
}
|
|
1928
|
-
function useApiClient() {
|
|
1929
|
-
const client = useClient({
|
|
1930
|
-
apiVersion: "vX"
|
|
1931
|
-
});
|
|
1932
|
-
return useMemo(() => {
|
|
1933
|
-
const customHost = localStorage.getItem("embeddings-index-host");
|
|
1934
|
-
if (customHost) {
|
|
1935
|
-
return client.withConfig({
|
|
1936
|
-
apiHost: customHost,
|
|
1937
|
-
useProjectHostname: false,
|
|
1938
|
-
withCredentials: false
|
|
1939
|
-
});
|
|
1940
|
-
}
|
|
1941
|
-
return client;
|
|
1942
|
-
}, [client]);
|
|
1943
|
-
}
|
|
1944
1941
|
const NO_RESULTS_VALUE = "";
|
|
1945
1942
|
const NO_OPTIONS = [];
|
|
1946
1943
|
const NO_FILTER = () => true;
|