@cimulate/copilot-sdk 2.0.0 → 2.0.1

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.
@@ -0,0 +1,29 @@
1
+ import { CimulateCopilot } from "@cimulate/copilot-sdk";
2
+
3
+ async function main() {
4
+ const copilot = new CimulateCopilot({
5
+ apiKey: "API_KEY",
6
+ baseUrl: "https://qa.copilot.search.cimulate.ai",
7
+ });
8
+
9
+ copilot.connect();
10
+
11
+ const search = await copilot.search({
12
+ searchParams: { query: "laptop" },
13
+ });
14
+
15
+ const followUp = copilot.on("follow_up", function followup(event) {
16
+ if (event.eventSourceId == search.result.eventId) {
17
+ event.suggestions.forEach((s) => console.log(s.displayText));
18
+ }
19
+ });
20
+
21
+ copilot.on("done", function done(event) {
22
+ if (event.eventSourceId == search.result.eventId) {
23
+ copilot.off("follow_up", followUp);
24
+ copilot.off("done", done);
25
+ }
26
+ });
27
+ }
28
+
29
+ main();
@@ -0,0 +1,26 @@
1
+ import { CimulateCopilot } from "@cimulate/copilot-sdk";
2
+
3
+ async function main() {
4
+ const copilot = new CimulateCopilot({
5
+ apiKey: "API_KEY",
6
+ baseUrl: "https://qa.copilot.search.cimulate.ai",
7
+ });
8
+
9
+ copilot.connect();
10
+
11
+ const search = await copilot.search({
12
+ searchParams: { query: "laptop" },
13
+ });
14
+
15
+ for await (const event of search.events) {
16
+ switch (event.eventName) {
17
+ case "follow_up":
18
+ event.suggestions.forEach((event) => console.log(event.displayText));
19
+ break;
20
+ }
21
+ }
22
+
23
+ console.log("No more events!");
24
+ }
25
+
26
+ main();
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@cimulate/copilot-sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "A lightweight API client SDK for Cimulate Copilot",
5
5
  "files": [
6
6
  "dist/**",
7
+ "examples/**",
7
8
  "README.md"
8
9
  ],
9
10
  "main": "dist/index.cjs.js",