@guava-ai/guava-sdk 0.23.0 → 0.24.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.
Files changed (57) hide show
  1. package/dist/examples/help-desk.js +22 -8
  2. package/dist/examples/help-desk.js.map +1 -1
  3. package/dist/examples/property-insurance.js +14 -3
  4. package/dist/examples/property-insurance.js.map +1 -1
  5. package/dist/examples/restaurant-waitlist.js +9 -1
  6. package/dist/examples/restaurant-waitlist.js.map +1 -1
  7. package/dist/examples/scheduling-outbound.js +2 -4
  8. package/dist/examples/scheduling-outbound.js.map +1 -1
  9. package/dist/src/action-item.d.ts +4 -4
  10. package/dist/src/action-item.js +1 -1
  11. package/dist/src/action-item.js.map +1 -1
  12. package/dist/src/agent.d.ts +18 -6
  13. package/dist/src/agent.js +269 -121
  14. package/dist/src/agent.js.map +1 -1
  15. package/dist/src/call.d.ts +9 -1
  16. package/dist/src/call.js +24 -1
  17. package/dist/src/call.js.map +1 -1
  18. package/dist/src/commands.d.ts +37 -9
  19. package/dist/src/commands.js +13 -3
  20. package/dist/src/commands.js.map +1 -1
  21. package/dist/src/events.d.ts +28 -1
  22. package/dist/src/events.js +10 -2
  23. package/dist/src/events.js.map +1 -1
  24. package/dist/src/health.d.ts +35 -0
  25. package/dist/src/health.js +99 -0
  26. package/dist/src/health.js.map +1 -0
  27. package/dist/src/helpers/index.d.ts +1 -0
  28. package/dist/src/helpers/index.js +9 -0
  29. package/dist/src/helpers/index.js.map +1 -0
  30. package/dist/src/helpers/llm.d.ts +33 -1
  31. package/dist/src/helpers/llm.js +220 -0
  32. package/dist/src/helpers/llm.js.map +1 -1
  33. package/dist/src/helpers/server-rag.d.ts +25 -0
  34. package/dist/src/helpers/server-rag.js +119 -0
  35. package/dist/src/helpers/server-rag.js.map +1 -0
  36. package/dist/src/socket/protocol.d.ts +4 -4
  37. package/dist/src/testing/mocks.d.ts +6 -0
  38. package/dist/src/testing/mocks.js +12 -0
  39. package/dist/src/testing/mocks.js.map +1 -1
  40. package/dist/src/version.d.ts +1 -1
  41. package/dist/src/version.js +1 -1
  42. package/examples/help-desk.ts +21 -12
  43. package/examples/property-insurance.ts +15 -3
  44. package/examples/restaurant-waitlist.ts +10 -1
  45. package/examples/scheduling-outbound.ts +2 -4
  46. package/package.json +5 -1
  47. package/src/action-item.ts +1 -1
  48. package/src/agent.ts +261 -127
  49. package/src/call.ts +37 -1
  50. package/src/commands.ts +16 -2
  51. package/src/events.ts +11 -1
  52. package/src/health.ts +120 -0
  53. package/src/helpers/index.ts +2 -0
  54. package/src/helpers/llm.ts +178 -1
  55. package/src/helpers/server-rag.ts +132 -0
  56. package/src/testing/mocks.ts +17 -0
  57. package/src/version.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.23.0";
4
+ exports.SDK_VERSION = "0.24.0";
5
5
  //# sourceMappingURL=version.js.map
@@ -1,7 +1,7 @@
1
1
  import * as guava from "@guava-ai/guava-sdk";
2
- import { DocumentQA, IntentRecognizer } from "@guava-ai/guava-sdk/helpers/openai";
2
+ import { DocumentQA } from "@guava-ai/guava-sdk/helpers";
3
+ import { IntentRecognizer } from "@guava-ai/guava-sdk/helpers";
3
4
  import { FURNITURE_RETAILER_QA } from "@guava-ai/guava-sdk/example-data";
4
- import { getDefaultLogger } from "@guava-ai/guava-sdk";
5
5
 
6
6
  export const agent = new guava.Agent({
7
7
  name: "Nova",
@@ -9,22 +9,24 @@ export const agent = new guava.Agent({
9
9
  purpose: "Answer questions and route callers to the appropriate department.",
10
10
  });
11
11
 
12
- const logger = getDefaultLogger();
13
-
14
- const documentQA = new DocumentQA("clearfield-home-living-qa", FURNITURE_RETAILER_QA);
12
+ const documentQA = new DocumentQA({
13
+ documents: FURNITURE_RETAILER_QA,
14
+ namespace: "clearfield-home-living-qa",
15
+ });
15
16
 
16
- const intentRecognizer = new IntentRecognizer(
17
- ["sales", "delivery-and-returns", "account-management", "other"] as const,
18
- logger,
19
- );
17
+ const intentRecognizer = new IntentRecognizer([
18
+ "sales",
19
+ "delivery-and-returns",
20
+ "account-management",
21
+ "other",
22
+ ]);
20
23
 
21
24
  agent.onQuestion(async (_call: guava.Call, question: string) => {
22
25
  return await documentQA.ask(question);
23
26
  });
24
27
 
25
28
  agent.onActionRequest(async (_call: guava.Call, request: string) => {
26
- const key = await intentRecognizer.classify(request);
27
- return { key };
29
+ return await intentRecognizer.classify(request);
28
30
  });
29
31
 
30
32
  agent.onAction("sales", async (call: guava.Call) => {
@@ -60,12 +62,19 @@ export async function run(args: string[]) {
60
62
  await agent.listenWebrtc();
61
63
  } else if (args.includes("--phone")) {
62
64
  agent.listenPhone(process.env.GUAVA_AGENT_NUMBER!);
65
+ } else if (args.includes("--sip")) {
66
+ const sipCode = args[args.indexOf("--sip") + 1];
67
+ if (!sipCode) {
68
+ console.error("Error: --sip requires a SIP code argument.");
69
+ process.exit(1);
70
+ }
71
+ await agent.listenSip(sipCode);
63
72
  } else if (args.includes("--local")) {
64
73
  await agent.callLocal();
65
74
  } else if (args.includes("--chat")) {
66
75
  await agent.chat();
67
76
  } else {
68
- console.error("Usage: guava-example help-desk --phone | --webrtc | --local | --chat");
77
+ console.error("Usage: guava-example help-desk --phone | --webrtc | --sip | --local | --chat");
69
78
  process.exit(1);
70
79
  }
71
80
  }
@@ -1,5 +1,5 @@
1
1
  import * as guava from "@guava-ai/guava-sdk";
2
- import { DocumentQA } from "@guava-ai/guava-sdk/helpers/openai";
2
+ import { DocumentQA } from "@guava-ai/guava-sdk/helpers";
3
3
  import { PROPERTY_INSURANCE_POLICY } from "@guava-ai/guava-sdk/example-data";
4
4
 
5
5
  const agent = new guava.Agent({
@@ -9,7 +9,10 @@ const agent = new guava.Agent({
9
9
 
10
10
  // This is a built-in knowledge base helper that we will use for this example.
11
11
  // You can use any RAG system you prefer.
12
- const documentQA = new DocumentQA("harper-valley-property-insurance", PROPERTY_INSURANCE_POLICY);
12
+ const documentQA = new DocumentQA({
13
+ documents: PROPERTY_INSURANCE_POLICY,
14
+ namespace: "harper-valley-property-insurance",
15
+ });
13
16
 
14
17
  // When the Agent is asked a question that it cannot answer, it will invoke the on_question callback.
15
18
  agent.onQuestion(async (call: guava.Call, question: string) => {
@@ -23,12 +26,21 @@ export async function run(args: string[]) {
23
26
  await agent.listenWebrtc();
24
27
  } else if (args.includes("--phone")) {
25
28
  agent.listenPhone(process.env.GUAVA_AGENT_NUMBER!);
29
+ } else if (args.includes("--sip")) {
30
+ const sipCode = args[args.indexOf("--sip") + 1];
31
+ if (!sipCode) {
32
+ console.error("Error: --sip requires a SIP code argument.");
33
+ process.exit(1);
34
+ }
35
+ await agent.listenSip(sipCode);
26
36
  } else if (args.includes("--local")) {
27
37
  await agent.callLocal();
28
38
  } else if (args.includes("--chat")) {
29
39
  await agent.chat();
30
40
  } else {
31
- console.error("Usage: guava-example property-insurance --phone | --webrtc | --local | --chat");
41
+ console.error(
42
+ "Usage: guava-example property-insurance --phone | --webrtc | --sip | --local | --chat",
43
+ );
32
44
  process.exit(1);
33
45
  }
34
46
  }
@@ -47,12 +47,21 @@ export async function run(args: string[]) {
47
47
  await agent.listenWebrtc();
48
48
  } else if (args.includes("--phone")) {
49
49
  agent.listenPhone(process.env.GUAVA_AGENT_NUMBER!);
50
+ } else if (args.includes("--sip")) {
51
+ const sipCode = args[args.indexOf("--sip") + 1];
52
+ if (!sipCode) {
53
+ console.error("Error: --sip requires a SIP code argument.");
54
+ process.exit(1);
55
+ }
56
+ await agent.listenSip(sipCode);
50
57
  } else if (args.includes("--local")) {
51
58
  await agent.callLocal();
52
59
  } else if (args.includes("--chat")) {
53
60
  await agent.chat();
54
61
  } else {
55
- console.error("Usage: guava-example restaurant-waitlist --phone | --webrtc | --local | --chat");
62
+ console.error(
63
+ "Usage: guava-example restaurant-waitlist --phone | --webrtc | --sip | --local | --chat",
64
+ );
56
65
  process.exit(1);
57
66
  }
58
67
  }
@@ -1,5 +1,5 @@
1
1
  import * as guava from "@guava-ai/guava-sdk";
2
- import { DatetimeFilter } from "@guava-ai/guava-sdk/helpers/openai";
2
+ import { DatetimeFilter } from "@guava-ai/guava-sdk/helpers";
3
3
  import { mockAppointmentsForFuture } from "@guava-ai/guava-sdk/example-data";
4
4
 
5
5
  const agent = new guava.Agent({
@@ -7,9 +7,7 @@ const agent = new guava.Agent({
7
7
  purpose: "You are calling patients to help them schedule a dental appointment",
8
8
  });
9
9
 
10
- const datetimeFilter = new DatetimeFilter({
11
- sourceList: mockAppointmentsForFuture(),
12
- });
10
+ const datetimeFilter = new DatetimeFilter(mockAppointmentsForFuture());
13
11
 
14
12
  agent.onCallStart(async (call: guava.Call) => {
15
13
  await call.reachPerson(await call.getVariable("patientName"));
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@guava-ai/guava-sdk",
3
3
  "description": "The official TypeScript SDK for building Guava voice agents.",
4
4
  "homepage": "https://docs.goguava.ai/typescript-sdk/",
5
- "version": "0.23.0",
5
+ "version": "0.24.0",
6
6
  "type": "commonjs",
7
7
  "main": "dist/src/index.js",
8
8
  "types": "dist/src/index.d.ts",
@@ -11,6 +11,10 @@
11
11
  "types": "./dist/src/index.d.ts",
12
12
  "default": "./dist/src/index.js"
13
13
  },
14
+ "./helpers": {
15
+ "types": "./dist/src/helpers/index.d.ts",
16
+ "default": "./dist/src/helpers/index.js"
17
+ },
14
18
  "./helpers/openai": {
15
19
  "types": "./dist/src/helpers/openai.d.ts",
16
20
  "default": "./dist/src/helpers/openai.js"
@@ -1,7 +1,7 @@
1
1
  import * as z from "zod";
2
2
 
3
3
  export const FieldItemType = z.union(
4
- (["text", "date", "datetime", "integer", "multiple_choice", "calendar_slot"] as const).map(
4
+ (["text", "date", "integer", "digit_sequence", "multiple_choice", "calendar_slot"] as const).map(
5
5
  (val) => z.literal(val),
6
6
  ),
7
7
  );