@sanity/client 7.2.0 → 7.2.1-agent-actions.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/dist/index.browser.cjs +15 -0
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +186 -16
- package/dist/index.browser.d.ts +186 -16
- package/dist/index.browser.js +15 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +16 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +186 -16
- package/dist/index.d.ts +186 -16
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +186 -16
- package/dist/stega.browser.d.ts +186 -16
- package/dist/stega.d.cts +186 -16
- package/dist/stega.d.ts +186 -16
- package/package.json +3 -2
- package/src/agent/actions/AgentActionsClient.ts +11 -0
- package/src/agent/actions/commonTypes.ts +26 -16
- package/src/agent/actions/prompt.ts +150 -0
- package/src/types.ts +1 -0
- package/umd/sanityClient.js +18 -4
- package/umd/sanityClient.min.js +1 -1
package/dist/index.browser.d.cts
CHANGED
|
@@ -55,15 +55,27 @@ declare interface AgentActionAsync {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/** @beta */
|
|
58
|
-
export declare type AgentActionParam
|
|
58
|
+
export declare type AgentActionParam<
|
|
59
|
+
TParamConfig extends {
|
|
60
|
+
docIdRequired: boolean
|
|
61
|
+
} = {
|
|
62
|
+
docIdRequired: false
|
|
63
|
+
},
|
|
64
|
+
> =
|
|
59
65
|
| string
|
|
60
66
|
| ConstantAgentActionParam
|
|
61
|
-
| FieldAgentActionParam
|
|
62
|
-
| DocumentAgentActionParam
|
|
67
|
+
| FieldAgentActionParam<TParamConfig>
|
|
68
|
+
| DocumentAgentActionParam<TParamConfig>
|
|
63
69
|
| GroqAgentActionParam
|
|
64
70
|
|
|
65
71
|
/** @beta */
|
|
66
|
-
export declare type AgentActionParams
|
|
72
|
+
export declare type AgentActionParams<
|
|
73
|
+
TParamConfig extends {
|
|
74
|
+
docIdRequired: boolean
|
|
75
|
+
} = {
|
|
76
|
+
docIdRequired: false
|
|
77
|
+
},
|
|
78
|
+
> = Record<string, AgentActionParam<TParamConfig>>
|
|
67
79
|
|
|
68
80
|
/** @beta */
|
|
69
81
|
export declare type AgentActionPath = AgentActionPathSegment[]
|
|
@@ -192,6 +204,13 @@ declare class AgentActionsClient {
|
|
|
192
204
|
}
|
|
193
205
|
: IdentifiedSanityDocumentStub & DocumentShape
|
|
194
206
|
>
|
|
207
|
+
/**
|
|
208
|
+
* Run a raw instruction and return the result either as text or json
|
|
209
|
+
* @param request - prompt request
|
|
210
|
+
*/
|
|
211
|
+
prompt<DocumentShape extends Record<string, Any>>(
|
|
212
|
+
request: PromptRequest<DocumentShape>,
|
|
213
|
+
): Promise<(typeof request)['json'] extends true ? DocumentShape : string>
|
|
195
214
|
}
|
|
196
215
|
|
|
197
216
|
/** @beta */
|
|
@@ -1095,6 +1114,23 @@ export declare type DisconnectEvent = {
|
|
|
1095
1114
|
reason: string
|
|
1096
1115
|
}
|
|
1097
1116
|
|
|
1117
|
+
declare type DocIdParam<
|
|
1118
|
+
TParamConfig extends {
|
|
1119
|
+
docIdRequired: boolean
|
|
1120
|
+
} = {
|
|
1121
|
+
docIdRequired: false
|
|
1122
|
+
},
|
|
1123
|
+
> = TParamConfig['docIdRequired'] extends true
|
|
1124
|
+
? {
|
|
1125
|
+
documentId: string
|
|
1126
|
+
}
|
|
1127
|
+
: {
|
|
1128
|
+
/**
|
|
1129
|
+
* If omitted, implicitly uses the documentId of the instruction target
|
|
1130
|
+
*/
|
|
1131
|
+
documentId?: string
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1098
1134
|
/**
|
|
1099
1135
|
*
|
|
1100
1136
|
* Includes a LLM-friendly version of the document in the instruction
|
|
@@ -1115,13 +1151,15 @@ export declare type DisconnectEvent = {
|
|
|
1115
1151
|
*
|
|
1116
1152
|
* @beta
|
|
1117
1153
|
* */
|
|
1118
|
-
export declare
|
|
1154
|
+
export declare type DocumentAgentActionParam<
|
|
1155
|
+
TParamConfig extends {
|
|
1156
|
+
docIdRequired: boolean
|
|
1157
|
+
} = {
|
|
1158
|
+
docIdRequired: false
|
|
1159
|
+
},
|
|
1160
|
+
> = {
|
|
1119
1161
|
type: 'document'
|
|
1120
|
-
|
|
1121
|
-
* If omitted, implicitly uses the documentId of the instruction target
|
|
1122
|
-
*/
|
|
1123
|
-
documentId?: string
|
|
1124
|
-
}
|
|
1162
|
+
} & DocIdParam<TParamConfig>
|
|
1125
1163
|
|
|
1126
1164
|
/** @internal */
|
|
1127
1165
|
export declare type EditableReleaseDocument = Omit<
|
|
@@ -1208,17 +1246,19 @@ export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSo
|
|
|
1208
1246
|
*
|
|
1209
1247
|
* @beta
|
|
1210
1248
|
* */
|
|
1211
|
-
export declare
|
|
1249
|
+
export declare type FieldAgentActionParam<
|
|
1250
|
+
TParamConfig extends {
|
|
1251
|
+
docIdRequired: boolean
|
|
1252
|
+
} = {
|
|
1253
|
+
docIdRequired: false
|
|
1254
|
+
},
|
|
1255
|
+
> = {
|
|
1212
1256
|
type: 'field'
|
|
1213
1257
|
/**
|
|
1214
1258
|
* Examples: 'title', ['array', \{_key: 'arrayItemKey'\}, 'field']
|
|
1215
1259
|
*/
|
|
1216
1260
|
path: AgentActionPathSegment | AgentActionPath
|
|
1217
|
-
|
|
1218
|
-
* If omitted, implicitly uses the documentId of the instruction target
|
|
1219
|
-
*/
|
|
1220
|
-
documentId?: string
|
|
1221
|
-
}
|
|
1261
|
+
} & DocIdParam<TParamConfig>
|
|
1222
1262
|
|
|
1223
1263
|
/** @public */
|
|
1224
1264
|
export declare type FilterDefault = (props: {
|
|
@@ -3429,6 +3469,136 @@ export declare class ProjectsClient {
|
|
|
3429
3469
|
getById(projectId: string): Promise<SanityProject>
|
|
3430
3470
|
}
|
|
3431
3471
|
|
|
3472
|
+
/**
|
|
3473
|
+
* @beta
|
|
3474
|
+
*/
|
|
3475
|
+
declare interface PromptJsonResponse<T extends Record<string, Any> = Record<string, Any>> {
|
|
3476
|
+
/**
|
|
3477
|
+
*
|
|
3478
|
+
* When true, the response body will be json according to the instruction.
|
|
3479
|
+
* When false, the response is the raw text response to the instruction.
|
|
3480
|
+
*
|
|
3481
|
+
* Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3482
|
+
*/
|
|
3483
|
+
json: true
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
/** @beta */
|
|
3487
|
+
export declare type PromptRequest<T extends Record<string, Any> = Record<string, Any>> = (
|
|
3488
|
+
| PromptTextResponse
|
|
3489
|
+
| PromptJsonResponse<T>
|
|
3490
|
+
) &
|
|
3491
|
+
PromptRequestBase
|
|
3492
|
+
|
|
3493
|
+
/** @beta */
|
|
3494
|
+
declare interface PromptRequestBase {
|
|
3495
|
+
/**
|
|
3496
|
+
* Instruct the LLM how it should generate content. Be as specific and detailed as needed.
|
|
3497
|
+
*
|
|
3498
|
+
* The LLM only has access to information in the instruction, plus the target schema.
|
|
3499
|
+
*
|
|
3500
|
+
* string template using $variable
|
|
3501
|
+
* */
|
|
3502
|
+
instruction: string
|
|
3503
|
+
/**
|
|
3504
|
+
* param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable"
|
|
3505
|
+
*
|
|
3506
|
+
* ### Examples
|
|
3507
|
+
*
|
|
3508
|
+
* #### Constant
|
|
3509
|
+
*
|
|
3510
|
+
* ##### Shorthand
|
|
3511
|
+
* ```ts
|
|
3512
|
+
* client.agent.action.generate({
|
|
3513
|
+
* schemaId,
|
|
3514
|
+
* documentId,
|
|
3515
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it',
|
|
3516
|
+
* instructionParams: {
|
|
3517
|
+
* topic: 'Grapefruit'
|
|
3518
|
+
* },
|
|
3519
|
+
* })
|
|
3520
|
+
* ```
|
|
3521
|
+
* ##### Object-form
|
|
3522
|
+
*
|
|
3523
|
+
* ```ts
|
|
3524
|
+
* client.agent.action.prompt({
|
|
3525
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it.',
|
|
3526
|
+
* instructionParams: {
|
|
3527
|
+
* topic: {
|
|
3528
|
+
* type: 'constant',
|
|
3529
|
+
* value: 'Grapefruit'
|
|
3530
|
+
* },
|
|
3531
|
+
* },
|
|
3532
|
+
* })
|
|
3533
|
+
* ```
|
|
3534
|
+
* #### Field
|
|
3535
|
+
* ```ts
|
|
3536
|
+
* client.agent.action.prompt({
|
|
3537
|
+
* instruction: 'Give the following field value:\n $pte \n ---\nGenerate keywords.',
|
|
3538
|
+
* instructionParams: {
|
|
3539
|
+
* pte: {
|
|
3540
|
+
* type: 'field',
|
|
3541
|
+
* path: ['pteField'],
|
|
3542
|
+
* documentId: 'someSanityDocId'
|
|
3543
|
+
* },
|
|
3544
|
+
* },
|
|
3545
|
+
* })
|
|
3546
|
+
* ```
|
|
3547
|
+
* #### Document
|
|
3548
|
+
* ```ts
|
|
3549
|
+
* client.agent.action.prompt({
|
|
3550
|
+
* json: true,
|
|
3551
|
+
* instruction: 'Given the following document:$document\nCreate a JSON string[] array with keywords describing it.',
|
|
3552
|
+
* instructionParams: {
|
|
3553
|
+
* document: {
|
|
3554
|
+
* type: 'document',
|
|
3555
|
+
* documentId: 'someSanityDocId'
|
|
3556
|
+
* },
|
|
3557
|
+
* },
|
|
3558
|
+
* })
|
|
3559
|
+
* ```
|
|
3560
|
+
*
|
|
3561
|
+
* #### GROQ
|
|
3562
|
+
* ```ts
|
|
3563
|
+
* client.agent.action.prompt({
|
|
3564
|
+
* instruction: 'Return the best title amongst these: $titles.',
|
|
3565
|
+
* instructionParams: {
|
|
3566
|
+
* titles: {
|
|
3567
|
+
* type: 'groq',
|
|
3568
|
+
* query: '* [_type==$type].title',
|
|
3569
|
+
* params: {type: 'article'}
|
|
3570
|
+
* },
|
|
3571
|
+
* },
|
|
3572
|
+
* })
|
|
3573
|
+
* ```
|
|
3574
|
+
* */
|
|
3575
|
+
instructionParams?: AgentActionParams<{
|
|
3576
|
+
docIdRequired: true
|
|
3577
|
+
}>
|
|
3578
|
+
/**
|
|
3579
|
+
* Controls how much variance the instructions will run with.
|
|
3580
|
+
*
|
|
3581
|
+
* Value must be in the range [0, 1] (inclusive).
|
|
3582
|
+
*
|
|
3583
|
+
* Defaults:
|
|
3584
|
+
* - generate: 0.3
|
|
3585
|
+
* - translate: 0
|
|
3586
|
+
* - transform: 0
|
|
3587
|
+
*/
|
|
3588
|
+
temperature?: number
|
|
3589
|
+
}
|
|
3590
|
+
|
|
3591
|
+
declare interface PromptTextResponse {
|
|
3592
|
+
/**
|
|
3593
|
+
*
|
|
3594
|
+
* When true, the response body will be json according to the instruction.
|
|
3595
|
+
* When false, the response is the raw text response to the instruction.
|
|
3596
|
+
*
|
|
3597
|
+
* Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3598
|
+
*/
|
|
3599
|
+
json?: false
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3432
3602
|
/**
|
|
3433
3603
|
* Publishes a draft document.
|
|
3434
3604
|
* If a published version of the document already exists this is replaced by the current draft document.
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -55,15 +55,27 @@ declare interface AgentActionAsync {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/** @beta */
|
|
58
|
-
export declare type AgentActionParam
|
|
58
|
+
export declare type AgentActionParam<
|
|
59
|
+
TParamConfig extends {
|
|
60
|
+
docIdRequired: boolean
|
|
61
|
+
} = {
|
|
62
|
+
docIdRequired: false
|
|
63
|
+
},
|
|
64
|
+
> =
|
|
59
65
|
| string
|
|
60
66
|
| ConstantAgentActionParam
|
|
61
|
-
| FieldAgentActionParam
|
|
62
|
-
| DocumentAgentActionParam
|
|
67
|
+
| FieldAgentActionParam<TParamConfig>
|
|
68
|
+
| DocumentAgentActionParam<TParamConfig>
|
|
63
69
|
| GroqAgentActionParam
|
|
64
70
|
|
|
65
71
|
/** @beta */
|
|
66
|
-
export declare type AgentActionParams
|
|
72
|
+
export declare type AgentActionParams<
|
|
73
|
+
TParamConfig extends {
|
|
74
|
+
docIdRequired: boolean
|
|
75
|
+
} = {
|
|
76
|
+
docIdRequired: false
|
|
77
|
+
},
|
|
78
|
+
> = Record<string, AgentActionParam<TParamConfig>>
|
|
67
79
|
|
|
68
80
|
/** @beta */
|
|
69
81
|
export declare type AgentActionPath = AgentActionPathSegment[]
|
|
@@ -192,6 +204,13 @@ declare class AgentActionsClient {
|
|
|
192
204
|
}
|
|
193
205
|
: IdentifiedSanityDocumentStub & DocumentShape
|
|
194
206
|
>
|
|
207
|
+
/**
|
|
208
|
+
* Run a raw instruction and return the result either as text or json
|
|
209
|
+
* @param request - prompt request
|
|
210
|
+
*/
|
|
211
|
+
prompt<DocumentShape extends Record<string, Any>>(
|
|
212
|
+
request: PromptRequest<DocumentShape>,
|
|
213
|
+
): Promise<(typeof request)['json'] extends true ? DocumentShape : string>
|
|
195
214
|
}
|
|
196
215
|
|
|
197
216
|
/** @beta */
|
|
@@ -1095,6 +1114,23 @@ export declare type DisconnectEvent = {
|
|
|
1095
1114
|
reason: string
|
|
1096
1115
|
}
|
|
1097
1116
|
|
|
1117
|
+
declare type DocIdParam<
|
|
1118
|
+
TParamConfig extends {
|
|
1119
|
+
docIdRequired: boolean
|
|
1120
|
+
} = {
|
|
1121
|
+
docIdRequired: false
|
|
1122
|
+
},
|
|
1123
|
+
> = TParamConfig['docIdRequired'] extends true
|
|
1124
|
+
? {
|
|
1125
|
+
documentId: string
|
|
1126
|
+
}
|
|
1127
|
+
: {
|
|
1128
|
+
/**
|
|
1129
|
+
* If omitted, implicitly uses the documentId of the instruction target
|
|
1130
|
+
*/
|
|
1131
|
+
documentId?: string
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1098
1134
|
/**
|
|
1099
1135
|
*
|
|
1100
1136
|
* Includes a LLM-friendly version of the document in the instruction
|
|
@@ -1115,13 +1151,15 @@ export declare type DisconnectEvent = {
|
|
|
1115
1151
|
*
|
|
1116
1152
|
* @beta
|
|
1117
1153
|
* */
|
|
1118
|
-
export declare
|
|
1154
|
+
export declare type DocumentAgentActionParam<
|
|
1155
|
+
TParamConfig extends {
|
|
1156
|
+
docIdRequired: boolean
|
|
1157
|
+
} = {
|
|
1158
|
+
docIdRequired: false
|
|
1159
|
+
},
|
|
1160
|
+
> = {
|
|
1119
1161
|
type: 'document'
|
|
1120
|
-
|
|
1121
|
-
* If omitted, implicitly uses the documentId of the instruction target
|
|
1122
|
-
*/
|
|
1123
|
-
documentId?: string
|
|
1124
|
-
}
|
|
1162
|
+
} & DocIdParam<TParamConfig>
|
|
1125
1163
|
|
|
1126
1164
|
/** @internal */
|
|
1127
1165
|
export declare type EditableReleaseDocument = Omit<
|
|
@@ -1208,17 +1246,19 @@ export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSo
|
|
|
1208
1246
|
*
|
|
1209
1247
|
* @beta
|
|
1210
1248
|
* */
|
|
1211
|
-
export declare
|
|
1249
|
+
export declare type FieldAgentActionParam<
|
|
1250
|
+
TParamConfig extends {
|
|
1251
|
+
docIdRequired: boolean
|
|
1252
|
+
} = {
|
|
1253
|
+
docIdRequired: false
|
|
1254
|
+
},
|
|
1255
|
+
> = {
|
|
1212
1256
|
type: 'field'
|
|
1213
1257
|
/**
|
|
1214
1258
|
* Examples: 'title', ['array', \{_key: 'arrayItemKey'\}, 'field']
|
|
1215
1259
|
*/
|
|
1216
1260
|
path: AgentActionPathSegment | AgentActionPath
|
|
1217
|
-
|
|
1218
|
-
* If omitted, implicitly uses the documentId of the instruction target
|
|
1219
|
-
*/
|
|
1220
|
-
documentId?: string
|
|
1221
|
-
}
|
|
1261
|
+
} & DocIdParam<TParamConfig>
|
|
1222
1262
|
|
|
1223
1263
|
/** @public */
|
|
1224
1264
|
export declare type FilterDefault = (props: {
|
|
@@ -3429,6 +3469,136 @@ export declare class ProjectsClient {
|
|
|
3429
3469
|
getById(projectId: string): Promise<SanityProject>
|
|
3430
3470
|
}
|
|
3431
3471
|
|
|
3472
|
+
/**
|
|
3473
|
+
* @beta
|
|
3474
|
+
*/
|
|
3475
|
+
declare interface PromptJsonResponse<T extends Record<string, Any> = Record<string, Any>> {
|
|
3476
|
+
/**
|
|
3477
|
+
*
|
|
3478
|
+
* When true, the response body will be json according to the instruction.
|
|
3479
|
+
* When false, the response is the raw text response to the instruction.
|
|
3480
|
+
*
|
|
3481
|
+
* Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3482
|
+
*/
|
|
3483
|
+
json: true
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
/** @beta */
|
|
3487
|
+
export declare type PromptRequest<T extends Record<string, Any> = Record<string, Any>> = (
|
|
3488
|
+
| PromptTextResponse
|
|
3489
|
+
| PromptJsonResponse<T>
|
|
3490
|
+
) &
|
|
3491
|
+
PromptRequestBase
|
|
3492
|
+
|
|
3493
|
+
/** @beta */
|
|
3494
|
+
declare interface PromptRequestBase {
|
|
3495
|
+
/**
|
|
3496
|
+
* Instruct the LLM how it should generate content. Be as specific and detailed as needed.
|
|
3497
|
+
*
|
|
3498
|
+
* The LLM only has access to information in the instruction, plus the target schema.
|
|
3499
|
+
*
|
|
3500
|
+
* string template using $variable
|
|
3501
|
+
* */
|
|
3502
|
+
instruction: string
|
|
3503
|
+
/**
|
|
3504
|
+
* param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable"
|
|
3505
|
+
*
|
|
3506
|
+
* ### Examples
|
|
3507
|
+
*
|
|
3508
|
+
* #### Constant
|
|
3509
|
+
*
|
|
3510
|
+
* ##### Shorthand
|
|
3511
|
+
* ```ts
|
|
3512
|
+
* client.agent.action.generate({
|
|
3513
|
+
* schemaId,
|
|
3514
|
+
* documentId,
|
|
3515
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it',
|
|
3516
|
+
* instructionParams: {
|
|
3517
|
+
* topic: 'Grapefruit'
|
|
3518
|
+
* },
|
|
3519
|
+
* })
|
|
3520
|
+
* ```
|
|
3521
|
+
* ##### Object-form
|
|
3522
|
+
*
|
|
3523
|
+
* ```ts
|
|
3524
|
+
* client.agent.action.prompt({
|
|
3525
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it.',
|
|
3526
|
+
* instructionParams: {
|
|
3527
|
+
* topic: {
|
|
3528
|
+
* type: 'constant',
|
|
3529
|
+
* value: 'Grapefruit'
|
|
3530
|
+
* },
|
|
3531
|
+
* },
|
|
3532
|
+
* })
|
|
3533
|
+
* ```
|
|
3534
|
+
* #### Field
|
|
3535
|
+
* ```ts
|
|
3536
|
+
* client.agent.action.prompt({
|
|
3537
|
+
* instruction: 'Give the following field value:\n $pte \n ---\nGenerate keywords.',
|
|
3538
|
+
* instructionParams: {
|
|
3539
|
+
* pte: {
|
|
3540
|
+
* type: 'field',
|
|
3541
|
+
* path: ['pteField'],
|
|
3542
|
+
* documentId: 'someSanityDocId'
|
|
3543
|
+
* },
|
|
3544
|
+
* },
|
|
3545
|
+
* })
|
|
3546
|
+
* ```
|
|
3547
|
+
* #### Document
|
|
3548
|
+
* ```ts
|
|
3549
|
+
* client.agent.action.prompt({
|
|
3550
|
+
* json: true,
|
|
3551
|
+
* instruction: 'Given the following document:$document\nCreate a JSON string[] array with keywords describing it.',
|
|
3552
|
+
* instructionParams: {
|
|
3553
|
+
* document: {
|
|
3554
|
+
* type: 'document',
|
|
3555
|
+
* documentId: 'someSanityDocId'
|
|
3556
|
+
* },
|
|
3557
|
+
* },
|
|
3558
|
+
* })
|
|
3559
|
+
* ```
|
|
3560
|
+
*
|
|
3561
|
+
* #### GROQ
|
|
3562
|
+
* ```ts
|
|
3563
|
+
* client.agent.action.prompt({
|
|
3564
|
+
* instruction: 'Return the best title amongst these: $titles.',
|
|
3565
|
+
* instructionParams: {
|
|
3566
|
+
* titles: {
|
|
3567
|
+
* type: 'groq',
|
|
3568
|
+
* query: '* [_type==$type].title',
|
|
3569
|
+
* params: {type: 'article'}
|
|
3570
|
+
* },
|
|
3571
|
+
* },
|
|
3572
|
+
* })
|
|
3573
|
+
* ```
|
|
3574
|
+
* */
|
|
3575
|
+
instructionParams?: AgentActionParams<{
|
|
3576
|
+
docIdRequired: true
|
|
3577
|
+
}>
|
|
3578
|
+
/**
|
|
3579
|
+
* Controls how much variance the instructions will run with.
|
|
3580
|
+
*
|
|
3581
|
+
* Value must be in the range [0, 1] (inclusive).
|
|
3582
|
+
*
|
|
3583
|
+
* Defaults:
|
|
3584
|
+
* - generate: 0.3
|
|
3585
|
+
* - translate: 0
|
|
3586
|
+
* - transform: 0
|
|
3587
|
+
*/
|
|
3588
|
+
temperature?: number
|
|
3589
|
+
}
|
|
3590
|
+
|
|
3591
|
+
declare interface PromptTextResponse {
|
|
3592
|
+
/**
|
|
3593
|
+
*
|
|
3594
|
+
* When true, the response body will be json according to the instruction.
|
|
3595
|
+
* When false, the response is the raw text response to the instruction.
|
|
3596
|
+
*
|
|
3597
|
+
* Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3598
|
+
*/
|
|
3599
|
+
json?: false
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3432
3602
|
/**
|
|
3433
3603
|
* Publishes a draft document.
|
|
3434
3604
|
* If a published version of the document already exists this is replaced by the current draft document.
|
package/dist/index.browser.js
CHANGED
|
@@ -1042,6 +1042,14 @@ function _generate(client, httpRequest, request) {
|
|
|
1042
1042
|
body: request
|
|
1043
1043
|
});
|
|
1044
1044
|
}
|
|
1045
|
+
function _prompt(client, httpRequest, request) {
|
|
1046
|
+
const dataset2 = hasDataset(client.config());
|
|
1047
|
+
return _request(client, httpRequest, {
|
|
1048
|
+
method: "POST",
|
|
1049
|
+
uri: `/agent/action/prompt/${dataset2}`,
|
|
1050
|
+
body: request
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1045
1053
|
function _transform(client, httpRequest, request) {
|
|
1046
1054
|
const dataset2 = hasDataset(client.config());
|
|
1047
1055
|
return _request(client, httpRequest, {
|
|
@@ -1113,6 +1121,13 @@ class AgentActionsClient {
|
|
|
1113
1121
|
translate(request) {
|
|
1114
1122
|
return lastValueFrom(_translate(this.#client, this.#httpRequest, request));
|
|
1115
1123
|
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Run a raw instruction and return the result either as text or json
|
|
1126
|
+
* @param request - prompt request
|
|
1127
|
+
*/
|
|
1128
|
+
prompt(request) {
|
|
1129
|
+
return lastValueFrom(_prompt(this.#client, this.#httpRequest, request));
|
|
1130
|
+
}
|
|
1116
1131
|
}
|
|
1117
1132
|
class ObservableAssetsClient {
|
|
1118
1133
|
#client;
|