@gleanwork/api-client 0.1.0-beta.3 → 0.1.0-beta.5
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 +34 -1
- package/dist/commonjs/__tests__/chat.test.js +233 -414
- package/dist/commonjs/__tests__/chat.test.js.map +1 -1
- package/dist/commonjs/funcs/clientChatStart.d.ts +1 -1
- package/dist/commonjs/funcs/clientChatStart.d.ts.map +1 -1
- package/dist/commonjs/funcs/clientChatStart.js +3 -3
- package/dist/commonjs/funcs/clientChatStart.js.map +1 -1
- package/dist/commonjs/funcs/clientChatStartStream.d.ts +16 -0
- package/dist/commonjs/funcs/clientChatStartStream.d.ts.map +1 -0
- package/dist/commonjs/funcs/clientChatStartStream.js +121 -0
- package/dist/commonjs/funcs/clientChatStartStream.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/components/workflow.d.ts +0 -2
- package/dist/commonjs/models/components/workflow.d.ts.map +1 -1
- package/dist/commonjs/models/components/workflow.js.map +1 -1
- package/dist/commonjs/models/operations/chatstream.d.ts +38 -0
- package/dist/commonjs/models/operations/chatstream.d.ts.map +1 -0
- package/dist/commonjs/models/operations/chatstream.js +81 -0
- package/dist/commonjs/models/operations/chatstream.js.map +1 -0
- package/dist/commonjs/models/operations/index.d.ts +1 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +1 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/react-query/clientChatStart.d.ts +1 -1
- package/dist/commonjs/react-query/clientChatStart.d.ts.map +1 -1
- package/dist/commonjs/react-query/clientChatStartStream.d.ts +24 -0
- package/dist/commonjs/react-query/clientChatStartStream.d.ts.map +1 -0
- package/dist/commonjs/react-query/clientChatStartStream.js +47 -0
- package/dist/commonjs/react-query/clientChatStartStream.js.map +1 -0
- package/dist/commonjs/react-query/index.d.ts +1 -0
- package/dist/commonjs/react-query/index.d.ts.map +1 -1
- package/dist/commonjs/react-query/index.js +1 -0
- package/dist/commonjs/react-query/index.js.map +1 -1
- package/dist/commonjs/sdk/chat.d.ts +8 -1
- package/dist/commonjs/sdk/chat.d.ts.map +1 -1
- package/dist/commonjs/sdk/chat.js +10 -0
- package/dist/commonjs/sdk/chat.js.map +1 -1
- package/dist/esm/__tests__/chat.test.js +234 -415
- package/dist/esm/__tests__/chat.test.js.map +1 -1
- package/dist/esm/funcs/clientChatStart.d.ts +1 -1
- package/dist/esm/funcs/clientChatStart.d.ts.map +1 -1
- package/dist/esm/funcs/clientChatStart.js +3 -3
- package/dist/esm/funcs/clientChatStart.js.map +1 -1
- package/dist/esm/funcs/clientChatStartStream.d.ts +16 -0
- package/dist/esm/funcs/clientChatStartStream.d.ts.map +1 -0
- package/dist/esm/funcs/clientChatStartStream.js +85 -0
- package/dist/esm/funcs/clientChatStartStream.js.map +1 -0
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/components/workflow.d.ts +0 -2
- package/dist/esm/models/components/workflow.d.ts.map +1 -1
- package/dist/esm/models/components/workflow.js.map +1 -1
- package/dist/esm/models/operations/chatstream.d.ts +38 -0
- package/dist/esm/models/operations/chatstream.d.ts.map +1 -0
- package/dist/esm/models/operations/chatstream.js +43 -0
- package/dist/esm/models/operations/chatstream.js.map +1 -0
- package/dist/esm/models/operations/index.d.ts +1 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +1 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/react-query/clientChatStart.d.ts +1 -1
- package/dist/esm/react-query/clientChatStart.d.ts.map +1 -1
- package/dist/esm/react-query/clientChatStartStream.d.ts +24 -0
- package/dist/esm/react-query/clientChatStartStream.d.ts.map +1 -0
- package/dist/esm/react-query/clientChatStartStream.js +42 -0
- package/dist/esm/react-query/clientChatStartStream.js.map +1 -0
- package/dist/esm/react-query/index.d.ts +1 -0
- package/dist/esm/react-query/index.d.ts.map +1 -1
- package/dist/esm/react-query/index.js +1 -0
- package/dist/esm/react-query/index.js.map +1 -1
- package/dist/esm/sdk/chat.d.ts +8 -1
- package/dist/esm/sdk/chat.d.ts.map +1 -1
- package/dist/esm/sdk/chat.js +10 -0
- package/dist/esm/sdk/chat.js.map +1 -1
- package/docs/sdks/chat/README.md +112 -1
- package/docs/sdks/glean/README.md +10 -0
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/__tests__/chat.test.ts +292 -457
- package/src/funcs/clientChatStart.ts +5 -6
- package/src/funcs/clientChatStartStream.ts +169 -0
- package/src/lib/config.ts +2 -2
- package/src/models/components/workflow.ts +0 -2
- package/src/models/operations/chatstream.ts +86 -0
- package/src/models/operations/index.ts +1 -0
- package/src/react-query/clientChatStart.ts +1 -1
- package/src/react-query/clientChatStartStream.ts +91 -0
- package/src/react-query/index.ts +1 -0
- package/src/sdk/chat.ts +21 -1
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import * as z from "zod";
|
|
6
5
|
import { GleanCore } from "../core.js";
|
|
7
6
|
import { encodeFormQuery, encodeJSON } from "../lib/encodings.js";
|
|
8
7
|
import * as M from "../lib/matchers.js";
|
|
@@ -38,7 +37,7 @@ export function clientChatStart(
|
|
|
38
37
|
options?: RequestOptions,
|
|
39
38
|
): APIPromise<
|
|
40
39
|
Result<
|
|
41
|
-
|
|
40
|
+
components.ChatResponse,
|
|
42
41
|
| GleanError
|
|
43
42
|
| SDKValidationError
|
|
44
43
|
| UnexpectedClientError
|
|
@@ -64,7 +63,7 @@ async function $do(
|
|
|
64
63
|
): Promise<
|
|
65
64
|
[
|
|
66
65
|
Result<
|
|
67
|
-
|
|
66
|
+
components.ChatResponse,
|
|
68
67
|
| GleanError
|
|
69
68
|
| SDKValidationError
|
|
70
69
|
| UnexpectedClientError
|
|
@@ -100,7 +99,7 @@ async function $do(
|
|
|
100
99
|
|
|
101
100
|
const headers = new Headers(compactMap({
|
|
102
101
|
"Content-Type": "application/json",
|
|
103
|
-
Accept: "
|
|
102
|
+
Accept: "application/json",
|
|
104
103
|
}));
|
|
105
104
|
|
|
106
105
|
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
@@ -148,7 +147,7 @@ async function $do(
|
|
|
148
147
|
const response = doResult.value;
|
|
149
148
|
|
|
150
149
|
const [result] = await M.match<
|
|
151
|
-
|
|
150
|
+
components.ChatResponse,
|
|
152
151
|
| GleanError
|
|
153
152
|
| SDKValidationError
|
|
154
153
|
| UnexpectedClientError
|
|
@@ -157,7 +156,7 @@ async function $do(
|
|
|
157
156
|
| RequestTimeoutError
|
|
158
157
|
| ConnectionError
|
|
159
158
|
>(
|
|
160
|
-
M.
|
|
159
|
+
M.json(200, components.ChatResponse$inboundSchema),
|
|
161
160
|
M.fail([400, 401, 408, 429, "4XX"]),
|
|
162
161
|
M.fail("5XX"),
|
|
163
162
|
)(response);
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { GleanCore } from "../core.js";
|
|
7
|
+
import { encodeFormQuery, encodeJSON } from "../lib/encodings.js";
|
|
8
|
+
import * as M from "../lib/matchers.js";
|
|
9
|
+
import { compactMap } from "../lib/primitives.js";
|
|
10
|
+
import { safeParse } from "../lib/schemas.js";
|
|
11
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
12
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
13
|
+
import { pathToFunc } from "../lib/url.js";
|
|
14
|
+
import * as components from "../models/components/index.js";
|
|
15
|
+
import { GleanError } from "../models/errors/gleanerror.js";
|
|
16
|
+
import {
|
|
17
|
+
ConnectionError,
|
|
18
|
+
InvalidRequestError,
|
|
19
|
+
RequestAbortedError,
|
|
20
|
+
RequestTimeoutError,
|
|
21
|
+
UnexpectedClientError,
|
|
22
|
+
} from "../models/errors/httpclienterrors.js";
|
|
23
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
24
|
+
import * as operations from "../models/operations/index.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
|
+
import { Result } from "../types/fp.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Chat
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Have a conversation with Glean AI.
|
|
33
|
+
*/
|
|
34
|
+
export function clientChatStartStream(
|
|
35
|
+
client: GleanCore,
|
|
36
|
+
chatRequest: components.ChatRequest,
|
|
37
|
+
timezoneOffset?: number | undefined,
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): APIPromise<
|
|
40
|
+
Result<
|
|
41
|
+
string,
|
|
42
|
+
| GleanError
|
|
43
|
+
| SDKValidationError
|
|
44
|
+
| UnexpectedClientError
|
|
45
|
+
| InvalidRequestError
|
|
46
|
+
| RequestAbortedError
|
|
47
|
+
| RequestTimeoutError
|
|
48
|
+
| ConnectionError
|
|
49
|
+
>
|
|
50
|
+
> {
|
|
51
|
+
return new APIPromise($do(
|
|
52
|
+
client,
|
|
53
|
+
chatRequest,
|
|
54
|
+
timezoneOffset,
|
|
55
|
+
options,
|
|
56
|
+
));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function $do(
|
|
60
|
+
client: GleanCore,
|
|
61
|
+
chatRequest: components.ChatRequest,
|
|
62
|
+
timezoneOffset?: number | undefined,
|
|
63
|
+
options?: RequestOptions,
|
|
64
|
+
): Promise<
|
|
65
|
+
[
|
|
66
|
+
Result<
|
|
67
|
+
string,
|
|
68
|
+
| GleanError
|
|
69
|
+
| SDKValidationError
|
|
70
|
+
| UnexpectedClientError
|
|
71
|
+
| InvalidRequestError
|
|
72
|
+
| RequestAbortedError
|
|
73
|
+
| RequestTimeoutError
|
|
74
|
+
| ConnectionError
|
|
75
|
+
>,
|
|
76
|
+
APICall,
|
|
77
|
+
]
|
|
78
|
+
> {
|
|
79
|
+
const input: operations.ChatStreamRequest = {
|
|
80
|
+
chatRequest: chatRequest,
|
|
81
|
+
timezoneOffset: timezoneOffset,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const parsed = safeParse(
|
|
85
|
+
input,
|
|
86
|
+
(value) => operations.ChatStreamRequest$outboundSchema.parse(value),
|
|
87
|
+
"Input validation failed",
|
|
88
|
+
);
|
|
89
|
+
if (!parsed.ok) {
|
|
90
|
+
return [parsed, { status: "invalid" }];
|
|
91
|
+
}
|
|
92
|
+
const payload = parsed.value;
|
|
93
|
+
const body = encodeJSON("body", payload.ChatRequest, { explode: true });
|
|
94
|
+
|
|
95
|
+
const path = pathToFunc("/rest/api/v1/chat#stream")();
|
|
96
|
+
|
|
97
|
+
const query = encodeFormQuery({
|
|
98
|
+
"timezoneOffset": payload.timezoneOffset,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const headers = new Headers(compactMap({
|
|
102
|
+
"Content-Type": "application/json",
|
|
103
|
+
Accept: "text/plain",
|
|
104
|
+
}));
|
|
105
|
+
|
|
106
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
107
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
108
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
109
|
+
|
|
110
|
+
const context = {
|
|
111
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
112
|
+
operationID: "chatStream",
|
|
113
|
+
oAuth2Scopes: [],
|
|
114
|
+
|
|
115
|
+
resolvedSecurity: requestSecurity,
|
|
116
|
+
|
|
117
|
+
securitySource: client._options.bearerAuth,
|
|
118
|
+
retryConfig: options?.retries
|
|
119
|
+
|| client._options.retryConfig
|
|
120
|
+
|| { strategy: "none" },
|
|
121
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const requestRes = client._createRequest(context, {
|
|
125
|
+
security: requestSecurity,
|
|
126
|
+
method: "POST",
|
|
127
|
+
baseURL: options?.serverURL,
|
|
128
|
+
path: path,
|
|
129
|
+
headers: headers,
|
|
130
|
+
query: query,
|
|
131
|
+
body: body,
|
|
132
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
133
|
+
}, options);
|
|
134
|
+
if (!requestRes.ok) {
|
|
135
|
+
return [requestRes, { status: "invalid" }];
|
|
136
|
+
}
|
|
137
|
+
const req = requestRes.value;
|
|
138
|
+
|
|
139
|
+
const doResult = await client._do(req, {
|
|
140
|
+
context,
|
|
141
|
+
errorCodes: ["400", "401", "408", "429", "4XX", "5XX"],
|
|
142
|
+
retryConfig: context.retryConfig,
|
|
143
|
+
retryCodes: context.retryCodes,
|
|
144
|
+
});
|
|
145
|
+
if (!doResult.ok) {
|
|
146
|
+
return [doResult, { status: "request-error", request: req }];
|
|
147
|
+
}
|
|
148
|
+
const response = doResult.value;
|
|
149
|
+
|
|
150
|
+
const [result] = await M.match<
|
|
151
|
+
string,
|
|
152
|
+
| GleanError
|
|
153
|
+
| SDKValidationError
|
|
154
|
+
| UnexpectedClientError
|
|
155
|
+
| InvalidRequestError
|
|
156
|
+
| RequestAbortedError
|
|
157
|
+
| RequestTimeoutError
|
|
158
|
+
| ConnectionError
|
|
159
|
+
>(
|
|
160
|
+
M.text(200, z.string()),
|
|
161
|
+
M.fail([400, 401, 408, 429, "4XX"]),
|
|
162
|
+
M.fail("5XX"),
|
|
163
|
+
)(response);
|
|
164
|
+
if (!result.ok) {
|
|
165
|
+
return [result, { status: "complete", request: req, response }];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return [result, { status: "complete", request: req, response }];
|
|
169
|
+
}
|
package/src/lib/config.ts
CHANGED
|
@@ -64,8 +64,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
64
64
|
export const SDK_METADATA = {
|
|
65
65
|
language: "typescript",
|
|
66
66
|
openapiDocVersion: "0.9.0",
|
|
67
|
-
sdkVersion: "0.1.0-beta.
|
|
67
|
+
sdkVersion: "0.1.0-beta.5",
|
|
68
68
|
genVersion: "2.596.2",
|
|
69
69
|
userAgent:
|
|
70
|
-
"speakeasy-sdk/typescript 0.1.0-beta.
|
|
70
|
+
"speakeasy-sdk/typescript 0.1.0-beta.5 2.596.2 0.9.0 @gleanwork/api-client",
|
|
71
71
|
} as const;
|
|
@@ -33,8 +33,6 @@ export type Workflow = {
|
|
|
33
33
|
permissions?: ObjectPermissions | undefined;
|
|
34
34
|
/**
|
|
35
35
|
* The name of the workflow.
|
|
36
|
-
*
|
|
37
|
-
* @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
|
|
38
36
|
*/
|
|
39
37
|
name?: string | undefined;
|
|
40
38
|
/**
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import * as components from "../components/index.js";
|
|
10
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
|
|
12
|
+
export type ChatStreamRequest = {
|
|
13
|
+
/**
|
|
14
|
+
* The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
|
|
15
|
+
*/
|
|
16
|
+
timezoneOffset?: number | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Includes chat history for Glean AI to respond to.
|
|
19
|
+
*/
|
|
20
|
+
chatRequest: components.ChatRequest;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** @internal */
|
|
24
|
+
export const ChatStreamRequest$inboundSchema: z.ZodType<
|
|
25
|
+
ChatStreamRequest,
|
|
26
|
+
z.ZodTypeDef,
|
|
27
|
+
unknown
|
|
28
|
+
> = z.object({
|
|
29
|
+
timezoneOffset: z.number().int().optional(),
|
|
30
|
+
ChatRequest: components.ChatRequest$inboundSchema,
|
|
31
|
+
}).transform((v) => {
|
|
32
|
+
return remap$(v, {
|
|
33
|
+
"ChatRequest": "chatRequest",
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/** @internal */
|
|
38
|
+
export type ChatStreamRequest$Outbound = {
|
|
39
|
+
timezoneOffset?: number | undefined;
|
|
40
|
+
ChatRequest: components.ChatRequest$Outbound;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** @internal */
|
|
44
|
+
export const ChatStreamRequest$outboundSchema: z.ZodType<
|
|
45
|
+
ChatStreamRequest$Outbound,
|
|
46
|
+
z.ZodTypeDef,
|
|
47
|
+
ChatStreamRequest
|
|
48
|
+
> = z.object({
|
|
49
|
+
timezoneOffset: z.number().int().optional(),
|
|
50
|
+
chatRequest: components.ChatRequest$outboundSchema,
|
|
51
|
+
}).transform((v) => {
|
|
52
|
+
return remap$(v, {
|
|
53
|
+
chatRequest: "ChatRequest",
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @internal
|
|
59
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
60
|
+
*/
|
|
61
|
+
export namespace ChatStreamRequest$ {
|
|
62
|
+
/** @deprecated use `ChatStreamRequest$inboundSchema` instead. */
|
|
63
|
+
export const inboundSchema = ChatStreamRequest$inboundSchema;
|
|
64
|
+
/** @deprecated use `ChatStreamRequest$outboundSchema` instead. */
|
|
65
|
+
export const outboundSchema = ChatStreamRequest$outboundSchema;
|
|
66
|
+
/** @deprecated use `ChatStreamRequest$Outbound` instead. */
|
|
67
|
+
export type Outbound = ChatStreamRequest$Outbound;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function chatStreamRequestToJSON(
|
|
71
|
+
chatStreamRequest: ChatStreamRequest,
|
|
72
|
+
): string {
|
|
73
|
+
return JSON.stringify(
|
|
74
|
+
ChatStreamRequest$outboundSchema.parse(chatStreamRequest),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function chatStreamRequestFromJSON(
|
|
79
|
+
jsonString: string,
|
|
80
|
+
): SafeParseResult<ChatStreamRequest, SDKValidationError> {
|
|
81
|
+
return safeParse(
|
|
82
|
+
jsonString,
|
|
83
|
+
(x) => ChatStreamRequest$inboundSchema.parse(JSON.parse(x)),
|
|
84
|
+
`Failed to parse 'ChatStreamRequest' from JSON`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
MutationKey,
|
|
7
|
+
useMutation,
|
|
8
|
+
UseMutationResult,
|
|
9
|
+
} from "@tanstack/react-query";
|
|
10
|
+
import { GleanCore } from "../core.js";
|
|
11
|
+
import { clientChatStartStream } from "../funcs/clientChatStartStream.js";
|
|
12
|
+
import { combineSignals } from "../lib/primitives.js";
|
|
13
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
14
|
+
import * as components from "../models/components/index.js";
|
|
15
|
+
import { unwrapAsync } from "../types/fp.js";
|
|
16
|
+
import { useGleanContext } from "./_context.js";
|
|
17
|
+
import { MutationHookOptions } from "./_types.js";
|
|
18
|
+
|
|
19
|
+
export type ClientChatStartStreamMutationVariables = {
|
|
20
|
+
chatRequest: components.ChatRequest;
|
|
21
|
+
timezoneOffset?: number | undefined;
|
|
22
|
+
options?: RequestOptions;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type ClientChatStartStreamMutationData = string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Chat
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Have a conversation with Glean AI.
|
|
32
|
+
*/
|
|
33
|
+
export function useClientChatStartStreamMutation(
|
|
34
|
+
options?: MutationHookOptions<
|
|
35
|
+
ClientChatStartStreamMutationData,
|
|
36
|
+
Error,
|
|
37
|
+
ClientChatStartStreamMutationVariables
|
|
38
|
+
>,
|
|
39
|
+
): UseMutationResult<
|
|
40
|
+
ClientChatStartStreamMutationData,
|
|
41
|
+
Error,
|
|
42
|
+
ClientChatStartStreamMutationVariables
|
|
43
|
+
> {
|
|
44
|
+
const client = useGleanContext();
|
|
45
|
+
return useMutation({
|
|
46
|
+
...buildClientChatStartStreamMutation(client, options),
|
|
47
|
+
...options,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function mutationKeyClientChatStartStream(): MutationKey {
|
|
52
|
+
return ["@gleanwork/api-client", "chat", "startStream"];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function buildClientChatStartStreamMutation(
|
|
56
|
+
client$: GleanCore,
|
|
57
|
+
hookOptions?: RequestOptions,
|
|
58
|
+
): {
|
|
59
|
+
mutationKey: MutationKey;
|
|
60
|
+
mutationFn: (
|
|
61
|
+
variables: ClientChatStartStreamMutationVariables,
|
|
62
|
+
) => Promise<ClientChatStartStreamMutationData>;
|
|
63
|
+
} {
|
|
64
|
+
return {
|
|
65
|
+
mutationKey: mutationKeyClientChatStartStream(),
|
|
66
|
+
mutationFn: function clientChatStartStreamMutationFn({
|
|
67
|
+
chatRequest,
|
|
68
|
+
timezoneOffset,
|
|
69
|
+
options,
|
|
70
|
+
}): Promise<ClientChatStartStreamMutationData> {
|
|
71
|
+
const mergedOptions = {
|
|
72
|
+
...hookOptions,
|
|
73
|
+
...options,
|
|
74
|
+
fetchOptions: {
|
|
75
|
+
...hookOptions?.fetchOptions,
|
|
76
|
+
...options?.fetchOptions,
|
|
77
|
+
signal: combineSignals(
|
|
78
|
+
hookOptions?.fetchOptions?.signal,
|
|
79
|
+
options?.fetchOptions?.signal,
|
|
80
|
+
),
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
return unwrapAsync(clientChatStartStream(
|
|
84
|
+
client$,
|
|
85
|
+
chatRequest,
|
|
86
|
+
timezoneOffset,
|
|
87
|
+
mergedOptions,
|
|
88
|
+
));
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
package/src/react-query/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * from "./clientChatGetApplication.js";
|
|
|
27
27
|
export * from "./clientChatGetFiles.js";
|
|
28
28
|
export * from "./clientChatList.js";
|
|
29
29
|
export * from "./clientChatStart.js";
|
|
30
|
+
export * from "./clientChatStartStream.js";
|
|
30
31
|
export * from "./clientChatUploadFiles.js";
|
|
31
32
|
export * from "./clientCollectionsAddItems.js";
|
|
32
33
|
export * from "./clientCollectionsCreate.js";
|
package/src/sdk/chat.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { clientChatGetApplication } from "../funcs/clientChatGetApplication.js";
|
|
|
10
10
|
import { clientChatGetFiles } from "../funcs/clientChatGetFiles.js";
|
|
11
11
|
import { clientChatList } from "../funcs/clientChatList.js";
|
|
12
12
|
import { clientChatStart } from "../funcs/clientChatStart.js";
|
|
13
|
+
import { clientChatStartStream } from "../funcs/clientChatStartStream.js";
|
|
13
14
|
import { clientChatUploadFiles } from "../funcs/clientChatUploadFiles.js";
|
|
14
15
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
15
16
|
import * as components from "../models/components/index.js";
|
|
@@ -26,7 +27,7 @@ export class Chat extends ClientSDK {
|
|
|
26
27
|
chatRequest: components.ChatRequest,
|
|
27
28
|
timezoneOffset?: number | undefined,
|
|
28
29
|
options?: RequestOptions,
|
|
29
|
-
): Promise<
|
|
30
|
+
): Promise<components.ChatResponse> {
|
|
30
31
|
return unwrapAsync(clientChatStart(
|
|
31
32
|
this,
|
|
32
33
|
chatRequest,
|
|
@@ -182,4 +183,23 @@ export class Chat extends ClientSDK {
|
|
|
182
183
|
options,
|
|
183
184
|
));
|
|
184
185
|
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Chat
|
|
189
|
+
*
|
|
190
|
+
* @remarks
|
|
191
|
+
* Have a conversation with Glean AI.
|
|
192
|
+
*/
|
|
193
|
+
async startStream(
|
|
194
|
+
chatRequest: components.ChatRequest,
|
|
195
|
+
timezoneOffset?: number | undefined,
|
|
196
|
+
options?: RequestOptions,
|
|
197
|
+
): Promise<string> {
|
|
198
|
+
return unwrapAsync(clientChatStartStream(
|
|
199
|
+
this,
|
|
200
|
+
chatRequest,
|
|
201
|
+
timezoneOffset,
|
|
202
|
+
options,
|
|
203
|
+
));
|
|
204
|
+
}
|
|
185
205
|
}
|