Skip to content

Commit

Permalink
245 hotfix q threads (#246)
Browse files Browse the repository at this point in the history
* 231 version 0010 updates (#239) (#240)

* 20240604 @Mookse
- teams() route
- teams(teamId) returns a fully formed team from server with new bots (when instructions provided)

* 20240604 @Mookse
- fix bot-bar `setActiveBot`
- cosmetic

* 20240604 @Mookse
- fix duplicate team members return

* 20240604 @Mookse
- botBar reordered

* 20240605 @Mookse
- teams  must be active

* 20240605 @Mookse
- default mods

* 20240605 @Mookse
- create (non-custom) bot frontend
- diary updates

* 20240605 @Mookse
- imagining `share memory`

* 20240606 @Mookse
- story updates

* 20240606 @Mookse
- minor cosmetics

* 20240606 @Mookse
- fetchShadows()
- ignite shadow: member-version (wip)

* 20240607 @Mookse
- `shadow` initial endpoint

* 20240607 @Mookse
- add processingBotId to payload (so that frontend can determine if it should setActive)

* 20240607 @Mookse
- front-end receives message about updating from agent shadow

* 20240607 @Mookse
- shadow cosmetics

* 20240607 @Mookse
- biographer openai function definitions

* 20240607 @Mookse
- now _that's_ an error

* 20240607 @Mookse
- updateSummary()
**note**: wip as thread got stopped

* 20240608 @Mookse
- updates summary

* 20240608 @Mookse
- remove dataset after shadow triggered
- add `proxy` endpoint to shadow ideas

* 20240608 @Mookse
- `globals.getGPTJavascriptFunction`: `getSummary`, `updateSummary`
- `updateBotInstructions` route
- on setActiveBot checks versions and updates as needed

* 20240609 @Mookse
- cosmetic

* 20240609 @Mookse
stable wip
kicking off memory is correct, need tuning of instructions or alternate scene-stepwise motion, no problem
small error left in frontend for more testing but time to save

* 20240618 @Mookse
- cosmetic: file under "the right evocation can make all the difference"

* 20240618 @Mookse
- cosmetic in dribs and drabs

* 20240618 @Mookse
- frontend 'next' fix

* version 0011 updates (#244)

* 231 version 0010 updates (#239)

* 20240604 @Mookse
- teams() route
- teams(teamId) returns a fully formed team from server with new bots (when instructions provided)

* 20240604 @Mookse
- fix bot-bar `setActiveBot`
- cosmetic

* 20240604 @Mookse
- fix duplicate team members return

* 20240604 @Mookse
- botBar reordered

* 20240605 @Mookse
- teams  must be active

* 20240605 @Mookse
- default mods

* 20240605 @Mookse
- create (non-custom) bot frontend
- diary updates

* 20240605 @Mookse
- imagining `share memory`

* 20240606 @Mookse
- story updates

* 20240606 @Mookse
- minor cosmetics

* 20240606 @Mookse
- fetchShadows()
- ignite shadow: member-version (wip)

* 20240607 @Mookse
- `shadow` initial endpoint

* 20240607 @Mookse
- add processingBotId to payload (so that frontend can determine if it should setActive)

* 20240607 @Mookse
- front-end receives message about updating from agent shadow

* 20240607 @Mookse
- shadow cosmetics

* 20240607 @Mookse
- biographer openai function definitions

* 20240607 @Mookse
- now _that's_ an error

* 20240607 @Mookse
- updateSummary()
**note**: wip as thread got stopped

* 20240608 @Mookse
- updates summary

* 20240608 @Mookse
- remove dataset after shadow triggered
- add `proxy` endpoint to shadow ideas

* 20240608 @Mookse
- `globals.getGPTJavascriptFunction`: `getSummary`, `updateSummary`
- `updateBotInstructions` route
- on setActiveBot checks versions and updates as needed

* 20240609 @Mookse
- cosmetic

* 20240609 @Mookse
stable wip
kicking off memory is correct, need tuning of instructions or alternate scene-stepwise motion, no problem
small error left in frontend for more testing but time to save

* 20240618 @Mookse
- cosmetic: file under "the right evocation can make all the difference"

* 20240618 @Mookse
- cosmetic in dribs and drabs

* 20240618 @Mookse
- frontend 'next' fix

* 20240621 @Mookse
- redirect logged in members to `/members`

* 20240626 @Mookse
- registration -> createAccount with Q

* 20240626 @Mookse
- hostedMembers fix

* 20240626 @Mookse
- avatar document name fix

* 20240626 @Mookse
- instruction change

* 20240626 @Mookse
- page-loader

* 20240626 @Mookse
- special pages fix

---------

Signed-off-by: Erik Jespersen <42016062+Mookse@users.noreply.github.com>

* Version 0.0.11 (#243)

* 231 version 0010 updates (#239)

* 20240604 @Mookse
- teams() route
- teams(teamId) returns a fully formed team from server with new bots (when instructions provided)

* 20240604 @Mookse
- fix bot-bar `setActiveBot`
- cosmetic

* 20240604 @Mookse
- fix duplicate team members return

* 20240604 @Mookse
- botBar reordered

* 20240605 @Mookse
- teams  must be active

* 20240605 @Mookse
- default mods

* 20240605 @Mookse
- create (non-custom) bot frontend
- diary updates

* 20240605 @Mookse
- imagining `share memory`

* 20240606 @Mookse
- story updates

* 20240606 @Mookse
- minor cosmetics

* 20240606 @Mookse
- fetchShadows()
- ignite shadow: member-version (wip)

* 20240607 @Mookse
- `shadow` initial endpoint

* 20240607 @Mookse
- add processingBotId to payload (so that frontend can determine if it should setActive)

* 20240607 @Mookse
- front-end receives message about updating from agent shadow

* 20240607 @Mookse
- shadow cosmetics

* 20240607 @Mookse
- biographer openai function definitions

* 20240607 @Mookse
- now _that's_ an error

* 20240607 @Mookse
- updateSummary()
**note**: wip as thread got stopped

* 20240608 @Mookse
- updates summary

* 20240608 @Mookse
- remove dataset after shadow triggered
- add `proxy` endpoint to shadow ideas

* 20240608 @Mookse
- `globals.getGPTJavascriptFunction`: `getSummary`, `updateSummary`
- `updateBotInstructions` route
- on setActiveBot checks versions and updates as needed

* 20240609 @Mookse
- cosmetic

* 20240609 @Mookse
stable wip
kicking off memory is correct, need tuning of instructions or alternate scene-stepwise motion, no problem
small error left in frontend for more testing but time to save

* 20240618 @Mookse
- cosmetic: file under "the right evocation can make all the difference"

* 20240618 @Mookse
- cosmetic in dribs and drabs

* 20240618 @Mookse
- frontend 'next' fix

* 238 version 0011 updates (#242)

* 231 version 0010 updates (#239) (#240)

* 20240604 @Mookse
- teams() route
- teams(teamId) returns a fully formed team from server with new bots (when instructions provided)

* 20240604 @Mookse
- fix bot-bar `setActiveBot`
- cosmetic

* 20240604 @Mookse
- fix duplicate team members return

* 20240604 @Mookse
- botBar reordered

* 20240605 @Mookse
- teams  must be active

* 20240605 @Mookse
- default mods

* 20240605 @Mookse
- create (non-custom) bot frontend
- diary updates

* 20240605 @Mookse
- imagining `share memory`

* 20240606 @Mookse
- story updates

* 20240606 @Mookse
- minor cosmetics

* 20240606 @Mookse
- fetchShadows()
- ignite shadow: member-version (wip)

* 20240607 @Mookse
- `shadow` initial endpoint

* 20240607 @Mookse
- add processingBotId to payload (so that frontend can determine if it should setActive)

* 20240607 @Mookse
- front-end receives message about updating from agent shadow

* 20240607 @Mookse
- shadow cosmetics

* 20240607 @Mookse
- biographer openai function definitions

* 20240607 @Mookse
- now _that's_ an error

* 20240607 @Mookse
- updateSummary()
**note**: wip as thread got stopped

* 20240608 @Mookse
- updates summary

* 20240608 @Mookse
- remove dataset after shadow triggered
- add `proxy` endpoint to shadow ideas

* 20240608 @Mookse
- `globals.getGPTJavascriptFunction`: `getSummary`, `updateSummary`
- `updateBotInstructions` route
- on setActiveBot checks versions and updates as needed

* 20240609 @Mookse
- cosmetic

* 20240609 @Mookse
stable wip
kicking off memory is correct, need tuning of instructions or alternate scene-stepwise motion, no problem
small error left in frontend for more testing but time to save

* 20240618 @Mookse
- cosmetic: file under "the right evocation can make all the difference"

* 20240618 @Mookse
- cosmetic in dribs and drabs

* 20240618 @Mookse
- frontend 'next' fix

* 20240621 @Mookse
- redirect logged in members to `/members`

* 20240626 @Mookse
- registration -> createAccount with Q

* 20240626 @Mookse
- hostedMembers fix

* 20240626 @Mookse
- avatar document name fix

* 20240626 @Mookse
- instruction change

* 20240626 @Mookse
- page-loader

* 20240626 @Mookse
- special pages fix

---------

Signed-off-by: Erik Jespersen <42016062+Mookse@users.noreply.github.com>

---------

Signed-off-by: Erik Jespersen <42016062+Mookse@users.noreply.github.com>

* 20240629 @Mookse
unstable wip
- Q-threaded correctly
ERROR: login fault:
Cannot read properties of undefined (reading 'on')
    at Member.attachListeners (file:///C:/Code/MyLife/mylife-maht/inc/js/core.mjs:32:15)
    Error: avatar id required to create bot
    at mCreateBot (file:///C:/Code/MyLife/mylife-maht/inc/js/mylife-agent-factory.mjs:1223:9)

* 20240629 @Mookse
- threaded fix stable

* 20240629 @Mookse
- pipeline fix for reliveMemory

---------

Signed-off-by: Erik Jespersen <42016062+Mookse@users.noreply.github.com>
  • Loading branch information
Mookse authored Jun 30, 2024
1 parent cc777a9 commit 4c567f3
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 159 deletions.
6 changes: 3 additions & 3 deletions inc/js/agents/system/evolution-assistant.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export class EvolutionAssistant extends EventEmitter {
#phase // create, init, develop, mature, maintain, retire
/**
* Constructor Function for Evolution Assistant.
* @param {Avatar} _avatar
* @param {Avatar} avatar
*/
constructor(_avatar) { // receive parent object ref
constructor(avatar) { // receive parent object ref
super()
this.#phase = _defaultPhase // overkill but fun
this.#avatar = _avatar
this.#avatar = avatar
this.#advancePhase() // phase complete
}
// public functions
Expand Down
45 changes: 17 additions & 28 deletions inc/js/core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,22 @@ import initRouter from './routes.mjs'
class Member extends EventEmitter {
#avatar
#factory
constructor(_Factory){
constructor(factory){
super()
this.#factory = _Factory // member will need factory after avatar is created for datacore evolutionary agent, et likely al.
/* assign factory/avatar listeners */
this.attachListeners()
this.#factory = factory
}
/**
* Initializes `this.#avatar` and returns `this`. The Avatar will thence be primary point of interaction with Session and Server. Only upon dissolution of Avatar [sessionEnd] is triggered an internal `this` evolution evaluation based on upon the conduct of Avatar.
* @async
* @public
* @param {Q} avatar - Avatar object to initialize, when infused from child instance
* @returns {Promise} Promise resolves to this Member class instantiation
*/
async init(){
this.#avatar = await this.factory.getAvatar()
async init(avatar){
this.#avatar = avatar
?? await this.factory.getAvatar()
return this
}
/**
* Attaches listeners to Member class instantiation
* @publc must remain public in order to be overridden
* @returns {void} returns nothing
*/
attachListeners(){
this.factory.on('avatar-init-end',(_avatar,bytes)=>{
console.log(chalk.grey(`Member::init::avatar-init-end|memory-size=${bytes}b`))
})
}
// getter/setter functions
get abilities(){
return this.core.abilities
Expand Down Expand Up @@ -177,16 +167,10 @@ class Organization extends Member { // form=organization
super(_Factory)
}
/* public functions */
async init(){
return await super.init()
}
/**
* `Member` Overload
* @publc must remain public in order to be overridden
* @returns {void} returns nothing
*/
attachListeners(){
// intentionally empty
async init(avatar){
if(!avatar)
throw new Error('avatar parameter currently required for Organization imprint')
return await super.init(avatar)
}
/* getters/setters */
/**
Expand Down Expand Up @@ -245,10 +229,15 @@ class Organization extends Member { // form=organization
return this.core.vision
}
}
class MyLife extends Organization { // form=server
constructor(factory){ // no session presumed to exist
class MyLife extends Organization { // form=server
#avatar // MyLife's private class avatar, _same_ object reference as Member Class's `#avatar`
constructor(factory){ // no session presumed to exist
super(factory)
}
async init(){
this.#avatar = await this.factory.getAvatar()
return await super.init(this.#avatar)
}
/**
* Retrieves all public experiences (i.e., owned by MyLife).
* @returns {Object[]} - An array of the currently available public experiences.
Expand Down
25 changes: 18 additions & 7 deletions inc/js/factory-class-extenders/class-extenders.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ function extendClass_conversation(originClass, referencesObject) {
this.#factory = factory
this.#thread = thread
this.#botId = botId
this.form = this.form
?? 'system'
this.name = `conversation_${this.#factory.mbr_id}_${thread.thread_id}`
this.type = this.type ?? 'chat'
this.type = this.type
?? 'chat'
}
/* public functions */
/**
Expand Down Expand Up @@ -203,12 +206,20 @@ function extendClass_conversation(originClass, referencesObject) {
return this
}
// public getters/setters
get bot_id(){
return this.#botId
}
/**
* Get the id {Guid} of the conversation's bot.
* @getter
* @returns {Guid} - The bot id.
*/
get botId(){
return this.bot_id
return this.#botId
}
/**
* Set the id {Guid} of the conversation's bot.
* @setter
* @param {Guid} botId - The bot id.
* @returns {void}
*/
set botId(botId){
this.#botId = botId
}
Expand Down Expand Up @@ -238,10 +249,10 @@ function extendClass_conversation(originClass, referencesObject) {
return this.#thread
}
get thread_id(){
return this.threadId
return this.thread.id
}
get threadId(){
return this.thread.id
return this.thread_id
}
}
return Conversation
Expand Down
9 changes: 7 additions & 2 deletions inc/js/functions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,18 @@ async function challenge(ctx){
ctx.throw(400, `challenge request requires member id`)
ctx.body = await ctx.session.MemberSession.challengeAccess(mid, passphrase)
}
/**
* Chat with the member's avatar.
* @todo - deprecate threadId in favor of thread_id
* @param {Koa} ctx - Koa Context object
*/
async function chat(ctx){
const { botId, message, role, threadId, } = ctx.request.body
const { botId, message, role, threadId, thread_id, } = ctx.request.body
?? {} /* body nodes sent by fe */
if(!message?.length)
ctx.throw(400, 'missing `message` content')
const { avatar, } = ctx.state
const response = await avatar.chatRequest(botId, threadId, message)
const response = await avatar.chatRequest(botId, thread_id ?? threadId, message)
ctx.body = response
}
async function collections(ctx){
Expand Down
11 changes: 10 additions & 1 deletion inc/js/mylife-agent-factory.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import EventEmitter from 'events'
import vm from 'vm'
import util from 'util'
import { Guid } from 'js-guid' // usage = Guid.newGuid().toString()
import Avatar from './mylife-avatar.mjs'
import { Avatar, Q, } from './mylife-avatar.mjs'
import Dataservices from './mylife-data-service.js'
import { Member, MyLife } from './core.mjs'
import {
Expand Down Expand Up @@ -1041,6 +1041,15 @@ class MyLifeFactory extends AgentFactory {
deleteItem(){
throw new Error('MyLife server cannot delete items')
}
/**
* Retrieves member's Avatar data and creates singleton instance.
* @returns {Avatar} - The Avatar instance.
*/
async getAvatar(){
const avatar = await ( new Q(this, this.#llmServices) )
.init()
return avatar
}
/**
* Returns Array of hosted members based on validation requirements.
* @param {Array} validations - Array of validation strings to filter membership.
Expand Down
Loading

0 comments on commit 4c567f3

Please sign in to comment.