myavana-bot-test-core 2.2.0 → 2.3.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/.env +1 -1
- package/README.md +0 -0
- package/index.js +46 -1
- package/migrations/004_add_partner_products.sql +25 -0
- package/migrations/005_add_hair_trends.sql +23 -0
- package/migrations/006_add_funnel_events.sql +17 -0
- package/migrations/007_add_agent_memory.sql +23 -0
- package/package.json +3 -2
- package/src/__tests__/agentTools.test.js +165 -0
- package/src/__tests__/cacheManager.test.js +196 -0
- package/src/__tests__/conversation.test.js +151 -0
- package/src/__tests__/conversationDriver.test.js +233 -0
- package/src/__tests__/messageContextBuilder.test.js +192 -0
- package/src/__tests__/personaClassifier.test.js +253 -0
- package/src/__tests__/postResponseProcessing.test.js +199 -0
- package/src/__tests__/trendManager.test.js +166 -0
- package/src/agentMemory.js +122 -0
- package/src/agentTools.js +236 -0
- package/src/ai.js +1 -1
- package/src/cacheManager.js +17 -7
- package/src/config.js +2 -2
- package/src/conversation.js +1 -1
- package/src/conversationDriver.js +230 -0
- package/src/funnelEvents.js +32 -0
- package/src/messageContextBuilder.js +84 -0
- package/src/personaClassifier.js +214 -0
- package/src/postResponseProcessing.js +33 -3
- package/src/trendManager.js +240 -0
- package/src/unifiedChatHandler.js +2 -2
- package/src/utils.js +27 -5
package/src/utils.js
CHANGED
|
@@ -50,10 +50,6 @@ async function getAdditionalInstructions() { // New function to get ALL Bot Inst
|
|
|
50
50
|
return [];
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
async function getHairIssuesForUser(userId){
|
|
54
|
-
//return empty for now
|
|
55
|
-
return []
|
|
56
|
-
}
|
|
57
53
|
async function getProductByName(productName) {
|
|
58
54
|
try {
|
|
59
55
|
const result = await pgClient.query('SELECT product_id FROM products WHERE product_name = $1', [productName]);
|
|
@@ -81,13 +77,39 @@ async function addProductRecommendation(userId, conversationId, productId, reaso
|
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
79
|
|
|
80
|
+
|
|
81
|
+
async function getTrainingData(limit = 50) {
|
|
82
|
+
try {
|
|
83
|
+
const result = await pgClient.query(
|
|
84
|
+
'SELECT title, source_type, extracted_text, created_at FROM training_data ORDER BY created_at DESC LIMIT $1',
|
|
85
|
+
[limit]
|
|
86
|
+
);
|
|
87
|
+
return result.rows;
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.error("Error fetching training data:", error);
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function getChatbotWelcomeSettings() {
|
|
95
|
+
try {
|
|
96
|
+
const result = await pgClient.query(
|
|
97
|
+
'SELECT welcome_text, image_urls, flow_data FROM chatbot_welcome_settings WHERE is_active = TRUE ORDER BY created_at DESC LIMIT 1'
|
|
98
|
+
);
|
|
99
|
+
return result.rows[0] || null;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error("Error fetching chatbot welcome settings:", error);
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
84
105
|
module.exports = {
|
|
85
106
|
getAllProducts,
|
|
86
107
|
getAllFaqs,
|
|
87
108
|
getAllYoutubeVideos,
|
|
88
109
|
getAllTestimonials,
|
|
89
110
|
getAdditionalInstructions,
|
|
90
|
-
|
|
111
|
+
getTrainingData,
|
|
112
|
+
getChatbotWelcomeSettings,
|
|
91
113
|
getProductByName,
|
|
92
114
|
addProductRecommendation
|
|
93
115
|
};
|