myavana-bot-test-core 1.0.4 → 1.0.6
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 +3 -1
- package/index.js +1 -0
- package/package.json +1 -1
- package/src/config.js +7 -0
- package/src/postResponseProcessing.js +6 -7
package/.env
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# PostgreSQL
|
|
2
2
|
DB_HOST=34.55.140.120
|
|
3
|
+
MYAVANA_DB_HOST=34.60.246.147
|
|
3
4
|
DB_USER=myavana
|
|
4
5
|
DB_PASSWORD=higibertigibet
|
|
5
6
|
DB_NAME=sienna-naturals-custom-bot
|
|
7
|
+
MYAVANA_DB_NAME=myavana-dashboard-bot
|
|
6
8
|
DB_PORT=5432
|
|
7
9
|
|
|
8
10
|
# Redis
|
|
@@ -15,5 +17,5 @@ REDIS_USERNAME=default
|
|
|
15
17
|
GENKIT_API_KEY=AIzaSyBB5ZYwktOFI3R3j_vs8U7CxwKgS3XNgM0
|
|
16
18
|
|
|
17
19
|
#OpenAI
|
|
18
|
-
OPENAI_API_KEY=sk-proj-
|
|
20
|
+
OPENAI_API_KEY=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
|
|
19
21
|
|
package/index.js
CHANGED
|
@@ -19,6 +19,7 @@ module.exports = {
|
|
|
19
19
|
// Post-processing and hair issues
|
|
20
20
|
postProcessConversation: require('./src/postResponseProcessing').postProcessConversation,
|
|
21
21
|
postResponseProcessing: require('./src/postResponseProcessing').postResponseProcessing,
|
|
22
|
+
updateUserProfile: require('./src/postResponseProcessing').updateUserProfile,
|
|
22
23
|
saveHairIssue: require('./src/hairIssues').saveHairIssue,
|
|
23
24
|
getHairIssuesForUser: require('./src/hairIssues').getHairIssuesForUser,
|
|
24
25
|
postResponseProductCheck: require('./src/postResponseProcessing').postResponseProductCheck,
|
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -9,6 +9,13 @@ module.exports = {
|
|
|
9
9
|
database: process.env.DB_NAME,
|
|
10
10
|
port: parseInt(process.env.DB_PORT, 10) || 5432, // Default PostgreSQL port
|
|
11
11
|
},
|
|
12
|
+
myavanaDbConfig: {
|
|
13
|
+
host: process.env.MYAVANA_DB_HOST,
|
|
14
|
+
user: process.env.DB_USER,
|
|
15
|
+
password: process.env.DB_PASSWORD,
|
|
16
|
+
database: process.env.MYAVANA_DB_NAME,
|
|
17
|
+
port: parseInt(process.env.DB_PORT, 10) || 5432, // Default PostgreSQL port
|
|
18
|
+
},
|
|
12
19
|
redisConfig: {
|
|
13
20
|
username: process.env.REDIS_USERNAME,
|
|
14
21
|
password: process.env.REDIS_PASSWORD,
|
|
@@ -9,7 +9,7 @@ const {getProductByName, addProductRecommendation} = require("./utils");
|
|
|
9
9
|
|
|
10
10
|
const postProcessingPrompt = (chatHistory, message) => {
|
|
11
11
|
return `
|
|
12
|
-
You are a
|
|
12
|
+
You are a hair expert AI assistant designed to analyze user conversations and user's name and extract structured information related to hair care.
|
|
13
13
|
|
|
14
14
|
**Task:** Analyze the following conversation history and the user's latest message to:
|
|
15
15
|
|
|
@@ -223,7 +223,7 @@ const postProcessConversation = async (chatHistory, message) => {
|
|
|
223
223
|
|
|
224
224
|
|
|
225
225
|
const extractionPrompt = await postProcessingPrompt(chatHistory, message);
|
|
226
|
-
console.log('Extraction prompt: ', extractionPrompt);
|
|
226
|
+
//console.log('Extraction prompt: ', extractionPrompt);
|
|
227
227
|
try {
|
|
228
228
|
const chat = ai.chat({
|
|
229
229
|
model: gemini15Flash,
|
|
@@ -233,7 +233,7 @@ const postProcessConversation = async (chatHistory, message) => {
|
|
|
233
233
|
|
|
234
234
|
});
|
|
235
235
|
const { output } = await chat.send(extractionPrompt);
|
|
236
|
-
console.log("Raw post-processing output:", JSON.stringify(output));
|
|
236
|
+
//console.log("Raw post-processing output:", JSON.stringify(output));
|
|
237
237
|
|
|
238
238
|
if (!output) {
|
|
239
239
|
console.warn("Post-processing output is empty. Returning default empty JSON.");
|
|
@@ -316,8 +316,7 @@ const updateUserProfile = async (userId, updates) => {
|
|
|
316
316
|
|
|
317
317
|
const postResponseProcessing = async (postProcessData, userId, output, allchatsSummary, conversationId, chatHistory, botMessage )=>{
|
|
318
318
|
if (postProcessData.user_profile_updates) {
|
|
319
|
-
//
|
|
320
|
-
console.log("User profile updates to be applied:", postProcessData.user_profile_updates);
|
|
319
|
+
//console.log("User profile updates to be applied:", postProcessData.user_profile_updates);
|
|
321
320
|
await updateUserProfile(userId, postProcessData.user_profile_updates);
|
|
322
321
|
}
|
|
323
322
|
|
|
@@ -333,7 +332,7 @@ const postResponseProcessing = async (postProcessData, userId, output, allchatsS
|
|
|
333
332
|
await generateAndSaveSummary(userId, conversationId, chatHistory);
|
|
334
333
|
}
|
|
335
334
|
const recommendedProductsData = await postResponseProductCheck(chatHistory, botMessage); // Get array of product objects
|
|
336
|
-
|
|
335
|
+
console.log("Recommended Products (with reasons):", JSON.stringify(recommendedProductsData));
|
|
337
336
|
|
|
338
337
|
if (recommendedProductsData && recommendedProductsData.length > 0) {
|
|
339
338
|
// --- Loop through recommended products and save to DB (Corrected for reasons) ---
|
|
@@ -386,7 +385,7 @@ const postResponseProductCheck = async (chatHistory, message) => {
|
|
|
386
385
|
},
|
|
387
386
|
});
|
|
388
387
|
const { output } = await chat.send(extractionPrompt);
|
|
389
|
-
console.log("Raw post-processing output for product check (with reason):", JSON.stringify(output)); // Updated log
|
|
388
|
+
//console.log("Raw post-processing output for product check (with reason):", JSON.stringify(output)); // Updated log
|
|
390
389
|
|
|
391
390
|
if (!output) {
|
|
392
391
|
console.warn("Post-processing output for product check (with reason) is empty. Returning default empty array."); // Updated log
|