@sanity/client 6.28.3-instruct.1 → 6.28.3-resources.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/src/ai/types.ts DELETED
@@ -1,206 +0,0 @@
1
- //Request shape
2
-
3
- import type {Any, SanityDocumentStub} from '@sanity/client'
4
-
5
- /** @beta */
6
- export interface InstructConstantInstructionParam {
7
- type: 'constant'
8
- value: string
9
- }
10
-
11
- /**
12
- *
13
- * Includes a LLM-friendly version of the field value in the instruction
14
- * @beta
15
- * */
16
- export interface InstructFieldInstructionParam {
17
- type: 'field'
18
- /**
19
- * Examples: 'title', 'array[_key=="key"].field'
20
- */
21
- path: string
22
- /**
23
- * If omitted, implicitly uses the documentId of the instruction target
24
- */
25
- documentId?: string
26
- }
27
-
28
- /**
29
- *
30
- * Includes a LLM-friendly version of the document in the instruction
31
- * @beta
32
- * */
33
- export interface DocumentInstructionParam {
34
- type: 'document'
35
- /**
36
- * If omitted, implicitly uses the documentId of the instruction target
37
- */
38
- documentId?: string
39
- }
40
-
41
- /**
42
- * Includes a LLM-friendly version of GROQ query result in the instruction
43
- * @beta
44
- * */
45
- export interface InstructGroqInstructionParam {
46
- type: 'groq'
47
- query: string
48
- params?: Record<string, string>
49
- }
50
-
51
- /** @beta */
52
- export type InstructInstructionParam =
53
- | string
54
- | InstructConstantInstructionParam
55
- | InstructFieldInstructionParam
56
- | DocumentInstructionParam
57
- | InstructGroqInstructionParam
58
-
59
- /** @beta */
60
- export type InstructInstructionParams = Record<string, InstructInstructionParam>
61
-
62
- interface InstructRequestBase {
63
- /** schemaId as reported by sanity deploy / sanity schema store */
64
- schemaId: string
65
- /** string template using $variable – more on this below under "Dynamic instruction" */
66
- instruction: string
67
- /** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
68
- instructionParams?: InstructInstructionParams
69
- /**
70
- * Optional document path output target for the instruction.
71
- * When provided, the instruction will apply to this path in the document and its children.
72
- *
73
- * ## Examples
74
- * - `path: 'title'` will output to the title field in the document
75
- * - `path: 'array[_key="xx"]'` will output to the item with `_key: 'xx'` in the array field
76
- */
77
- path?: string
78
-
79
- /**
80
- * Controls sub-paths in the document that can be output to.
81
- *
82
- * The string-paths are relative to the `path` param
83
- *
84
- * Note: these path strings are less strictly validated than the `path` param itself:
85
- * if an relative-path does not exist or is invalid, it will be silently ignored.
86
- *
87
- * @see InstructRequestBase#conditionalPaths
88
- * @see InstructRequestBase#outputTypes
89
- */
90
- relativeOutputPaths?: {include: string[]} | {exclude: string[]}
91
-
92
- /**
93
- * Controls which types the instruction is allowed to output to.
94
- *
95
- * @see InstructRequestBase#relativeOutputPaths
96
- * @see InstructRequestBase#conditionalPaths
97
- */
98
- outputTypes?: {include: string[]} | {exclude: string[]}
99
-
100
- /**
101
- * When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
102
- *
103
- * By default, AI Instruct will not output to conditional `readOnly` and `hidden` fields,
104
- * ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
105
- *
106
- * `conditionalPaths` param allows setting the default conditional value for
107
- * `hidden` and `readOnly` to false,
108
- * or individually set `hidden` and `readOnly` state for individual document paths.
109
- *
110
- *
111
- * Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Instruct,
112
- * and cannot be changed via conditionalPaths.
113
- *
114
- * conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
115
- *
116
- * @see InstructRequestBase#relativeOutputPaths
117
- * @see InstructRequestBase#outputTypes
118
- */
119
- conditionalPaths?: {
120
- defaultReadOnly?: boolean
121
- defaultHidden?: boolean
122
- paths?: {
123
- /** path here is not a relative path: it must be the full document path, regardless of `path` param on the request itself */
124
- path: string
125
- readOnly: boolean
126
- hidden: boolean
127
- }[]
128
- }
129
- }
130
-
131
- interface Sync {
132
- /**
133
- * By default, skipWrite: false.
134
- * Write enabled operations will mutate the target document, and emit AI presence in the studio.
135
- *
136
- * When skipWrite: true, the api will not mutate any documents nor emit presence.
137
- * Ie, when true, no changes will be made to content-lake
138
- *
139
- * skipWrite: true is incompatible with async: true,
140
- * as skipWrite implies that you will use the return value of the operation
141
- */
142
- skipWrite?: boolean
143
-
144
- /**
145
- * When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
146
- * The instruction operation will carry on in the background.
147
- *
148
- * When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
149
- *
150
- * async: true is incompatible with skipWrite: true, as async: true does not return the resulting document
151
- */
152
- async?: false
153
- }
154
-
155
- interface Async {
156
- /**
157
- * When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
158
- * The instruction operation will carry on in the background.
159
- *
160
- * When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
161
- *
162
- * async: true is incompatible with skipWrite, as async: true does not return the resulting document
163
- */
164
- async: true
165
- }
166
-
167
- /**
168
- * Instruction for an existing document.
169
- * @beta
170
- */
171
- interface ExistingDocumentRequest {
172
- documentId: string
173
- }
174
-
175
- /**
176
- * Instruction to create a new document
177
- * @beta
178
- */
179
- interface CreateDocumentRequest<T extends Record<string, Any> = Record<string, Any>> {
180
- createDocument: {
181
- /** if no _id is provided, one will be generated. _id is always returned when the requests succeed */
182
- _id?: string
183
- _type: string
184
- } & SanityDocumentStub<T>
185
- }
186
-
187
- /** @beta */
188
- export type InstructSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
189
- | ExistingDocumentRequest
190
- | CreateDocumentRequest<T>
191
- ) &
192
- InstructRequestBase &
193
- Sync
194
-
195
- /** @beta */
196
- export type InstructAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
197
- | ExistingDocumentRequest
198
- | CreateDocumentRequest<T>
199
- ) &
200
- InstructRequestBase &
201
- Async
202
-
203
- /** @beta */
204
- export type InstructInstruction<T extends Record<string, Any> = Record<string, Any>> =
205
- | InstructSyncInstruction<T>
206
- | InstructAsyncInstruction<T>