myavana-bot-test-core 1.0.0 → 1.0.2
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/package.json
CHANGED
|
@@ -5,7 +5,146 @@ const DatabaseSessionStore = require("./session");
|
|
|
5
5
|
const { pgClient, redisClient } = require('./database');
|
|
6
6
|
const {generateAndSaveSummary, saveConversationSummary, saveConversation} = require("./conversation");
|
|
7
7
|
const {saveHairIssue} = require("./hairIssues");
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
const postProcessingPrompt = (chatHistory, message) => {
|
|
10
|
+
return `
|
|
11
|
+
You are a Sienna Naturals expert AI assistant designed to analyze user conversations and user's name and extract structured information related to hair care.
|
|
12
|
+
|
|
13
|
+
**Task:** Analyze the following conversation history and the user's latest message to:
|
|
14
|
+
|
|
15
|
+
1. **Extract User Profile Parameters:** Identify any mentions of the user's name, hair characteristics, concerns, goals, habits, and preferences. Extract these as structured parameters based on the provided Zod schema for UserProfileUpdateSchema. If a parameter is not mentioned or cannot be inferred, leave it as null or optional as defined in the schema. **Specifically, try to identify and extract the user's name if they mention it during the conversation.**
|
|
16
|
+
|
|
17
|
+
2. **Extract Hair Issues:** Identify any specific hair issues the user mentions in their latest message. List these issues as an array of strings in the "hair_issues_reported" field, as defined in the HairIssueExtractionSchema. If no issues are mentioned, return an empty array or null for this field as defined in the schema.
|
|
18
|
+
|
|
19
|
+
**Conversation History:**
|
|
20
|
+
${JSON.stringify(chatHistory)}
|
|
21
|
+
|
|
22
|
+
**User's Latest Message:**
|
|
23
|
+
"${message}"
|
|
24
|
+
|
|
25
|
+
**Response Schema**
|
|
26
|
+
{
|
|
27
|
+
"type": "OBJECT",
|
|
28
|
+
"properties": {
|
|
29
|
+
"user_profile_updates": {
|
|
30
|
+
"type": "OBJECT",
|
|
31
|
+
"properties": {
|
|
32
|
+
"name": {
|
|
33
|
+
"type": "STRING",
|
|
34
|
+
"nullable": true
|
|
35
|
+
},
|
|
36
|
+
"hair_type": {
|
|
37
|
+
"type": "STRING",
|
|
38
|
+
"nullable": true
|
|
39
|
+
},
|
|
40
|
+
"hair_texture": {
|
|
41
|
+
"type": "STRING",
|
|
42
|
+
"nullable": true
|
|
43
|
+
},
|
|
44
|
+
"porosity": {
|
|
45
|
+
"type": "STRING",
|
|
46
|
+
"nullable": true
|
|
47
|
+
},
|
|
48
|
+
"elasticity": {
|
|
49
|
+
"type": "STRING",
|
|
50
|
+
"nullable": true
|
|
51
|
+
},
|
|
52
|
+
"density": {
|
|
53
|
+
"type": "STRING",
|
|
54
|
+
"nullable": true
|
|
55
|
+
},
|
|
56
|
+
"curl_pattern": {
|
|
57
|
+
"type": "STRING",
|
|
58
|
+
"nullable": true
|
|
59
|
+
},
|
|
60
|
+
"hair_color_natural": {
|
|
61
|
+
"type": "STRING",
|
|
62
|
+
"nullable": true
|
|
63
|
+
},
|
|
64
|
+
"hair_color_treated": {
|
|
65
|
+
"type": "STRING",
|
|
66
|
+
"nullable": true
|
|
67
|
+
},
|
|
68
|
+
"hair_concerns": {
|
|
69
|
+
"type": "ARRAY",
|
|
70
|
+
"items": {
|
|
71
|
+
"type": "STRING"
|
|
72
|
+
},
|
|
73
|
+
"nullable": true
|
|
74
|
+
},
|
|
75
|
+
"hair_goals": {
|
|
76
|
+
"type": "ARRAY",
|
|
77
|
+
"items": {
|
|
78
|
+
"type": "STRING"
|
|
79
|
+
},
|
|
80
|
+
"nullable": true
|
|
81
|
+
},
|
|
82
|
+
"hair_history_treatments": {
|
|
83
|
+
"type": "ARRAY",
|
|
84
|
+
"items": {
|
|
85
|
+
"type": "STRING"
|
|
86
|
+
},
|
|
87
|
+
"nullable": true
|
|
88
|
+
},
|
|
89
|
+
"hair_styling_habits": {
|
|
90
|
+
"type": "STRING",
|
|
91
|
+
"nullable": true
|
|
92
|
+
},
|
|
93
|
+
"product_preferences_brands": {
|
|
94
|
+
"type": "ARRAY",
|
|
95
|
+
"items": {
|
|
96
|
+
"type": "STRING"
|
|
97
|
+
},
|
|
98
|
+
"nullable": true
|
|
99
|
+
},
|
|
100
|
+
"product_preferences_ingredients": {
|
|
101
|
+
"type": "STRING",
|
|
102
|
+
"nullable": true
|
|
103
|
+
},
|
|
104
|
+
"journey_stage_intent": {
|
|
105
|
+
"type": "STRING",
|
|
106
|
+
"nullable": true
|
|
107
|
+
},
|
|
108
|
+
"damage_level_self_reported": {
|
|
109
|
+
"type": "STRING",
|
|
110
|
+
"nullable": true
|
|
111
|
+
},
|
|
112
|
+
"experimenting_interest": {
|
|
113
|
+
"type": "BOOLEAN",
|
|
114
|
+
"nullable": true
|
|
115
|
+
},
|
|
116
|
+
"boredom_expression": {
|
|
117
|
+
"type": "BOOLEAN",
|
|
118
|
+
"nullable": true
|
|
119
|
+
},
|
|
120
|
+
"confidence_level_inferred": {
|
|
121
|
+
"type": "STRING",
|
|
122
|
+
"nullable": true
|
|
123
|
+
},
|
|
124
|
+
"desperation_level_inferred": {
|
|
125
|
+
"type": "STRING",
|
|
126
|
+
"nullable": true
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"nullable": true
|
|
130
|
+
},
|
|
131
|
+
"hair_issue_extractions": {
|
|
132
|
+
"type": "OBJECT",
|
|
133
|
+
"properties": {
|
|
134
|
+
"hair_issues_reported": {
|
|
135
|
+
"type": "ARRAY",
|
|
136
|
+
"items": {
|
|
137
|
+
"type": "STRING"
|
|
138
|
+
},
|
|
139
|
+
"nullable": true
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"nullable": true
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
};
|
|
9
148
|
|
|
10
149
|
|
|
11
150
|
const processBotResponse = (botResponse) => {
|
|
File without changes
|