@xapp/stentor-service-generative-ai 1.89.0 → 1.89.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.
Files changed (88) hide show
  1. package/lib/AWSBedrockService.d.ts +67 -0
  2. package/lib/AWSBedrockService.js +133 -0
  3. package/lib/AWSBedrockService.js.map +1 -0
  4. package/lib/ClaudeService.d.ts +77 -0
  5. package/lib/ClaudeService.js +142 -0
  6. package/lib/ClaudeService.js.map +1 -0
  7. package/lib/FallbackLLMService.d.ts +46 -0
  8. package/lib/FallbackLLMService.js +83 -0
  9. package/lib/FallbackLLMService.js.map +1 -0
  10. package/lib/GenerativeAIService.d.ts +49 -0
  11. package/lib/GenerativeAIService.js +130 -0
  12. package/lib/GenerativeAIService.js.map +1 -0
  13. package/lib/OpenAIService.d.ts +33 -0
  14. package/lib/OpenAIService.js +76 -0
  15. package/lib/OpenAIService.js.map +1 -0
  16. package/lib/http/HTTPService.d.ts +18 -0
  17. package/lib/http/HTTPService.js +4 -0
  18. package/lib/http/HTTPService.js.map +1 -0
  19. package/lib/http/NodeHTTPService.d.ts +8 -0
  20. package/lib/http/NodeHTTPService.js +70 -0
  21. package/lib/http/NodeHTTPService.js.map +1 -0
  22. package/lib/http/index.d.ts +3 -0
  23. package/lib/http/index.js +20 -0
  24. package/lib/http/index.js.map +1 -0
  25. package/lib/index.d.ts +10 -0
  26. package/lib/index.js +27 -0
  27. package/lib/index.js.map +1 -0
  28. package/lib/models/ChatSummary.d.ts +10 -0
  29. package/lib/models/ChatSummary.js +4 -0
  30. package/lib/models/ChatSummary.js.map +1 -0
  31. package/lib/models/EmailAnalysis.d.ts +73 -0
  32. package/lib/models/EmailAnalysis.js +4 -0
  33. package/lib/models/EmailAnalysis.js.map +1 -0
  34. package/lib/models/EngagementAnalysis.d.ts +93 -0
  35. package/lib/models/EngagementAnalysis.js +4 -0
  36. package/lib/models/EngagementAnalysis.js.map +1 -0
  37. package/lib/models/GenerativeAIService.d.ts +65 -0
  38. package/lib/models/GenerativeAIService.js +3 -0
  39. package/lib/models/GenerativeAIService.js.map +1 -0
  40. package/lib/models/LLMService.d.ts +24 -0
  41. package/lib/models/LLMService.js +4 -0
  42. package/lib/models/LLMService.js.map +1 -0
  43. package/lib/models/LeadAnalysis.d.ts +105 -0
  44. package/lib/models/LeadAnalysis.js +4 -0
  45. package/lib/models/LeadAnalysis.js.map +1 -0
  46. package/lib/models/Prompt.d.ts +37 -0
  47. package/lib/models/Prompt.js +8 -0
  48. package/lib/models/Prompt.js.map +1 -0
  49. package/lib/models/PromptGenerator.d.ts +6 -0
  50. package/lib/models/PromptGenerator.js +4 -0
  51. package/lib/models/PromptGenerator.js.map +1 -0
  52. package/lib/models/ResponseParser.d.ts +5 -0
  53. package/lib/models/ResponseParser.js +4 -0
  54. package/lib/models/ResponseParser.js.map +1 -0
  55. package/lib/models/WebsiteAnalysis.d.ts +48 -0
  56. package/lib/models/WebsiteAnalysis.js +4 -0
  57. package/lib/models/WebsiteAnalysis.js.map +1 -0
  58. package/lib/models/errors.d.ts +7 -0
  59. package/lib/models/errors.js +15 -0
  60. package/lib/models/errors.js.map +1 -0
  61. package/lib/models/index.d.ts +10 -0
  62. package/lib/models/index.js +27 -0
  63. package/lib/models/index.js.map +1 -0
  64. package/lib/prompts/AnalyzeEmail.d.ts +36 -0
  65. package/lib/prompts/AnalyzeEmail.js +385 -0
  66. package/lib/prompts/AnalyzeEmail.js.map +1 -0
  67. package/lib/prompts/AnalyzeLead.d.ts +59 -0
  68. package/lib/prompts/AnalyzeLead.js +396 -0
  69. package/lib/prompts/AnalyzeLead.js.map +1 -0
  70. package/lib/prompts/AnalyzeTranscript.d.ts +24 -0
  71. package/lib/prompts/AnalyzeTranscript.js +202 -0
  72. package/lib/prompts/AnalyzeTranscript.js.map +1 -0
  73. package/lib/prompts/AnalyzeWebsite.d.ts +10 -0
  74. package/lib/prompts/AnalyzeWebsite.js +176 -0
  75. package/lib/prompts/AnalyzeWebsite.js.map +1 -0
  76. package/lib/prompts/ChatSummary.d.ts +62 -0
  77. package/lib/prompts/ChatSummary.js +67 -0
  78. package/lib/prompts/ChatSummary.js.map +1 -0
  79. package/lib/prompts/index.d.ts +5 -0
  80. package/lib/prompts/index.js +22 -0
  81. package/lib/prompts/index.js.map +1 -0
  82. package/lib/utils/extractJSON.d.ts +10 -0
  83. package/lib/utils/extractJSON.js +17 -0
  84. package/lib/utils/extractJSON.js.map +1 -0
  85. package/lib/utils/standardizeTerms.d.ts +15 -0
  86. package/lib/utils/standardizeTerms.js +53 -0
  87. package/lib/utils/standardizeTerms.js.map +1 -0
  88. package/package.json +3 -2
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2025, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.parseAnalyzeWebsiteResponse = exports.generateAnalyzeWebsite = void 0;
5
+ const stentor_utils_1 = require("stentor-utils");
6
+ const arachne_utils_1 = require("@xapp/arachne-utils");
7
+ const generateAnalyzeWebsite = ({ markdown, url }, overrides) => {
8
+ const content = `
9
+ Your task is to analyze the contents of a website (provided in markdown below) found at ${url} and provide information about the organization from what is on the website. You will only provide information available through the website content about the services they provide, contact information and a description of the business.
10
+
11
+ ===========
12
+ ${markdown}
13
+ ===========
14
+
15
+ Please print out in JSON format on one line information about the website above with the following keys:
16
+
17
+ "parked_domain" - Boolean, true if the website is a parked domain such as for sale, coming soon, no longer active by the host, used for type-in traffic monetization. This is false if the website is for an actual organization or business.
18
+ "organization_name" - The name of the organization for the website.
19
+ "email" - An array of emails for the organization. If available, include what they are used for such as "sales" or "info", if unknown then leave it blank. Use an object with keys: email and purpose.
20
+ "phone_numbers" - An array of phone numbers for the organization. If available, include what they are used for such as "main phone", "customer support" or "sales", if unknown then leave it blank. The numbers must appear in the provided website content. Use an object with keys: number and purpose.
21
+ "addresses" - An array of address objects for the organization. Partial address objects are acceptable. The keys for the address object are as follows:
22
+ "formatted" - The full formatted address, similar to what Google Autocomplete API provides.
23
+ "streetAddress" - The street address with street number and name, quadrant, etc.
24
+ "locality" - City, Town or Locality. This is typically from the "city" of "city", "state"
25
+ "region" - Typically the state or province
26
+ "postalCode" - The postal or zip code
27
+ "country" - The country
28
+ "services" - An array of the possible top five unique most common services the organization provides, they should be concise and no more than a few words. These will include but not limited to: "hvac", "plumbing", "electrical", "roofing",
29
+ "calls_to_action" - An array of the top five unique calls to action found on the site and their fully formed URL if they have one. Good examples of calls to actions are "Request Demo", "Get Started", "Free Quote", "Schedule Consultation", "Sign Up". Bad examples are "Learn More" or "Follow us on Facebook". Use an object with keys: url & callToAction in the array. For the url please combine it properly with the website's URL.
30
+ "description" - A description of what the organization does, include the name of the organization, their services, their location, phone number, email. Keep it concise and to a few sentences and around 480 characters.
31
+ "industry_category" - A description of which industry category the business is in. Only pick from one of the following and use the value in quotes:
32
+ "business-coaching" - Business provides coaching services for other business
33
+ "consulting" - Business provides consulting services
34
+ "financial-services" - Business provides wealth & asset management services
35
+ "home-services-cleaning" - Provide janitorial and cleaning services
36
+ "home-services-contractors" - Electricians, plumbers, roofers, and other technicians and contractors
37
+ "home-services-outdoor" - Lawn care, gardeners and other outside residential services
38
+ "pest-control" - Pest control services
39
+ "insurance" - Insurance agents and brokers,
40
+ "legal-services" - Lawyers, legal services, tax attorneys
41
+ "life-coaching" - Life coaching services
42
+ "real-estate" - Real estate agents and brokers
43
+ "technology-services" - IT consultants and software services
44
+ "travel" - Travel agents
45
+ "property-management" - Property management services
46
+ `.trim();
47
+ return Object.assign(Object.assign({ model: "gpt-4o-mini", max_tokens: 256, frequency_penalty: 0, temperature: 1, top_p: 1, presence_penalty: 0 }, overrides), { response_format: {
48
+ type: "json_schema",
49
+ json_schema: {
50
+ name: "analyze_website",
51
+ strict: true,
52
+ schema: {
53
+ type: "object",
54
+ properties: {
55
+ parked_domain: { type: "boolean" },
56
+ organization_name: { type: "string" },
57
+ email: {
58
+ type: "array",
59
+ items: {
60
+ type: "object",
61
+ properties: {
62
+ email: { type: "string" },
63
+ purpose: { type: "string", nullable: true }
64
+ },
65
+ required: ["email"]
66
+ }
67
+ },
68
+ phone_numbers: {
69
+ type: "array",
70
+ items: {
71
+ type: "object",
72
+ properties: {
73
+ number: { type: "string" },
74
+ purpose: { type: "string", nullable: true }
75
+ },
76
+ required: ["number"]
77
+ }
78
+ },
79
+ addresses: {
80
+ type: "array",
81
+ items: {
82
+ type: "object",
83
+ properties: {
84
+ formatted: { type: "string", nullable: true },
85
+ streetAddress: { type: "string", nullable: true },
86
+ locality: { type: "string", nullable: true },
87
+ region: { type: "string", nullable: true },
88
+ postalCode: { type: "string", nullable: true },
89
+ country: { type: "string", nullable: true }
90
+ }
91
+ }
92
+ },
93
+ services: { type: "array", items: { type: "string" } },
94
+ calls_to_action: {
95
+ type: "array",
96
+ items: {
97
+ type: "object",
98
+ properties: { url: { type: "string" }, callToAction: { type: "string" } }
99
+ }
100
+ },
101
+ description: { type: "string" },
102
+ industry_category: { type: "string" }
103
+ },
104
+ required: [
105
+ "parked_domain",
106
+ "organization_name",
107
+ "email",
108
+ "phone_numbers",
109
+ "addresses",
110
+ "services",
111
+ "calls_to_action",
112
+ "description",
113
+ "industry_category"
114
+ ]
115
+ }
116
+ }
117
+ }, type: "completions", messages: [
118
+ {
119
+ role: "system",
120
+ content
121
+ }
122
+ ] });
123
+ };
124
+ exports.generateAnalyzeWebsite = generateAnalyzeWebsite;
125
+ const parseAnalyzeWebsiteResponse = (response) => {
126
+ const DEFAULT_ANALYSIS = {
127
+ parked_domain: false,
128
+ organization_name: "",
129
+ email: [],
130
+ phone_numbers: [],
131
+ addresses: [],
132
+ services: [],
133
+ calls_to_action: [],
134
+ description: "",
135
+ industry_category: "contact-capture"
136
+ };
137
+ try {
138
+ const { parked_domain, organization_name, description, industry_category, phone_numbers, email, addresses, services, calls_to_action } = JSON.parse(response);
139
+ const analysis = Object.assign(Object.assign({}, DEFAULT_ANALYSIS), { parked_domain,
140
+ organization_name,
141
+ description });
142
+ if (industry_category) {
143
+ analysis.industry_category = industry_category;
144
+ }
145
+ if ((0, stentor_utils_1.existsAndNotEmpty)(addresses)) {
146
+ analysis.addresses = addresses;
147
+ }
148
+ // filter out hallucinated phone numbers
149
+ if ((0, stentor_utils_1.existsAndNotEmpty)(phone_numbers)) {
150
+ // clean for hallucinations
151
+ // numbers like 123-45678 or numbers like 555-
152
+ const mostLikelyRealPhoneNumbers = phone_numbers
153
+ .filter((number) => !!number.number)
154
+ .filter((number) => !(0, arachne_utils_1.isHallucinatedPhoneNumber)(number.number));
155
+ analysis.phone_numbers = mostLikelyRealPhoneNumbers;
156
+ }
157
+ // filter out hallucinated emails
158
+ if ((0, stentor_utils_1.existsAndNotEmpty)(email)) {
159
+ const filteredEmails = email.filter((e) => !!e.email).filter((e) => !(0, arachne_utils_1.isHallucinatedEmail)(e.email));
160
+ analysis.email = filteredEmails;
161
+ }
162
+ if ((0, stentor_utils_1.existsAndNotEmpty)(services)) {
163
+ analysis.services = services;
164
+ }
165
+ if ((0, stentor_utils_1.existsAndNotEmpty)(calls_to_action)) {
166
+ analysis.calls_to_action = calls_to_action;
167
+ }
168
+ return analysis;
169
+ }
170
+ catch (error) {
171
+ console.error("Error parsing analyze website response:", error);
172
+ return DEFAULT_ANALYSIS;
173
+ }
174
+ };
175
+ exports.parseAnalyzeWebsiteResponse = parseAnalyzeWebsiteResponse;
176
+ //# sourceMappingURL=AnalyzeWebsite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyzeWebsite.js","sourceRoot":"","sources":["../../src/prompts/AnalyzeWebsite.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;AAElC,iDAAkD;AAGlD,uDAAqF;AAW9E,MAAM,sBAAsB,GAI/B,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,SAAS,EAAoB,EAAE;IACnD,MAAM,OAAO,GAAG;0FACsE,GAAG;;;EAG3F,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCT,CA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AE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAA,mCAAmB,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YACnG,QAAQ,CAAC,KAAK,GAAG,cAAc,CAAC;QACpC,CAAC;QAED,IAAI,IAAA,iCAAiB,EAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACjC,CAAC;QAED,IAAI,IAAA,iCAAiB,EAAC,eAAe,CAAC,EAAE,CAAC;YACrC,QAAQ,CAAC,eAAe,GAAG,eAAe,CAAC;QAC/C,CAAC;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAC;QAChE,OAAO,gBAAgB,CAAC;IAC5B,CAAC;AACL,CAAC,CAAC;AAtEW,QAAA,2BAA2B,+BAsEtC"}
@@ -0,0 +1,62 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ import type { ExternalLead } from "stentor-models";
3
+ import type { CompletionPrompt, PromptGenerator, ResponseParser } from "../models";
4
+ import type { ChatSummary } from "../models/ChatSummary";
5
+ /**
6
+ * A conversation line that was said by the user or system.
7
+ */
8
+ export interface SummaryLine {
9
+ /**
10
+ * The user that said the line.
11
+ */
12
+ user: string;
13
+ /**
14
+ * The content that was said by the user.
15
+ */
16
+ line: string;
17
+ }
18
+ /**
19
+ * The properties that are required to generate a chat summary prompt.
20
+ */
21
+ export interface ChatSummaryPromptProps {
22
+ /**
23
+ * The lines that were said in the conversation.
24
+ */
25
+ summary: SummaryLine[];
26
+ }
27
+ export interface ChatSummaryFromLeadTranscriptProps {
28
+ /**
29
+ * The transcript of a found lead.
30
+ */
31
+ transcript: ExternalLead["transcript"];
32
+ }
33
+ export type ChatSummaryLLMOverrides = Partial<Pick<CompletionPrompt, "model" | "max_tokens" | "temperature" | "top_p" | "frequency_penalty" | "presence_penalty">>;
34
+ /**
35
+ * Generate a prompt that can be used in an LLM to return a summary of a chat conversation from a lead transcript.
36
+ *
37
+ * The expected output format from the LLM will be:
38
+ *
39
+ * <Full summary of the text>
40
+ *
41
+ * @param transcript - The summary transcript of the chat.
42
+ * @param overrides
43
+ * @returns
44
+ */
45
+ export declare const generateChatSummaryPromptFromLeadTranscript: PromptGenerator<ChatSummaryFromLeadTranscriptProps, ChatSummaryLLMOverrides, CompletionPrompt>;
46
+ /**
47
+ * Generates a prompt that can be used in an LLM to return a summary of a chat conversation.
48
+ *
49
+ * The expected output format from the LLM will be:
50
+ *
51
+ * <Full summary of the text>
52
+ *
53
+ * @param summary - The summary transcript of the chat.
54
+ * @returns
55
+ */
56
+ export declare const generateChatSummaryPrompt: PromptGenerator<ChatSummaryPromptProps, ChatSummaryLLMOverrides, CompletionPrompt>;
57
+ /**
58
+ * Parser for the Chat Summary response.
59
+ * @param response
60
+ * @returns
61
+ */
62
+ export declare const chatSummaryResponseParse: ResponseParser<ChatSummary>;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2024, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.chatSummaryResponseParse = exports.generateChatSummaryPrompt = exports.generateChatSummaryPromptFromLeadTranscript = void 0;
5
+ /**
6
+ * Generate a prompt that can be used in an LLM to return a summary of a chat conversation from a lead transcript.
7
+ *
8
+ * The expected output format from the LLM will be:
9
+ *
10
+ * <Full summary of the text>
11
+ *
12
+ * @param transcript - The summary transcript of the chat.
13
+ * @param overrides
14
+ * @returns
15
+ */
16
+ const generateChatSummaryPromptFromLeadTranscript = ({ transcript }, overrides) => {
17
+ const summary = transcript.map(({ from, message }) => ({
18
+ user: (from === null || from === void 0 ? void 0 : from.name) || (from === null || from === void 0 ? void 0 : from.email) || (from === null || from === void 0 ? void 0 : from.phone) || (from === null || from === void 0 ? void 0 : from.id) || "Unknown",
19
+ line: message
20
+ }));
21
+ return (0, exports.generateChatSummaryPrompt)({ summary }, overrides);
22
+ };
23
+ exports.generateChatSummaryPromptFromLeadTranscript = generateChatSummaryPromptFromLeadTranscript;
24
+ /**
25
+ * Generates a prompt that can be used in an LLM to return a summary of a chat conversation.
26
+ *
27
+ * The expected output format from the LLM will be:
28
+ *
29
+ * <Full summary of the text>
30
+ *
31
+ * @param summary - The summary transcript of the chat.
32
+ * @returns
33
+ */
34
+ const generateChatSummaryPrompt = ({ summary }, overrides) => {
35
+ return Object.assign(Object.assign({ model: "gpt-4o-mini", max_tokens: 256, frequency_penalty: 0, temperature: 1, top_p: 1, presence_penalty: 0 }, overrides), { response_format: {
36
+ type: "text"
37
+ }, type: "completions", messages: [{
38
+ role: "system",
39
+ content: "Summarize the transcript of a chat between a business's bot on a website and a person." +
40
+ "Please summarize as if you are the bot in the transcript and you are taking notes for somebody that will be able to help the person with their query. You may use first person." +
41
+ "Do not call the user, \"user\" but instead use \"Someone\", \"Somebody\" or if they give their name you can use their first name however not last name." +
42
+ "If the transcript contains additional identifying information from the user, such as last name, phone number, email address, or addresses then do not include theses in the summary. If the bot provided contact information for the business, you may include it in your summary." +
43
+ "The summary will be then be provided to the business owner so they are aware somebody will be in touch soon with the request they mentioned in the transcript." +
44
+ "Keep the summary to one sentence around 100 words." +
45
+ "An example of a good summary is:" +
46
+ "\"Somebody reached out looking for a quote and I provided them with your contact information.\"" +
47
+ "or" +
48
+ "\"John reached out looking to schedule an appointment and I provided them with the scheduling link.\""
49
+ }, {
50
+ role: "user",
51
+ content: summary.map((s) => `${s.user}: ${s.line}`).join("\n")
52
+ }] });
53
+ };
54
+ exports.generateChatSummaryPrompt = generateChatSummaryPrompt;
55
+ /**
56
+ * Parser for the Chat Summary response.
57
+ * @param response
58
+ * @returns
59
+ */
60
+ const chatSummaryResponseParse = (response) => {
61
+ const summary = response.trim();
62
+ return {
63
+ summary
64
+ };
65
+ };
66
+ exports.chatSummaryResponseParse = chatSummaryResponseParse;
67
+ //# sourceMappingURL=ChatSummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatSummary.js","sourceRoot":"","sources":["../../src/prompts/ChatSummary.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;AAwClC;;;;;;;;;;GAUG;AACI,MAAM,2CAA2C,GAAmG,CAAC,EAAE,UAAU,EAAE,EAAE,SAAS,EAAoB,EAAE;IACvM,MAAM,OAAO,GAAkB,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QAClE,IAAI,EAAE,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAA,KAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAA,KAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,EAAE,CAAA,IAAI,SAAS;QACvE,IAAI,EAAE,OAAO;KAChB,CAAC,CAAC,CAAC;IAEJ,OAAO,IAAA,iCAAyB,EAAC,EAAE,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AAC7D,CAAC,CAAA;AAPY,QAAA,2CAA2C,+CAOvD;AAED;;;;;;;;;GASG;AACI,MAAM,yBAAyB,GAAuF,CAAC,EAAE,OAAO,EAAE,EAAE,SAAS,EAAoB,EAAE;IACtK,qCACI,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,GAAG,EACf,iBAAiB,EAAE,CAAC,EACpB,WAAW,EAAE,CAAC,EACd,KAAK,EAAE,CAAC,EACR,gBAAgB,EAAE,CAAC,IAChB,SAAS,KACZ,eAAe,EAAE;YACb,IAAI,EAAE,MAAM;SACf,EACD,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,CAAC;gBACP,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,wFAAwF;oBAC7F,kLAAkL;oBAClL,yJAAyJ;oBACzJ,qRAAqR;oBACrR,gKAAgK;oBAChK,oDAAoD;oBACpD,kCAAkC;oBAClC,iGAAiG;oBACjG,IAAI;oBACJ,uGAAuG;aAC9G,EAAE;gBACC,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;aACjE,CAAC,IACL;AACL,CAAC,CAAA;AA9BY,QAAA,yBAAyB,6BA8BrC;AAED;;;;GAIG;AACI,MAAM,wBAAwB,GAAgC,CAAC,QAAQ,EAAE,EAAE;IAC9E,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;IAChC,OAAO;QACH,OAAO;KACV,CAAC;AACN,CAAC,CAAA;AALY,QAAA,wBAAwB,4BAKpC"}
@@ -0,0 +1,5 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ export * from "./AnalyzeEmail";
3
+ export * from "./AnalyzeLead";
4
+ export * from "./AnalyzeTranscript";
5
+ export * from "./ChatSummary";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2024, XAPP AI */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ __exportStar(require("./AnalyzeEmail"), exports);
19
+ __exportStar(require("./AnalyzeLead"), exports);
20
+ __exportStar(require("./AnalyzeTranscript"), exports);
21
+ __exportStar(require("./ChatSummary"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;;;;;;;;;;;;;;AAElC,iDAA+B;AAC/B,gDAA8B;AAC9B,sDAAoC;AACpC,gDAA8B"}
@@ -0,0 +1,10 @@
1
+ /*! Copyright (c) 2026, XAPP AI */
2
+ /**
3
+ * Extracts a JSON string from an LLM response that may be wrapped in markdown
4
+ * code fences (e.g., ```json ... ```). Falls back to the raw response if no
5
+ * fences are found.
6
+ *
7
+ * This is necessary because Claude (Bedrock/Anthropic API) does not support
8
+ * `response_format: json_schema` and may wrap JSON output in markdown fences.
9
+ */
10
+ export declare function extractJSON(response: string): string;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2026, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.extractJSON = extractJSON;
5
+ /**
6
+ * Extracts a JSON string from an LLM response that may be wrapped in markdown
7
+ * code fences (e.g., ```json ... ```). Falls back to the raw response if no
8
+ * fences are found.
9
+ *
10
+ * This is necessary because Claude (Bedrock/Anthropic API) does not support
11
+ * `response_format: json_schema` and may wrap JSON output in markdown fences.
12
+ */
13
+ function extractJSON(response) {
14
+ const match = response.match(/```(?:json)?\s*\n?([\s\S]*?)\n?\s*```/);
15
+ return match ? match[1].trim() : response;
16
+ }
17
+ //# sourceMappingURL=extractJSON.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractJSON.js","sourceRoot":"","sources":["../../src/utils/extractJSON.ts"],"names":[],"mappings":";AAAA,kCAAkC;;AAUlC,kCAGC;AAXD;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAC,QAAgB;IACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IACtE,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,15 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ /**
3
+ * Standardizes common terms and acronyms in text while preserving the overall phrasing.
4
+ * Automatically converts input to lowercase before processing and returns lowercased standardized terms.
5
+ *
6
+ * @param input - The text or array of texts to standardize (will be converted to lowercase)
7
+ * @returns The lowercased text(s) with standardized terms
8
+ *
9
+ * @example
10
+ * standardizeTerms("A/C Repair Needed") // "hvac repair needed"
11
+ * standardizeTerms(["HVAC Maintenance", "ELEC Work"]) // ["hvac maintenance", "electrical work"]
12
+ * standardizeTerms("Elec work w/ permits") // "electrical work with permits"
13
+ */
14
+ export declare function standardizeTerms(input: string): string;
15
+ export declare function standardizeTerms(input: string[]): string[];
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2024, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.standardizeTerms = standardizeTerms;
5
+ const TERM_STANDARDIZATIONS = {
6
+ // HVAC/Air Conditioning
7
+ "a/c": "hvac",
8
+ "air conditioning": "hvac",
9
+ "air conditioner": "hvac",
10
+ "hvac": "hvac",
11
+ "heating": "hvac",
12
+ "cooling": "hvac",
13
+ // Plumbing
14
+ "h2o": "water",
15
+ "hot water heater": "water heater",
16
+ "hwh": "water heater",
17
+ // Electrical
18
+ "elec": "electrical",
19
+ "electric": "electrical",
20
+ // General
21
+ "w/": "with",
22
+ "w/o": "without",
23
+ "&": "and"
24
+ };
25
+ function standardizeTerms(input) {
26
+ if (Array.isArray(input)) {
27
+ return input.map(text => standardizeTerms(text));
28
+ }
29
+ if (!input)
30
+ return input;
31
+ // Convert to lowercase first
32
+ let standardized = input.toLowerCase();
33
+ // Apply each standardization using word boundaries to avoid partial matches
34
+ for (const [variant, standard] of Object.entries(TERM_STANDARDIZATIONS)) {
35
+ // Escape special regex characters, including forward slash
36
+ const escapedVariant = variant.replace(/[.*+?^${}()|[\]\\\/]/g, '\\$&');
37
+ // For variants that contain non-word characters (like & or /), we need different boundary matching
38
+ const hasNonWordChars = /[^\w\s]/.test(variant);
39
+ let regex;
40
+ if (hasNonWordChars) {
41
+ // Use space boundaries or start/end of string for non-word character variants
42
+ regex = new RegExp(`(^|\\s)${escapedVariant}(\\s|$)`, 'g');
43
+ standardized = standardized.replace(regex, `$1${standard}$2`);
44
+ }
45
+ else {
46
+ // Use word boundaries for normal word variants
47
+ regex = new RegExp(`\\b${escapedVariant}\\b`, 'g');
48
+ standardized = standardized.replace(regex, standard);
49
+ }
50
+ }
51
+ return standardized;
52
+ }
53
+ //# sourceMappingURL=standardizeTerms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standardizeTerms.js","sourceRoot":"","sources":["../../src/utils/standardizeTerms.ts"],"names":[],"mappings":";AAAA,kCAAkC;;AAwClC,4CA+BC;AArED,MAAM,qBAAqB,GAA2B;IAClD,wBAAwB;IACxB,KAAK,EAAE,MAAM;IACb,kBAAkB,EAAE,MAAM;IAC1B,iBAAiB,EAAE,MAAM;IACzB,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IAEjB,WAAW;IACX,KAAK,EAAE,OAAO;IACd,kBAAkB,EAAE,cAAc;IAClC,KAAK,EAAE,cAAc;IAErB,aAAa;IACb,MAAM,EAAE,YAAY;IACpB,UAAU,EAAE,YAAY;IAExB,UAAU;IACV,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,KAAK;CACb,CAAC;AAgBF,SAAgB,gBAAgB,CAAC,KAAwB;IACrD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEzB,6BAA6B;IAC7B,IAAI,YAAY,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAEvC,4EAA4E;IAC5E,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC;QACtE,2DAA2D;QAC3D,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;QAExE,mGAAmG;QACnG,MAAM,eAAe,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEhD,IAAI,KAAa,CAAC;QAClB,IAAI,eAAe,EAAE,CAAC;YAClB,8EAA8E;YAC9E,KAAK,GAAG,IAAI,MAAM,CAAC,UAAU,cAAc,SAAS,EAAE,GAAG,CAAC,CAAC;YAC3D,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,QAAQ,IAAI,CAAC,CAAC;QAClE,CAAC;aAAM,CAAC;YACJ,+CAA+C;YAC/C,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,cAAc,KAAK,EAAE,GAAG,CAAC,CAAC;YACnD,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACzD,CAAC;IACL,CAAC;IAED,OAAO,YAAY,CAAC;AACxB,CAAC"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "1.89.0",
7
+ "version": "1.89.1",
8
8
  "description": "Generative AI Service",
9
9
  "types": "lib/index",
10
10
  "main": "lib/index",
@@ -41,10 +41,11 @@
41
41
  "stentor-utils": "1.x"
42
42
  },
43
43
  "scripts": {
44
+ "prepack": "yarn build",
44
45
  "build": "tsc -d true -p .",
45
46
  "clean": "rm -rf ./lib/*",
46
47
  "test": "mocha --recursive -r ts-node/register \"./src/**/*.test.ts\"",
47
48
  "ftest": "mocha --recursive -r ts-node/register \"./src/**/*.ftest.ts\""
48
49
  },
49
- "gitHead": "9ca70c64befe97bf993832bf3648a2e4ce77e6c9"
50
+ "gitHead": "3a345719866a5c39329b605545f04c465e6baf48"
50
51
  }