@@ -68,6 +68,13 @@ class Avatar extends EventEmitter {
68
68
: this . activeBot . bot_id
69
69
return this
70
70
}
71
+ /**
72
+ * Add a conversation to session memory.
73
+ * @param {Conversation } conversation - The conversation object.
74
+ */
75
+ addConversation ( conversation ) {
76
+ this . #conversations. push ( conversation )
77
+ }
71
78
/**
72
79
* Get a bot.
73
80
* @public
@@ -185,7 +192,6 @@ class Avatar extends EventEmitter {
185
192
*/
186
193
async createConversation ( type = 'chat' , threadId , botId = this . activeBotId , saveToConversations = true ) {
187
194
const bot = await this . bot ( botId )
188
- console . log ( 'createConversation::bot' , botId , bot . bot_name , bot . type )
189
195
const thread = await this . #llmServices. thread ( threadId )
190
196
const conversation = new ( this . #factory. conversation ) ( { mbr_id : this . mbr_id , type, } , this . #factory, thread , botId )
191
197
bot . thread_id = conversation . thread_id
@@ -197,7 +203,7 @@ class Avatar extends EventEmitter {
197
203
thread_id,
198
204
} )
199
205
if ( saveToConversations )
200
- this . #conversations . push ( conversation )
206
+ this . addConversation ( conversation )
201
207
return conversation
202
208
}
203
209
/**
@@ -1125,7 +1131,7 @@ class Q extends Avatar {
1125
1131
throw new Error ( 'factory parameter must be an instance of MyLifeFactory' )
1126
1132
super ( factory , llmServices )
1127
1133
this . #factory = factory
1128
- this . llmServices = llmServices
1134
+ this . # llmServices = llmServices
1129
1135
}
1130
1136
/* overloaded methods */
1131
1137
/**
@@ -1147,14 +1153,30 @@ class Q extends Avatar {
1147
1153
?? this . activeBot . bot_id
1148
1154
conversation = await this . createConversation ( 'system' , undefined , activeBotId , true ) // pushes to this.#conversations in Avatar
1149
1155
threadId = conversation . thread_id
1150
- console . log ( 'chatRequest::NEW-CONVERSATION' , this . conversations , threadId )
1151
1156
}
1152
1157
if ( this . isValidating ) // trigger confirmation until session (or vld) ends
1153
1158
chatMessage = `CONFIRM REGISTRATION PHASE: registrationId=${ this . registrationId } \n${ chatMessage } `
1154
1159
if ( this . isCreatingAccount )
1155
1160
chatMessage = `CREATE ACCOUNT PHASE: ${ chatMessage } `
1156
1161
return super . chatRequest ( activeBotId , threadId , chatMessage , conversation , processStartTime )
1157
1162
}
1163
+ /**
1164
+ * Create a new conversation.
1165
+ * @async
1166
+ * @public
1167
+ * @param {string } type - Type of conversation: chat, experience, dialog, inter-system, etc.; defaults to `chat`.
1168
+ * @param {string } threadId - The openai thread id.
1169
+ * @param {string } botId - The bot id.
1170
+ * @param {boolean } saveToConversations - Whether to save the conversation to local memory; certain system and memory actions will be saved in their own threads.
1171
+ * @returns {Conversation } - The conversation object.
1172
+ */
1173
+ async createConversation ( type = 'system' , botId = this . activeBotId , saveToConversations = true ) {
1174
+ const thread = await this . #llmServices. thread ( undefined )
1175
+ const conversation = new ( this . #factory. conversation ) ( { mbr_id : this . mbr_id , type, } , this . #factory, thread , botId )
1176
+ if ( saveToConversations )
1177
+ this . addConversation ( conversation )
1178
+ return conversation
1179
+ }
1158
1180
/* public methods */
1159
1181
/**
1160
1182
* Add a member to the hosted members list.
0 commit comments