Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.0.11 #243

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion inc/js/core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Member extends EventEmitter {
*/
async init(){
this.#avatar = await this.factory.getAvatar()
// @todo: add consent and evolution agents for self-evolution from avatar data
return this
}
/**
Expand Down
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
67 changes: 62 additions & 5 deletions inc/js/functions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
/* module export functions */
async function about(ctx){
ctx.state.title = `About MyLife`
await ctx.render('about') // about
await ctx.render('about') // about
}
/**
* Activate a bot for the member
Expand All @@ -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 @@ -160,6 +162,8 @@ async function help(ctx){
* @param {object} ctx - Koa Context object
*/
async function index(ctx){
if(!ctx.state?.locked ?? true)
ctx.redirect(`/members`) // Redirect to /members if authorized
await ctx.render('index')
}
/**
Expand Down Expand Up @@ -219,6 +223,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 +294,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 +359,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,
}
9 changes: 3 additions & 6 deletions inc/js/menu.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ class Menu {
}
#setMenu(_Agent){
return [
// { display: `home`, route: '/', icon: 'home' },
{ display: `about`, route: '/about', icon: 'about' },
{ display: `walkthrough`, route: 'https://medium.com/@ewbj/mylife-we-save-your-life-480a80956a24', icon: 'gear' },
{ display: `donate`, route: 'https://gofund.me/65013d6e', icon: 'donate' },
// { display: `membership`, route: '/members', icon: 'membership' },
// { display: `register`, route: '/register', icon: 'register' },
{ display: `about`, route: '/about', icon: 'about', },
{ display: `walkthrough`, route: 'https://medium.com/@ewbj/mylife-we-save-your-life-480a80956a24', icon: 'gear', },
{ display: `donate`, route: 'https://gofund.me/65013d6e', icon: 'donate', },
]
}
}
Expand Down
Loading