@cimulate/copilot-sdk 3.4.0 → 3.6.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.3d873978.esm.js → bundle.cimulate.copilot-sdk.1fbe1d17.esm.js} +2 -2
- package/dist/{bundle.cimulate.copilot-sdk.3d873978.esm.js.map → bundle.cimulate.copilot-sdk.1fbe1d17.esm.js.map} +1 -1
- package/dist/{bundle.cimulate.copilot-sdk.2d2eeac4.umd.js → bundle.cimulate.copilot-sdk.528903a1.umd.js} +2 -2
- package/dist/{bundle.cimulate.copilot-sdk.2d2eeac4.umd.js.map → bundle.cimulate.copilot-sdk.528903a1.umd.js.map} +1 -1
- package/dist/{bundle.cimulate.copilot-sdk.2eb603f8.cjs.js → bundle.cimulate.copilot-sdk.a9e69ca5.cjs.js} +2 -2
- package/dist/{bundle.cimulate.copilot-sdk.2eb603f8.cjs.js.map → bundle.cimulate.copilot-sdk.a9e69ca5.cjs.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 +3 -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 +2 -1
- package/dist/types/model/SearchParams.d.ts +2 -0
- package/dist/types/model/SessionData.d.ts +2 -0
- package/dist/types/model/index.d.ts +3 -1
- package/examples/callbacks.ts +1 -1
- package/examples/conversationReset.ts +52 -0
- package/package.json +1 -1
- package/src/copilot.ts +18 -0
- package/src/model/ConversationReset.ts +6 -0
- package/src/model/ConversationResetAck.ts +10 -0
- package/src/model/CopilotApiAck.ts +2 -0
- package/src/model/SearchParams.ts +2 -0
- package/src/model/SessionData.ts +2 -0
- package/src/model/index.ts +3 -1
|
@@ -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 };
|
|
@@ -6,4 +6,5 @@ import { CancelAck } from "./CancelAck";
|
|
|
6
6
|
import { CopilotError } from "./CopilotError";
|
|
7
7
|
import { CopilotSearchAck } from "./CopilotSearchAck";
|
|
8
8
|
import { FacetedNavigationAck } from "./FacetedNavigationAck";
|
|
9
|
-
|
|
9
|
+
import { ConversationResetAck } from "./ConversationResetAck";
|
|
10
|
+
export type CopilotAPIAck = CancelAck | CopilotSearchAck | ConversationResetAck | FacetedNavigationAck | CopilotError;
|
|
@@ -6,8 +6,10 @@ export * from './CommonRequiredFields';
|
|
|
6
6
|
export * from './ConnectAck';
|
|
7
7
|
export * from './ConnectAckMetadata';
|
|
8
8
|
export * from './ConnectError';
|
|
9
|
-
export * from './
|
|
9
|
+
export * from './ConversationReset';
|
|
10
|
+
export * from './ConversationResetAck';
|
|
10
11
|
export * from './CopilotApiAck';
|
|
12
|
+
export * from './CopilotAPIEvent';
|
|
11
13
|
export * from './CopilotError';
|
|
12
14
|
export * from './CopilotEvent';
|
|
13
15
|
export * from './CopilotSearch';
|
package/examples/callbacks.ts
CHANGED
|
@@ -16,7 +16,7 @@ async function main() {
|
|
|
16
16
|
|
|
17
17
|
try {
|
|
18
18
|
const search = await copilot.search({
|
|
19
|
-
searchParams: { query: "
|
|
19
|
+
searchParams: { query: "starlink Mini", catalogSegment: "WestMarine", pricebooks: ["wm-regular", "wm-sale-retail"] },
|
|
20
20
|
});
|
|
21
21
|
console.log("Search request ack:", search.result);
|
|
22
22
|
|
|
@@ -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.conversationResetRequest({});
|
|
30
|
+
console.log("Conversation reset response: ", response);
|
|
31
|
+
|
|
32
|
+
console.log("Reset conversaton with empty payload");
|
|
33
|
+
const responseWithUserReason = await copilot.conversationResetRequest({
|
|
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
|
@@ -15,6 +15,8 @@ import type {
|
|
|
15
15
|
FacetedNavigationAck,
|
|
16
16
|
ReturnedFields,
|
|
17
17
|
SessionInformation,
|
|
18
|
+
ConversationReset,
|
|
19
|
+
ConversationResetAck,
|
|
18
20
|
} from "./model";
|
|
19
21
|
import CimulateCopilotException from "./exceptions";
|
|
20
22
|
import { SnakeCaseParser } from "./parser";
|
|
@@ -251,6 +253,22 @@ export default class CimulateCopilot<
|
|
|
251
253
|
);
|
|
252
254
|
}
|
|
253
255
|
|
|
256
|
+
async conversationResetRequest(args: ConversationReset): Promise<CopilotResult<T, ConversationResetAck>>;
|
|
257
|
+
async conversationResetRequest(
|
|
258
|
+
args: ConversationReset,
|
|
259
|
+
callback?: (event: ConversationResetAck) => void
|
|
260
|
+
): Promise<void>;
|
|
261
|
+
conversationResetRequest(
|
|
262
|
+
args: ConversationReset,
|
|
263
|
+
callback?: (event: ConversationResetAck) => void
|
|
264
|
+
): Promise<CopilotResult<T, ConversationResetAck> | void> {
|
|
265
|
+
return this.asyncResponse<ConversationReset, ConversationResetAck>(
|
|
266
|
+
"conversation_reset",
|
|
267
|
+
args,
|
|
268
|
+
callback
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
254
272
|
async requestSessionInformation(): Promise<
|
|
255
273
|
CopilotResult<T, SessionInformation>
|
|
256
274
|
>;
|
|
@@ -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 };
|
|
@@ -6,9 +6,11 @@ import { CancelAck } from "./CancelAck";
|
|
|
6
6
|
import { CopilotError } from "./CopilotError";
|
|
7
7
|
import { CopilotSearchAck } from "./CopilotSearchAck";
|
|
8
8
|
import { FacetedNavigationAck } from "./FacetedNavigationAck";
|
|
9
|
+
import { ConversationResetAck } from "./ConversationResetAck";
|
|
9
10
|
|
|
10
11
|
export type CopilotAPIAck =
|
|
11
12
|
| CancelAck
|
|
12
13
|
| CopilotSearchAck
|
|
14
|
+
| ConversationResetAck
|
|
13
15
|
| FacetedNavigationAck
|
|
14
16
|
| CopilotError;
|
package/src/model/SessionData.ts
CHANGED
package/src/model/index.ts
CHANGED
|
@@ -6,8 +6,10 @@ export * from './CommonRequiredFields';
|
|
|
6
6
|
export * from './ConnectAck';
|
|
7
7
|
export * from './ConnectAckMetadata';
|
|
8
8
|
export * from './ConnectError';
|
|
9
|
-
export * from './
|
|
9
|
+
export * from './ConversationReset';
|
|
10
|
+
export * from './ConversationResetAck';
|
|
10
11
|
export * from './CopilotApiAck';
|
|
12
|
+
export * from './CopilotAPIEvent';
|
|
11
13
|
export * from './CopilotError';
|
|
12
14
|
export * from './CopilotEvent';
|
|
13
15
|
export * from './CopilotSearch';
|