@gleanwork/api-client 0.13.1 → 0.13.3
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 +2 -1
- package/dist/commonjs/__tests__/messages.test.js +1 -1
- package/dist/commonjs/__tests__/messages.test.js.map +1 -1
- package/dist/commonjs/__tests__/summarize.test.js +4 -3
- package/dist/commonjs/__tests__/summarize.test.js.map +1 -1
- package/dist/commonjs/lib/config.d.ts +3 -3
- package/dist/commonjs/lib/config.js +3 -3
- package/dist/commonjs/models/components/agentsinsightsv2response.d.ts +4 -0
- package/dist/commonjs/models/components/agentsinsightsv2response.d.ts.map +1 -1
- package/dist/commonjs/models/components/agentsinsightsv2response.js +4 -0
- package/dist/commonjs/models/components/agentsinsightsv2response.js.map +1 -1
- package/dist/commonjs/models/components/chatmessagefragment.d.ts +1 -1
- package/dist/commonjs/models/components/debugdatasourcestatusresponse.d.ts +3 -1
- package/dist/commonjs/models/components/debugdatasourcestatusresponse.d.ts.map +1 -1
- package/dist/commonjs/models/components/debugdatasourcestatusresponse.js.map +1 -1
- package/dist/commonjs/models/components/peragentinsight.d.ts +10 -0
- package/dist/commonjs/models/components/peragentinsight.d.ts.map +1 -1
- package/dist/commonjs/models/components/peragentinsight.js +4 -0
- package/dist/commonjs/models/components/peragentinsight.js.map +1 -1
- package/dist/esm/__tests__/messages.test.js +1 -1
- package/dist/esm/__tests__/messages.test.js.map +1 -1
- package/dist/esm/__tests__/summarize.test.js +4 -3
- package/dist/esm/__tests__/summarize.test.js.map +1 -1
- package/dist/esm/lib/config.d.ts +3 -3
- package/dist/esm/lib/config.js +3 -3
- package/dist/esm/models/components/agentsinsightsv2response.d.ts +4 -0
- package/dist/esm/models/components/agentsinsightsv2response.d.ts.map +1 -1
- package/dist/esm/models/components/agentsinsightsv2response.js +4 -0
- package/dist/esm/models/components/agentsinsightsv2response.js.map +1 -1
- package/dist/esm/models/components/chatmessagefragment.d.ts +1 -1
- package/dist/esm/models/components/debugdatasourcestatusresponse.d.ts +3 -1
- package/dist/esm/models/components/debugdatasourcestatusresponse.d.ts.map +1 -1
- package/dist/esm/models/components/debugdatasourcestatusresponse.js.map +1 -1
- package/dist/esm/models/components/peragentinsight.d.ts +10 -0
- package/dist/esm/models/components/peragentinsight.d.ts.map +1 -1
- package/dist/esm/models/components/peragentinsight.js +4 -0
- package/dist/esm/models/components/peragentinsight.js.map +1 -1
- package/examples/package-lock.json +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/__tests__/messages.test.ts +1 -1
- package/src/__tests__/summarize.test.ts +4 -3
- package/src/lib/config.ts +3 -3
- package/src/models/components/agentsinsightsv2response.ts +8 -0
- package/src/models/components/chatmessagefragment.ts +1 -1
- package/src/models/components/debugdatasourcestatusresponse.ts +3 -1
- package/src/models/components/peragentinsight.ts +14 -0
- package/.devcontainer/README.md +0 -35
- package/docs/sdks/activity/README.md +0 -242
- package/docs/sdks/agents/README.md +0 -498
- package/docs/sdks/announcements/README.md +0 -137560
- package/docs/sdks/answers/README.md +0 -4966
- package/docs/sdks/chat/README.md +0 -967
- package/docs/sdks/clientauthentication/README.md +0 -98
- package/docs/sdks/clientdocuments/README.md +0 -457
- package/docs/sdks/clientshortcuts/README.md +0 -9340
- package/docs/sdks/collections/README.md +0 -4148
- package/docs/sdks/datasource/README.md +0 -98
- package/docs/sdks/datasources/README.md +0 -211
- package/docs/sdks/entities/README.md +0 -225
- package/docs/sdks/indexingauthentication/README.md +0 -93
- package/docs/sdks/indexingdocuments/README.md +0 -983
- package/docs/sdks/indexingshortcuts/README.md +0 -251
- package/docs/sdks/insights/README.md +0 -94
- package/docs/sdks/messages/README.md +0 -102
- package/docs/sdks/people/README.md +0 -1052
- package/docs/sdks/permissions/README.md +0 -1198
- package/docs/sdks/pins/README.md +0 -506
- package/docs/sdks/policies/README.md +0 -478
- package/docs/sdks/reports/README.md +0 -290
- package/docs/sdks/search/README.md +0 -986
- package/docs/sdks/tools/README.md +0 -208
- package/docs/sdks/verification/README.md +0 -276
- package/docs/sdks/visibilityoverrides/README.md +0 -192
- package/examples/README.md +0 -31
- package/src/__tests__/mockserver/README.md +0 -52
|
@@ -1,498 +0,0 @@
|
|
|
1
|
-
# Agents
|
|
2
|
-
(*client.agents*)
|
|
3
|
-
|
|
4
|
-
## Overview
|
|
5
|
-
|
|
6
|
-
### Available Operations
|
|
7
|
-
|
|
8
|
-
* [retrieve](#retrieve) - Retrieve an agent
|
|
9
|
-
* [retrieveSchemas](#retrieveschemas) - List an agent's schemas
|
|
10
|
-
* [list](#list) - Search agents
|
|
11
|
-
* [runStream](#runstream) - Create an agent run and stream the response
|
|
12
|
-
* [run](#run) - Create an agent run and wait for the response
|
|
13
|
-
|
|
14
|
-
## retrieve
|
|
15
|
-
|
|
16
|
-
Returns details of an [agent](https://developers.glean.com/agents/agents-api) created in the Agent Builder.
|
|
17
|
-
|
|
18
|
-
### Example Usage
|
|
19
|
-
|
|
20
|
-
<!-- UsageSnippet language="typescript" operationID="getAgent" method="get" path="/rest/api/v1/agents/{agent_id}" -->
|
|
21
|
-
```typescript
|
|
22
|
-
import { Glean } from "@gleanwork/api-client";
|
|
23
|
-
|
|
24
|
-
const glean = new Glean({
|
|
25
|
-
apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
async function run() {
|
|
29
|
-
const result = await glean.client.agents.retrieve("<id>");
|
|
30
|
-
|
|
31
|
-
console.log(result);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
run();
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### Standalone function
|
|
38
|
-
|
|
39
|
-
The standalone function version of this method:
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
import { GleanCore } from "@gleanwork/api-client/core.js";
|
|
43
|
-
import { clientAgentsRetrieve } from "@gleanwork/api-client/funcs/clientAgentsRetrieve.js";
|
|
44
|
-
|
|
45
|
-
// Use `GleanCore` for best tree-shaking performance.
|
|
46
|
-
// You can create one instance of it to use across an application.
|
|
47
|
-
const glean = new GleanCore({
|
|
48
|
-
apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
async function run() {
|
|
52
|
-
const res = await clientAgentsRetrieve(glean, "<id>");
|
|
53
|
-
if (res.ok) {
|
|
54
|
-
const { value: result } = res;
|
|
55
|
-
console.log(result);
|
|
56
|
-
} else {
|
|
57
|
-
console.log("clientAgentsRetrieve failed:", res.error);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
run();
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### React hooks and utilities
|
|
65
|
-
|
|
66
|
-
This method can be used in React components through the following hooks and
|
|
67
|
-
associated utilities.
|
|
68
|
-
|
|
69
|
-
> Check out [this guide][hook-guide] for information about each of the utilities
|
|
70
|
-
> below and how to get started using React hooks.
|
|
71
|
-
|
|
72
|
-
[hook-guide]: ../../../REACT_QUERY.md
|
|
73
|
-
|
|
74
|
-
```tsx
|
|
75
|
-
import {
|
|
76
|
-
// Query hooks for fetching data.
|
|
77
|
-
useClientAgentsRetrieve,
|
|
78
|
-
useClientAgentsRetrieveSuspense,
|
|
79
|
-
|
|
80
|
-
// Utility for prefetching data during server-side rendering and in React
|
|
81
|
-
// Server Components that will be immediately available to client components
|
|
82
|
-
// using the hooks.
|
|
83
|
-
prefetchClientAgentsRetrieve,
|
|
84
|
-
|
|
85
|
-
// Utilities to invalidate the query cache for this query in response to
|
|
86
|
-
// mutations and other user actions.
|
|
87
|
-
invalidateClientAgentsRetrieve,
|
|
88
|
-
invalidateAllClientAgentsRetrieve,
|
|
89
|
-
} from "@gleanwork/api-client/react-query/clientAgentsRetrieve.js";
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Parameters
|
|
93
|
-
|
|
94
|
-
| Parameter | Type | Required | Description |
|
|
95
|
-
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
96
|
-
| `agentId` | *string* | :heavy_check_mark: | The ID of the agent. |
|
|
97
|
-
| `timezoneOffset` | *number* | :heavy_minus_sign: | The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. |
|
|
98
|
-
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
99
|
-
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
100
|
-
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
101
|
-
|
|
102
|
-
### Response
|
|
103
|
-
|
|
104
|
-
**Promise\<[components.Agent](../../models/components/agent.md)\>**
|
|
105
|
-
|
|
106
|
-
### Errors
|
|
107
|
-
|
|
108
|
-
| Error Type | Status Code | Content Type |
|
|
109
|
-
| ----------------- | ----------------- | ----------------- |
|
|
110
|
-
| errors.GleanError | 4XX, 5XX | \*/\* |
|
|
111
|
-
|
|
112
|
-
## retrieveSchemas
|
|
113
|
-
|
|
114
|
-
Return [agent](https://developers.glean.com/agents/agents-api)'s input and output schemas. You can use these schemas to detect changes to an agent's input or output structure.
|
|
115
|
-
|
|
116
|
-
### Example Usage
|
|
117
|
-
|
|
118
|
-
<!-- UsageSnippet language="typescript" operationID="getAgentSchemas" method="get" path="/rest/api/v1/agents/{agent_id}/schemas" -->
|
|
119
|
-
```typescript
|
|
120
|
-
import { Glean } from "@gleanwork/api-client";
|
|
121
|
-
|
|
122
|
-
const glean = new Glean({
|
|
123
|
-
apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
async function run() {
|
|
127
|
-
const result = await glean.client.agents.retrieveSchemas("<id>");
|
|
128
|
-
|
|
129
|
-
console.log(result);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
run();
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Standalone function
|
|
136
|
-
|
|
137
|
-
The standalone function version of this method:
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
import { GleanCore } from "@gleanwork/api-client/core.js";
|
|
141
|
-
import { clientAgentsRetrieveSchemas } from "@gleanwork/api-client/funcs/clientAgentsRetrieveSchemas.js";
|
|
142
|
-
|
|
143
|
-
// Use `GleanCore` for best tree-shaking performance.
|
|
144
|
-
// You can create one instance of it to use across an application.
|
|
145
|
-
const glean = new GleanCore({
|
|
146
|
-
apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
async function run() {
|
|
150
|
-
const res = await clientAgentsRetrieveSchemas(glean, "<id>");
|
|
151
|
-
if (res.ok) {
|
|
152
|
-
const { value: result } = res;
|
|
153
|
-
console.log(result);
|
|
154
|
-
} else {
|
|
155
|
-
console.log("clientAgentsRetrieveSchemas failed:", res.error);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
run();
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### React hooks and utilities
|
|
163
|
-
|
|
164
|
-
This method can be used in React components through the following hooks and
|
|
165
|
-
associated utilities.
|
|
166
|
-
|
|
167
|
-
> Check out [this guide][hook-guide] for information about each of the utilities
|
|
168
|
-
> below and how to get started using React hooks.
|
|
169
|
-
|
|
170
|
-
[hook-guide]: ../../../REACT_QUERY.md
|
|
171
|
-
|
|
172
|
-
```tsx
|
|
173
|
-
import {
|
|
174
|
-
// Query hooks for fetching data.
|
|
175
|
-
useClientAgentsRetrieveSchemas,
|
|
176
|
-
useClientAgentsRetrieveSchemasSuspense,
|
|
177
|
-
|
|
178
|
-
// Utility for prefetching data during server-side rendering and in React
|
|
179
|
-
// Server Components that will be immediately available to client components
|
|
180
|
-
// using the hooks.
|
|
181
|
-
prefetchClientAgentsRetrieveSchemas,
|
|
182
|
-
|
|
183
|
-
// Utilities to invalidate the query cache for this query in response to
|
|
184
|
-
// mutations and other user actions.
|
|
185
|
-
invalidateClientAgentsRetrieveSchemas,
|
|
186
|
-
invalidateAllClientAgentsRetrieveSchemas,
|
|
187
|
-
} from "@gleanwork/api-client/react-query/clientAgentsRetrieveSchemas.js";
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### Parameters
|
|
191
|
-
|
|
192
|
-
| Parameter | Type | Required | Description |
|
|
193
|
-
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
194
|
-
| `agentId` | *string* | :heavy_check_mark: | The ID of the agent. |
|
|
195
|
-
| `timezoneOffset` | *number* | :heavy_minus_sign: | The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. |
|
|
196
|
-
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
197
|
-
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
198
|
-
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
199
|
-
|
|
200
|
-
### Response
|
|
201
|
-
|
|
202
|
-
**Promise\<[components.AgentSchemas](../../models/components/agentschemas.md)\>**
|
|
203
|
-
|
|
204
|
-
### Errors
|
|
205
|
-
|
|
206
|
-
| Error Type | Status Code | Content Type |
|
|
207
|
-
| ----------------- | ----------------- | ----------------- |
|
|
208
|
-
| errors.GleanError | 4XX, 5XX | \*/\* |
|
|
209
|
-
|
|
210
|
-
## list
|
|
211
|
-
|
|
212
|
-
Search for [agents](https://developers.glean.com/agents/agents-api) by agent name.
|
|
213
|
-
|
|
214
|
-
### Example Usage
|
|
215
|
-
|
|
216
|
-
<!-- UsageSnippet language="typescript" operationID="searchAgents" method="post" path="/rest/api/v1/agents/search" -->
|
|
217
|
-
```typescript
|
|
218
|
-
import { Glean } from "@gleanwork/api-client";
|
|
219
|
-
|
|
220
|
-
const glean = new Glean({
|
|
221
|
-
apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
async function run() {
|
|
225
|
-
const result = await glean.client.agents.list({
|
|
226
|
-
name: "HR Policy Agent",
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
console.log(result);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
run();
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Standalone function
|
|
236
|
-
|
|
237
|
-
The standalone function version of this method:
|
|
238
|
-
|
|
239
|
-
```typescript
|
|
240
|
-
import { GleanCore } from "@gleanwork/api-client/core.js";
|
|
241
|
-
import { clientAgentsList } from "@gleanwork/api-client/funcs/clientAgentsList.js";
|
|
242
|
-
|
|
243
|
-
// Use `GleanCore` for best tree-shaking performance.
|
|
244
|
-
// You can create one instance of it to use across an application.
|
|
245
|
-
const glean = new GleanCore({
|
|
246
|
-
apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
async function run() {
|
|
250
|
-
const res = await clientAgentsList(glean, {
|
|
251
|
-
name: "HR Policy Agent",
|
|
252
|
-
});
|
|
253
|
-
if (res.ok) {
|
|
254
|
-
const { value: result } = res;
|
|
255
|
-
console.log(result);
|
|
256
|
-
} else {
|
|
257
|
-
console.log("clientAgentsList failed:", res.error);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
run();
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
### React hooks and utilities
|
|
265
|
-
|
|
266
|
-
This method can be used in React components through the following hooks and
|
|
267
|
-
associated utilities.
|
|
268
|
-
|
|
269
|
-
> Check out [this guide][hook-guide] for information about each of the utilities
|
|
270
|
-
> below and how to get started using React hooks.
|
|
271
|
-
|
|
272
|
-
[hook-guide]: ../../../REACT_QUERY.md
|
|
273
|
-
|
|
274
|
-
```tsx
|
|
275
|
-
import {
|
|
276
|
-
// Mutation hook for triggering the API call.
|
|
277
|
-
useClientAgentsListMutation
|
|
278
|
-
} from "@gleanwork/api-client/react-query/clientAgentsList.js";
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### Parameters
|
|
282
|
-
|
|
283
|
-
| Parameter | Type | Required | Description |
|
|
284
|
-
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
285
|
-
| `request` | [components.SearchAgentsRequest](../../models/components/searchagentsrequest.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
286
|
-
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
287
|
-
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
288
|
-
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
289
|
-
|
|
290
|
-
### Response
|
|
291
|
-
|
|
292
|
-
**Promise\<[components.SearchAgentsResponse](../../models/components/searchagentsresponse.md)\>**
|
|
293
|
-
|
|
294
|
-
### Errors
|
|
295
|
-
|
|
296
|
-
| Error Type | Status Code | Content Type |
|
|
297
|
-
| ----------------- | ----------------- | ----------------- |
|
|
298
|
-
| errors.GleanError | 4XX, 5XX | \*/\* |
|
|
299
|
-
|
|
300
|
-
## runStream
|
|
301
|
-
|
|
302
|
-
Executes an [agent](https://developers.glean.com/agents/agents-api) run and returns the result as a stream of server-sent events (SSE).
|
|
303
|
-
|
|
304
|
-
### Example Usage
|
|
305
|
-
|
|
306
|
-
<!-- UsageSnippet language="typescript" operationID="createAndStreamRun" method="post" path="/rest/api/v1/agents/runs/stream" -->
|
|
307
|
-
```typescript
|
|
308
|
-
import { Glean } from "@gleanwork/api-client";
|
|
309
|
-
|
|
310
|
-
const glean = new Glean({
|
|
311
|
-
apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
async function run() {
|
|
315
|
-
const result = await glean.client.agents.runStream({
|
|
316
|
-
agentId: "<id>",
|
|
317
|
-
messages: [
|
|
318
|
-
{
|
|
319
|
-
role: "USER",
|
|
320
|
-
},
|
|
321
|
-
],
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
console.log(result);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
run();
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
### Standalone function
|
|
331
|
-
|
|
332
|
-
The standalone function version of this method:
|
|
333
|
-
|
|
334
|
-
```typescript
|
|
335
|
-
import { GleanCore } from "@gleanwork/api-client/core.js";
|
|
336
|
-
import { clientAgentsRunStream } from "@gleanwork/api-client/funcs/clientAgentsRunStream.js";
|
|
337
|
-
|
|
338
|
-
// Use `GleanCore` for best tree-shaking performance.
|
|
339
|
-
// You can create one instance of it to use across an application.
|
|
340
|
-
const glean = new GleanCore({
|
|
341
|
-
apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
async function run() {
|
|
345
|
-
const res = await clientAgentsRunStream(glean, {
|
|
346
|
-
agentId: "<id>",
|
|
347
|
-
messages: [
|
|
348
|
-
{
|
|
349
|
-
role: "USER",
|
|
350
|
-
},
|
|
351
|
-
],
|
|
352
|
-
});
|
|
353
|
-
if (res.ok) {
|
|
354
|
-
const { value: result } = res;
|
|
355
|
-
console.log(result);
|
|
356
|
-
} else {
|
|
357
|
-
console.log("clientAgentsRunStream failed:", res.error);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
run();
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
### React hooks and utilities
|
|
365
|
-
|
|
366
|
-
This method can be used in React components through the following hooks and
|
|
367
|
-
associated utilities.
|
|
368
|
-
|
|
369
|
-
> Check out [this guide][hook-guide] for information about each of the utilities
|
|
370
|
-
> below and how to get started using React hooks.
|
|
371
|
-
|
|
372
|
-
[hook-guide]: ../../../REACT_QUERY.md
|
|
373
|
-
|
|
374
|
-
```tsx
|
|
375
|
-
import {
|
|
376
|
-
// Mutation hook for triggering the API call.
|
|
377
|
-
useClientAgentsRunStreamMutation
|
|
378
|
-
} from "@gleanwork/api-client/react-query/clientAgentsRunStream.js";
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
### Parameters
|
|
382
|
-
|
|
383
|
-
| Parameter | Type | Required | Description |
|
|
384
|
-
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
385
|
-
| `request` | [components.AgentRunCreate](../../models/components/agentruncreate.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
386
|
-
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
387
|
-
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
388
|
-
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
389
|
-
|
|
390
|
-
### Response
|
|
391
|
-
|
|
392
|
-
**Promise\<[string](../../models/.md)\>**
|
|
393
|
-
|
|
394
|
-
### Errors
|
|
395
|
-
|
|
396
|
-
| Error Type | Status Code | Content Type |
|
|
397
|
-
| ----------------- | ----------------- | ----------------- |
|
|
398
|
-
| errors.GleanError | 4XX, 5XX | \*/\* |
|
|
399
|
-
|
|
400
|
-
## run
|
|
401
|
-
|
|
402
|
-
Executes an [agent](https://developers.glean.com/agents/agents-api) run and returns the final response.
|
|
403
|
-
|
|
404
|
-
### Example Usage
|
|
405
|
-
|
|
406
|
-
<!-- UsageSnippet language="typescript" operationID="createAndWaitRun" method="post" path="/rest/api/v1/agents/runs/wait" -->
|
|
407
|
-
```typescript
|
|
408
|
-
import { Glean } from "@gleanwork/api-client";
|
|
409
|
-
|
|
410
|
-
const glean = new Glean({
|
|
411
|
-
apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
async function run() {
|
|
415
|
-
const result = await glean.client.agents.run({
|
|
416
|
-
agentId: "<id>",
|
|
417
|
-
messages: [
|
|
418
|
-
{
|
|
419
|
-
role: "USER",
|
|
420
|
-
},
|
|
421
|
-
],
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
console.log(result);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
run();
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
### Standalone function
|
|
431
|
-
|
|
432
|
-
The standalone function version of this method:
|
|
433
|
-
|
|
434
|
-
```typescript
|
|
435
|
-
import { GleanCore } from "@gleanwork/api-client/core.js";
|
|
436
|
-
import { clientAgentsRun } from "@gleanwork/api-client/funcs/clientAgentsRun.js";
|
|
437
|
-
|
|
438
|
-
// Use `GleanCore` for best tree-shaking performance.
|
|
439
|
-
// You can create one instance of it to use across an application.
|
|
440
|
-
const glean = new GleanCore({
|
|
441
|
-
apiToken: process.env["GLEAN_API_TOKEN"] ?? "",
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
async function run() {
|
|
445
|
-
const res = await clientAgentsRun(glean, {
|
|
446
|
-
agentId: "<id>",
|
|
447
|
-
messages: [
|
|
448
|
-
{
|
|
449
|
-
role: "USER",
|
|
450
|
-
},
|
|
451
|
-
],
|
|
452
|
-
});
|
|
453
|
-
if (res.ok) {
|
|
454
|
-
const { value: result } = res;
|
|
455
|
-
console.log(result);
|
|
456
|
-
} else {
|
|
457
|
-
console.log("clientAgentsRun failed:", res.error);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
run();
|
|
462
|
-
```
|
|
463
|
-
|
|
464
|
-
### React hooks and utilities
|
|
465
|
-
|
|
466
|
-
This method can be used in React components through the following hooks and
|
|
467
|
-
associated utilities.
|
|
468
|
-
|
|
469
|
-
> Check out [this guide][hook-guide] for information about each of the utilities
|
|
470
|
-
> below and how to get started using React hooks.
|
|
471
|
-
|
|
472
|
-
[hook-guide]: ../../../REACT_QUERY.md
|
|
473
|
-
|
|
474
|
-
```tsx
|
|
475
|
-
import {
|
|
476
|
-
// Mutation hook for triggering the API call.
|
|
477
|
-
useClientAgentsRunMutation
|
|
478
|
-
} from "@gleanwork/api-client/react-query/clientAgentsRun.js";
|
|
479
|
-
```
|
|
480
|
-
|
|
481
|
-
### Parameters
|
|
482
|
-
|
|
483
|
-
| Parameter | Type | Required | Description |
|
|
484
|
-
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
485
|
-
| `request` | [components.AgentRunCreate](../../models/components/agentruncreate.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
486
|
-
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
487
|
-
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
488
|
-
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
489
|
-
|
|
490
|
-
### Response
|
|
491
|
-
|
|
492
|
-
**Promise\<[components.AgentRunWaitResponse](../../models/components/agentrunwaitresponse.md)\>**
|
|
493
|
-
|
|
494
|
-
### Errors
|
|
495
|
-
|
|
496
|
-
| Error Type | Status Code | Content Type |
|
|
497
|
-
| ----------------- | ----------------- | ----------------- |
|
|
498
|
-
| errors.GleanError | 4XX, 5XX | \*/\* |
|