Skip to content

Commit

Permalink
20240717 @Mookse
Browse files Browse the repository at this point in the history
- avatar update
  • Loading branch information
Mookse committed Jul 17, 2024
1 parent 2923766 commit 9842aae
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions inc/js/mylife-avatar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ class Avatar extends EventEmitter {
: this.activeBot.bot_id
return this
}
/**
* Add a conversation to session memory.
* @param {Conversation} conversation - The conversation object.
*/
addConversation(conversation){
this.#conversations.push(conversation)
}
/**
* Get a bot.
* @public
Expand Down Expand Up @@ -185,7 +192,6 @@ class Avatar extends EventEmitter {
*/
async createConversation(type='chat', threadId, botId=this.activeBotId, saveToConversations=true){
const bot = await this.bot(botId)
console.log('createConversation::bot', botId, bot.bot_name, bot.type)
const thread = await this.#llmServices.thread(threadId)
const conversation = new (this.#factory.conversation)({ mbr_id: this.mbr_id, type, }, this.#factory, thread, botId)
bot.thread_id = conversation.thread_id
Expand All @@ -197,7 +203,7 @@ class Avatar extends EventEmitter {
thread_id,
})
if(saveToConversations)
this.#conversations.push(conversation)
this.addConversation(conversation)
return conversation
}
/**
Expand Down Expand Up @@ -1125,7 +1131,7 @@ class Q extends Avatar {
throw new Error('factory parameter must be an instance of MyLifeFactory')
super(factory, llmServices)
this.#factory = factory
this.llmServices = llmServices
this.#llmServices = llmServices
}
/* overloaded methods */
/**
Expand All @@ -1147,14 +1153,30 @@ class Q extends Avatar {
?? this.activeBot.bot_id
conversation = await this.createConversation('system', undefined, activeBotId, true) // pushes to this.#conversations in Avatar
threadId = conversation.thread_id
console.log('chatRequest::NEW-CONVERSATION', this.conversations, threadId)
}
if(this.isValidating) // trigger confirmation until session (or vld) ends
chatMessage = `CONFIRM REGISTRATION PHASE: registrationId=${ this.registrationId }\n${ chatMessage }`
if(this.isCreatingAccount)
chatMessage = `CREATE ACCOUNT PHASE: ${ chatMessage }`
return super.chatRequest(activeBotId, threadId, chatMessage, conversation, processStartTime)
}
/**
* Create a new conversation.
* @async
* @public
* @param {string} type - Type of conversation: chat, experience, dialog, inter-system, etc.; defaults to `chat`.
* @param {string} threadId - The openai thread id.
* @param {string} botId - The bot id.
* @param {boolean} saveToConversations - Whether to save the conversation to local memory; certain system and memory actions will be saved in their own threads.
* @returns {Conversation} - The conversation object.
*/
async createConversation(type='system', botId=this.activeBotId, saveToConversations=true){
const thread = await this.#llmServices.thread(undefined)
const conversation = new (this.#factory.conversation)({ mbr_id: this.mbr_id, type, }, this.#factory, thread, botId)
if(saveToConversations)
this.addConversation(conversation)
return conversation
}
/* public methods */
/**
* Add a member to the hosted members list.
Expand Down

0 comments on commit 9842aae

Please sign in to comment.