@sanity/embeddings-index-ui 1.0.2 → 1.1.0

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
@@ -67,7 +67,7 @@ defineField({
67
67
  })
68
68
  ```
69
69
 
70
- Setting `options.embeddings.indexName` on a reference field will allow enabled searching into the named index.
70
+ Setting `options.embedembeddingsIndexdings.indexName` on a reference field will allow enabled searching into the named index.
71
71
 
72
72
  This will add a "search mode" toggle button to the field.
73
73
 
@@ -78,6 +78,38 @@ that the types the reference field expects actually exist in the index
78
78
  *Caveats*:
79
79
  `options.filter` is not respected by the semantic search.
80
80
 
81
+ ### Default embeddings index config
82
+
83
+ Default config for the reference inputs can be enabled using plugin configuration:
84
+
85
+ ```ts
86
+ import {defineConfig} from 'sanity'
87
+ import {embeddingsIndexReferenceInput} from '@sanity/embeddings-index-ui'
88
+
89
+ export default defineConfig({
90
+ //...
91
+ plugins: [embeddingsIndexReferenceInput({
92
+ indexName: 'my-index', // inputs will use 'my-index' as indexName by default
93
+ maxResults: 15, // now 15 will be the default maxResult for inputs,
94
+ searchMode: 'embeddings' // now 'embeddings' will be the default searchMode for inputs
95
+ })],
96
+ })
97
+ ```
98
+
99
+ When the plugin has a default indexName set like this, the embeddings search can also
100
+ be enabled using `options.embeddingsIndex: true` for a reference field:
101
+
102
+ ```ts
103
+ defineField({
104
+ name: 'myField',
105
+ type: 'reference',
106
+ to: [{type: 'myType'}],
107
+ options: {
108
+ embeddingsIndex: true
109
+ }
110
+ })
111
+ ```
112
+
81
113
  ## Embeddings index dashboard
82
114
  An UI alternative to the [Embeddings index CLI](https://github.com/sanity-io/embeddings-index-cli)
83
115
  Manage embeddings indexes in a Studio dashboard.
package/dist/index.d.ts CHANGED
@@ -3,9 +3,23 @@ import {SanityClient} from 'sanity'
3
3
 
4
4
  export declare function deleteIndex(indexName: string, client: SanityClient): Promise<IndexState>
5
5
 
6
+ declare interface EmbeddingsIndexConfig {
7
+ /**
8
+ * Name of the index
9
+ */
10
+ indexName: string
11
+ maxResults?: number
12
+ /**
13
+ * Determines if which search mode is enabled by default for the reference field.
14
+ * Default is the studio default search, while 'embeddings' enables
15
+ * Defaults to 'default' behaviour
16
+ */
17
+ searchMode?: 'embeddings' | 'default'
18
+ }
19
+
6
20
  export declare const embeddingsIndexDashboard: Plugin_2<void>
7
21
 
8
- export declare const embeddingsIndexReferenceInput: Plugin_2<void>
22
+ export declare const embeddingsIndexReferenceInput: Plugin_2<void | EmbeddingsIndexConfig>
9
23
 
10
24
  export declare function getIndexes(client: SanityClient): Promise<IndexState[]>
11
25
 
@@ -50,18 +64,11 @@ export {}
50
64
 
51
65
  declare module 'sanity' {
52
66
  interface ReferenceBaseOptions {
53
- embeddingsIndex?: {
54
- /**
55
- * Name of the index
56
- */
57
- indexName: string
58
- maxResults?: number
59
- /**
60
- * Determines if which search mode is enabled by default for the reference field.
61
- * Default is the studio default search, while 'embeddings' enables
62
- * Defaults to 'default' behaviour
63
- */
64
- searchMode?: 'embeddings' | 'default'
65
- }
67
+ /**
68
+ * Enables toggleable semantic search for a reference field.
69
+ *
70
+ * When `true`: will use default plugin configuration (if no config has been for the plugin provided ,this will throw an error)
71
+ */
72
+ embeddingsIndex?: true | EmbeddingsIndexConfig
66
73
  }
67
74
  }