@cimulate/copilot-sdk 3.5.0 → 3.7.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/{bundle.cimulate.copilot-sdk.2d2eeac4.umd.js → bundle.cimulate.copilot-sdk.19bd46a0.umd.js} +2 -2
- package/dist/{bundle.cimulate.copilot-sdk.2d2eeac4.umd.js.map → bundle.cimulate.copilot-sdk.19bd46a0.umd.js.map} +1 -1
- package/dist/{bundle.cimulate.copilot-sdk.2eb603f8.cjs.js → bundle.cimulate.copilot-sdk.2fdeb472.cjs.js} +2 -2
- package/dist/{bundle.cimulate.copilot-sdk.2eb603f8.cjs.js.map → bundle.cimulate.copilot-sdk.2fdeb472.cjs.js.map} +1 -1
- package/dist/{bundle.cimulate.copilot-sdk.3d873978.esm.js → bundle.cimulate.copilot-sdk.77727d1e.esm.js} +2 -2
- package/dist/{bundle.cimulate.copilot-sdk.3d873978.esm.js.map → bundle.cimulate.copilot-sdk.77727d1e.esm.js.map} +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/copilot.d.ts +5 -1
- package/dist/types/model/ConversationReset.d.ts +5 -0
- package/dist/types/model/ConversationResetAck.d.ts +10 -0
- package/dist/types/model/CopilotApiAck.d.ts +3 -1
- package/dist/types/model/FollowUp.d.ts +2 -1
- package/dist/types/model/ProductView.d.ts +6 -0
- package/dist/types/model/ProductViewAck.d.ts +10 -0
- package/dist/types/model/ProductViewSuggestion.d.ts +7 -0
- package/dist/types/model/SessionData.d.ts +2 -0
- package/dist/types/model/index.d.ts +5 -0
- package/examples/conversationReset.ts +52 -0
- package/package.json +1 -1
- package/src/copilot.ts +38 -0
- package/src/model/ConversationReset.ts +6 -0
- package/src/model/ConversationResetAck.ts +10 -0
- package/src/model/CopilotApiAck.ts +4 -0
- package/src/model/FollowUp.ts +2 -1
- package/src/model/ProductView.ts +7 -0
- package/src/model/ProductViewAck.ts +10 -0
- package/src/model/ProductViewSuggestion.ts +7 -0
- package/src/model/SessionData.ts +2 -0
- package/src/model/index.ts +5 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConversationReset } from './ConversationReset';
|
|
2
|
+
interface ConversationResetAck {
|
|
3
|
+
name: 'conversation_reset';
|
|
4
|
+
request: ConversationReset;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
id: string;
|
|
7
|
+
createdAt: string;
|
|
8
|
+
status: number;
|
|
9
|
+
}
|
|
10
|
+
export { ConversationResetAck };
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
For any new event, manually create an entry here.
|
|
4
4
|
*/
|
|
5
5
|
import { CancelAck } from "./CancelAck";
|
|
6
|
+
import { ConversationResetAck } from "./ConversationResetAck";
|
|
6
7
|
import { CopilotError } from "./CopilotError";
|
|
7
8
|
import { CopilotSearchAck } from "./CopilotSearchAck";
|
|
8
9
|
import { FacetedNavigationAck } from "./FacetedNavigationAck";
|
|
9
|
-
|
|
10
|
+
import { ProductViewAck } from "./ProductViewAck";
|
|
11
|
+
export type CopilotAPIAck = CancelAck | CopilotSearchAck | ConversationResetAck | FacetedNavigationAck | ProductViewAck | CopilotError;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { CopilotSearchSuggestion } from './CopilotSearchSuggestion';
|
|
2
2
|
import { FacetedNavigationSuggestion } from './FacetedNavigationSuggestion';
|
|
3
|
+
import { ProductViewSuggestion } from './ProductViewSuggestion';
|
|
3
4
|
interface FollowUp {
|
|
4
5
|
sessionId: string;
|
|
5
6
|
id: string;
|
|
6
7
|
createdAt: string;
|
|
7
8
|
eventSourceId: string;
|
|
8
9
|
message: string;
|
|
9
|
-
suggestions: (CopilotSearchSuggestion | FacetedNavigationSuggestion)[];
|
|
10
|
+
suggestions: (CopilotSearchSuggestion | FacetedNavigationSuggestion | ProductViewSuggestion)[];
|
|
10
11
|
name: 'follow_up';
|
|
11
12
|
}
|
|
12
13
|
export { FollowUp };
|
|
@@ -6,6 +6,8 @@ export * from './CommonRequiredFields';
|
|
|
6
6
|
export * from './ConnectAck';
|
|
7
7
|
export * from './ConnectAckMetadata';
|
|
8
8
|
export * from './ConnectError';
|
|
9
|
+
export * from './ConversationReset';
|
|
10
|
+
export * from './ConversationResetAck';
|
|
9
11
|
export * from './CopilotApiAck';
|
|
10
12
|
export * from './CopilotAPIEvent';
|
|
11
13
|
export * from './CopilotError';
|
|
@@ -25,6 +27,9 @@ export * from './FollowUp';
|
|
|
25
27
|
export * from './Inquiry';
|
|
26
28
|
export * from './OperationAck';
|
|
27
29
|
export * from './PartialInquiry';
|
|
30
|
+
export * from './ProductView';
|
|
31
|
+
export * from './ProductViewAck';
|
|
32
|
+
export * from './ProductViewSuggestion';
|
|
28
33
|
export * from './Progress';
|
|
29
34
|
export * from './ProgressToolKwargs';
|
|
30
35
|
export * from './RefinedSearch';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CimulateCopilot } from "@cimulate/copilot-sdk";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
async function main() {
|
|
5
|
+
const copilot = new CimulateCopilot({
|
|
6
|
+
apiKey: "API_KEY",
|
|
7
|
+
// Alternatively, a JWT token of the form `Bearer {token}` can be used for authentication.
|
|
8
|
+
// apiToken: "token123",
|
|
9
|
+
baseUrl: "https://qa.copilot.search.cimulate.ai",
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// Register handlers.
|
|
13
|
+
const connectAckHandler = copilot.on("connect_ack", function connectAck(event) {
|
|
14
|
+
console.log("Connect Ack: ", event);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const errorHandler = copilot.on("error", function errorEvent(event) {
|
|
18
|
+
console.error("Error received: ", event);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const connectErrorHandler = copilot.on("connect_error", function errorEvent(error) {
|
|
22
|
+
console.error("Error message received: ", error.message);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
console.log("Establish a new connection");
|
|
26
|
+
copilot.connect();
|
|
27
|
+
|
|
28
|
+
console.log("Reset conversaton with empty payload");
|
|
29
|
+
const response = await copilot.conversationReset({});
|
|
30
|
+
console.log("Conversation reset response: ", response);
|
|
31
|
+
|
|
32
|
+
console.log("Reset conversaton with empty payload");
|
|
33
|
+
const responseWithUserReason = await copilot.conversationReset({
|
|
34
|
+
reason: "Clear the copilot context."
|
|
35
|
+
});
|
|
36
|
+
console.log("Conversation reset response: ", responseWithUserReason);
|
|
37
|
+
|
|
38
|
+
const sessionData = await copilot.requestSessionInformation();
|
|
39
|
+
console.log("Conversations related to this session: ", sessionData.data.conversationIds);
|
|
40
|
+
console.log("Current active conversation in this session: ", sessionData.data.activeConversationId);
|
|
41
|
+
|
|
42
|
+
console.log("Disconnect");
|
|
43
|
+
copilot.disconnect();
|
|
44
|
+
|
|
45
|
+
console.log("De-register handler");
|
|
46
|
+
copilot.off("connect_ack", connectAckHandler);
|
|
47
|
+
copilot.off("error", errorHandler);
|
|
48
|
+
copilot.off("connect_error", connectErrorHandler);
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
main();
|
package/package.json
CHANGED
package/src/copilot.ts
CHANGED
|
@@ -13,8 +13,12 @@ import type {
|
|
|
13
13
|
CopilotSearchAck,
|
|
14
14
|
FacetedNavigation,
|
|
15
15
|
FacetedNavigationAck,
|
|
16
|
+
ProductView,
|
|
17
|
+
ProductViewAck,
|
|
16
18
|
ReturnedFields,
|
|
17
19
|
SessionInformation,
|
|
20
|
+
ConversationReset,
|
|
21
|
+
ConversationResetAck,
|
|
18
22
|
} from "./model";
|
|
19
23
|
import CimulateCopilotException from "./exceptions";
|
|
20
24
|
import { SnakeCaseParser } from "./parser";
|
|
@@ -251,6 +255,40 @@ export default class CimulateCopilot<
|
|
|
251
255
|
);
|
|
252
256
|
}
|
|
253
257
|
|
|
258
|
+
async conversationReset(args: ConversationReset): Promise<CopilotResult<T, ConversationResetAck>>;
|
|
259
|
+
async conversationReset(
|
|
260
|
+
args: ConversationReset,
|
|
261
|
+
callback?: (event: ConversationResetAck) => void
|
|
262
|
+
): Promise<void>;
|
|
263
|
+
conversationReset(
|
|
264
|
+
args: ConversationReset,
|
|
265
|
+
callback?: (event: ConversationResetAck) => void
|
|
266
|
+
): Promise<CopilotResult<T, ConversationResetAck> | void> {
|
|
267
|
+
return this.asyncResponse<ConversationReset, ConversationResetAck>(
|
|
268
|
+
"conversation_reset",
|
|
269
|
+
args,
|
|
270
|
+
callback
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async productView(
|
|
275
|
+
args: ProductView
|
|
276
|
+
): Promise<CopilotResult<T, ProductViewAck>>;
|
|
277
|
+
async productView(
|
|
278
|
+
args: ProductView,
|
|
279
|
+
callback?: (event: ProductViewAck) => void
|
|
280
|
+
): Promise<void>;
|
|
281
|
+
async productView(
|
|
282
|
+
args: ProductView,
|
|
283
|
+
callback?: (event: ProductViewAck) => void
|
|
284
|
+
): Promise<CopilotResult<T, ProductViewAck> | void> {
|
|
285
|
+
return this.asyncResponse<ProductView, ProductViewAck>(
|
|
286
|
+
"product_view",
|
|
287
|
+
args,
|
|
288
|
+
callback
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
254
292
|
async requestSessionInformation(): Promise<
|
|
255
293
|
CopilotResult<T, SessionInformation>
|
|
256
294
|
>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConversationReset } from './ConversationReset';
|
|
2
|
+
interface ConversationResetAck {
|
|
3
|
+
name: 'conversation_reset';
|
|
4
|
+
request: ConversationReset;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
id: string;
|
|
7
|
+
createdAt: string;
|
|
8
|
+
status: number;
|
|
9
|
+
}
|
|
10
|
+
export { ConversationResetAck };
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
For any new event, manually create an entry here.
|
|
4
4
|
*/
|
|
5
5
|
import { CancelAck } from "./CancelAck";
|
|
6
|
+
import { ConversationResetAck } from "./ConversationResetAck";
|
|
6
7
|
import { CopilotError } from "./CopilotError";
|
|
7
8
|
import { CopilotSearchAck } from "./CopilotSearchAck";
|
|
8
9
|
import { FacetedNavigationAck } from "./FacetedNavigationAck";
|
|
10
|
+
import { ProductViewAck } from "./ProductViewAck"
|
|
9
11
|
|
|
10
12
|
export type CopilotAPIAck =
|
|
11
13
|
| CancelAck
|
|
12
14
|
| CopilotSearchAck
|
|
15
|
+
| ConversationResetAck
|
|
13
16
|
| FacetedNavigationAck
|
|
17
|
+
| ProductViewAck
|
|
14
18
|
| CopilotError;
|
package/src/model/FollowUp.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { CopilotSearchSuggestion } from './CopilotSearchSuggestion';
|
|
2
2
|
import { FacetedNavigationSuggestion } from './FacetedNavigationSuggestion';
|
|
3
|
+
import { ProductViewSuggestion } from './ProductViewSuggestion';
|
|
3
4
|
interface FollowUp {
|
|
4
5
|
sessionId: string;
|
|
5
6
|
id: string;
|
|
6
7
|
createdAt: string;
|
|
7
8
|
eventSourceId: string;
|
|
8
9
|
message: string;
|
|
9
|
-
suggestions: (CopilotSearchSuggestion | FacetedNavigationSuggestion)[];
|
|
10
|
+
suggestions: (CopilotSearchSuggestion | FacetedNavigationSuggestion | ProductViewSuggestion)[];
|
|
10
11
|
name: 'follow_up';
|
|
11
12
|
}
|
|
12
13
|
export { FollowUp };
|
package/src/model/SessionData.ts
CHANGED
package/src/model/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ export * from './CommonRequiredFields';
|
|
|
6
6
|
export * from './ConnectAck';
|
|
7
7
|
export * from './ConnectAckMetadata';
|
|
8
8
|
export * from './ConnectError';
|
|
9
|
+
export * from './ConversationReset';
|
|
10
|
+
export * from './ConversationResetAck';
|
|
9
11
|
export * from './CopilotApiAck';
|
|
10
12
|
export * from './CopilotAPIEvent';
|
|
11
13
|
export * from './CopilotError';
|
|
@@ -25,6 +27,9 @@ export * from './FollowUp';
|
|
|
25
27
|
export * from './Inquiry';
|
|
26
28
|
export * from './OperationAck';
|
|
27
29
|
export * from './PartialInquiry';
|
|
30
|
+
export * from './ProductView';
|
|
31
|
+
export * from './ProductViewAck';
|
|
32
|
+
export * from './ProductViewSuggestion';
|
|
28
33
|
export * from './Progress';
|
|
29
34
|
export * from './ProgressToolKwargs';
|
|
30
35
|
export * from './RefinedSearch';
|