Skip to content

Commit

Permalink
231 version 0010 updates (#239) (#240)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Mookse authored Jun 19, 2024
1 parent b88af06 commit 487ff9f
Show file tree
Hide file tree
Showing 17 changed files with 1,522 additions and 371 deletions.
4 changes: 2 additions & 2 deletions inc/js/factory-class-extenders/class-extenders.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ function extendClass_conversation(originClass, referencesObject) {
get botId(){
return this.bot_id
}
set botId(_botId){
this.#botId = _botId
set botId(botId){
this.#botId = botId
}
get isSaved(){
return this.#saved
Expand Down
63 changes: 59 additions & 4 deletions inc/js/functions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function activateBot(ctx){
}
async function alerts(ctx){
// @todo: put into ctx the _type_ of alert to return, system use dataservices, member use personal
const { MemberSession, } = ctx.state
if(ctx.params?.aid){ // specific system alert
ctx.body = await ctx.state.MemberSession.alert(ctx.params.aid)
} else { // all system alerts
Expand Down Expand Up @@ -100,17 +101,18 @@ async function collections(ctx){
ctx.body = await avatar.collections(ctx.params.type)
}
async function createBot(ctx){
const { team, type, } = ctx.request.body
const { teamId, type, } = ctx.request.body
const { avatar, } = ctx.state
const bot = { type, } // `type` only requirement to create a known, MyLife-typed bot
const bot = { teams: [], type, } // `type` only requirement to create a known, MyLife-typed bot
if(teamId?.length)
bot.teams.push(teamId)
ctx.body = await avatar.createBot(bot)
}
/**
* Delete an item from collection via the member's avatar.
* @async
* @public
* @param {object} ctx - Koa Context object
* @param {object} ctx - Koa Context object
* @returns {boolean} - Under `ctx.body`, status of deletion.
*/
async function deleteItem(ctx){
Expand Down Expand Up @@ -219,6 +221,24 @@ async function privacyPolicy(ctx){
ctx.state.subtitle = `Effective Date: 2024-01-01`
await ctx.render('privacy-policy') // privacy-policy
}
async function shadow(ctx){
const { avatar, } = ctx.state
const { active=true, botId, itemId, message, role, threadId, shadowId, title, } = ctx.request.body // necessary to flip active bot, or just presume to use the creator of the shadow?
if(!itemId?.length)
ctx.throw(400, `missing item id`)
if(!active) // @stub - redirect to normal chat?
ctx.throw(400, `shadow must be active`)
ctx.body = await avatar.shadow(shadowId, itemId, title, message)
}
/**
* Gets the list of shadows.
* @returns {Object[]} - Array of shadow objects.
*/
async function shadows(ctx){
const { avatar, } = ctx.state
const response = await avatar.shadows()
ctx.body = response
}
async function signup(ctx) {
const { avatarName, email, humanName, type='newsletter', } = ctx.request.body
const signupPacket = {
Expand Down Expand Up @@ -272,6 +292,36 @@ async function summarize(ctx){
throw new Error('Only logged in members may summarize text')
ctx.body = await avatar.summarize(fileId, fileName)
}
/**
* Get a specified team, its details and bots, by id for the member.
* @param {Koa} ctx - Koa Context object
* @returns {object} - Team object
*/
async function team(ctx){
const { tid, } = ctx.params
if(!tid?.length)
ctx.throw(400, `missing team id`)
const { avatar, } = ctx.state
ctx.body = await avatar.team(tid)
}
/**
* Get a list of available teams and their default details.
* @param {Koa} ctx - Koa Context object.
* @returns {Object[]} - List of team objects.
*/
function teams(ctx){
const { avatar, } = ctx.state
ctx.body = avatar.teams()
}
async function updateBotInstructions(ctx){
const { botId, } = ctx.request.body
const { avatar, } = ctx.state
let success = false
const bot = await avatar.updateBot(botId, { instructions: true, model: true, tools: true, })
if(bot)
success = true
ctx.body = { bot, success, }
}
/**
* Proxy for uploading files to the API.
* @param {Koa} ctx - Koa Context object
Expand Down Expand Up @@ -307,7 +357,12 @@ export {
members,
passphraseReset,
privacyPolicy,
shadow,
shadows,
signup,
summarize,
team,
teams,
updateBotInstructions,
upload,
}
39 changes: 39 additions & 0 deletions inc/js/globals.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ const mAiJsFunctions = {
]
}
},
getSummary: {
description: "Gets a story summary by itemId",
name: "getSummary",
parameters: {
type: "object",
properties: {
itemId: {
description: "Id of summary to retrieve",
format: "uuid",
type: "string"
}
},
required: [
"itemId"
]
}
},
storySummary: {
description: 'Generate a STORY summary with keywords and other critical data elements.',
name: 'storySummary',
Expand Down Expand Up @@ -120,6 +137,28 @@ const mAiJsFunctions = {
]
}
},
updateSummary: {
description: "Updates a story summary (in total) as referenced by itemId",
name: "updateSummary",
parameters: {
type: "object",
properties: {
itemId: {
description: "Id of summary to update",
format: "uuid",
type: "string"
},
summary: {
description: "The new updated and complete summary",
type: "string"
}
},
required: [
"itemId",
"title"
]
}
},
}
const mEmailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/ // regex for email validation
const mGuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i // regex for GUID validation
Expand Down
51 changes: 51 additions & 0 deletions inc/js/memory-functions.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* imports */
import {
activateBot,
interfaceMode, // @stub - deprecate?
upload,
} from './functions.mjs'
/* module export functions */
async function collectMemory(ctx){
// @todo - implement memory collection
}
async function improveMemory(ctx){
const { iid } = ctx.params
const { Globals, MyLife, } = ctx
const { avatar, } = ctx.state
if(!Globals.isValidGuid(iid))
return ctx.throw(400, 'Invalid Item ID')
ctx.body = await avatar.reliveMemory(iid)
}
/**
* Reliving a memory is a unique MyLife `experience` that allows a user to relive a memory from any vantage they choose. The bot by default will:
* @param {Koa} ctx - Koa context object.
* @returns {Promise<object>} - livingMemory engagement object (i.e., includes frontend parameters for engagement as per instructions for included `portrayMemory` function in LLM-speak)
*/
async function reliveMemory(ctx){
const { iid } = ctx.params
const { Globals, MyLife, } = ctx
const { avatar, } = ctx.state
if(!Globals.isValidGuid(iid))
return ctx.throw(400, 'Invalid Item ID')
ctx.body = await avatar.reliveMemory(iid)
}
/**
* Living a shared memory is a unique MyLife `experience` that allows a user to relive a memory from any vantage the "author/narrator" chooses. In fact, much of the triggers and dials on how to present the experience of a shared memory is available and controlled by the member, and contained and executed by the biographer bot for the moment through this func6ion. Ultimately the default bot could be switched, in which case, information retrieval may need ways to contextualize pushbacks (floabt, meaning people asking questions about the memory that are not answerable by the summar itself, and 1) _may_ be answerable by another bot, such as biogbot, or 2) is positioned as a piece of data to "improve" or flesh out memories... Remember on this day in 2011, what did you have to eat on the boardwalk? Enquiring minds want to know!)
* @param {Koa} ctx - Koa context object.
* @returns {Promise<object>} - livingMemory object.
*/
async function livingMemory(ctx){
const { iid } = ctx.params
const { Globals, MyLife, } = ctx
const { avatar, } = ctx.state
if(!Globals.isValidGuid(iid))
return ctx.throw(400, 'Invalid Item ID')
ctx.body = await avatar.livingMemory(iid)
}
/* exports */
export {
collectMemory,
improveMemory,
reliveMemory,
livingMemory,
}
Loading

0 comments on commit 487ff9f

Please sign in to comment.