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

382 version 0024 updates (#403) #404

Merged
merged 1 commit into from
Oct 8, 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
88 changes: 43 additions & 45 deletions inc/js/globals.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,134 +4,132 @@ import { Guid } from 'js-guid' // usage = Guid.newGuid().toString()
/* constants */
const mAiJsFunctions = {
changeTitle: {
description: 'Change the title of a memory summary in the database for an itemId',
name: 'changeTitle',
description: 'Change the title of a summary in the database for an itemId',
strict: true,
parameters: {
type: 'object',
properties: {
itemId: {
description: 'itemId of memory item to update',
format: 'uuid',
description: 'itemId to update',
type: 'string'
},
title: {
description: 'The new title for the summary',
maxLength: 256,
type: 'string'
}
},
additionalProperties: false,
required: [
'itemId',
'title'
]
}
},
entrySummary: {
description: 'Generate a JOURNAL ENTRY `entry` summary with keywords and other critical data elements.',
description: 'Generate `entry` summary with keywords and other critical data elements.',
name: 'entrySummary',
strict: true,
parameters: {
type: 'object',
properties: {
content: {
description: 'concatenated raw text content of member input for JOURNAL ENTRY.',
description: 'complete concatenated raw text content of member input(s) for this `entry`',
type: 'string'
},
keywords: {
description: 'Keywords most relevant to JOURNAL ENTRY.',
description: 'Keywords most relevant to `entry`.',
items: {
description: 'Keyword (single word or short phrase) to be used in JOURNAL ENTRY summary.',
maxLength: 64,
description: 'Keyword (single word or short phrase) to be used in `entry` summary',
type: 'string'
},
maxItems: 12,
minItems: 3,
type: 'array'
},
mood: {
description: 'Record member mood for day (or entry) in brief as ascertained from content of JOURNAL ENTRY.',
maxLength: 256,
description: 'Record member mood for day (or entry) in brief as ascertained from content of `entry`',
type: 'string'
},
relationships: {
description: 'Record individuals (or pets) mentioned in this `entry`.',
description: 'Record individuals (or pets) mentioned in this `entry`',
type: 'array',
items: {
description: 'A name of relational individual/pet to the `entry` content.',
description: 'A name of relational individual/pet to the `entry` content',
type: 'string'
},
maxItems: 24
}
},
summary: {
description: 'Generate a JOURNAL ENTRY summary from input.',
maxLength: 20480,
description: 'Generate `entry` summary from member input',
type: 'string'
},
title: {
description: 'Generate display Title of the JOURNAL ENTRY.',
maxLength: 256,
description: 'Generate display Title of the `entry`',
type: 'string'
}
},
additionalProperties: false,
required: [
'content',
'keywords',
'summary',
'title'
'content',
'keywords',
'mood',
'relationships',
'summary',
'title'
]
}
},
getSummary: {
description: "Gets a story summary by itemId",
name: "getSummary",
strict: true,
parameters: {
type: "object",
properties: {
itemId: {
description: "Id of summary to retrieve",
format: "uuid",
type: "string"
}
},
additionalProperties: false,
required: [
"itemId"
]
}
},
obscure: {
description: "Obscures a summary so that no human names are present.",
description: "Obscures a summary so that no human names are present",
name: "obscure",
strict: true,
parameters: {
type: "object",
properties: {
itemId: {
description: "Id of summary to obscure",
format: "uuid",
type: "string"
}
},
additionalProperties: false,
required: [
"itemId"
]
}
},
storySummary: {
description: 'Generate a complete multi-paragraph STORY summary with keywords and other critical data elements.',
description: 'Generate a complete `story` summary with metadata elements',
name: 'storySummary',
strict: true,
parameters: {
type: 'object',
properties: {
keywords: {
description: 'Keywords most relevant to STORY.',
description: 'Keywords most relevant to `story`',
items: {
description: 'Keyword (single word or short phrase) to be used in STORY summary.',
maxLength: 64,
description: 'Keyword from `story` summary',
type: 'string'
},
maxItems: 12,
minItems: 3,
type: 'array'
},
phaseOfLife: {
description: 'Phase of life indicated in STORY.',
description: 'Phase of life indicated in `story`',
enum: [
'birth',
'childhood',
Expand All @@ -146,52 +144,52 @@ const mAiJsFunctions = {
'unknown',
'other'
],
maxLength: 64,
type: 'string'
},
relationships: {
description: 'MyLife Biographer Bot does its best to record individuals (or pets) mentioned in this `story`.',
description: 'Individuals (or pets) mentioned in `story`',
type: 'array',
items: {
description: 'A name of relational individual/pet to the `story` content.',
description: 'Name of individual or pet in `story`',
type: 'string'
},
maxItems: 24
}
},
summary: {
description: 'A complete multi-paragraph STORY summary composed from relevant user input.',
description: 'A complete `story` summary composed of all salient points from member input',
type: 'string'
},
title: {
description: 'Generate display Title of the STORY.',
maxLength: 256,
description: 'Generate display Title for `story`',
type: 'string'
}
},
additionalProperties: false,
required: [
'keywords',
'phaseOfLife',
"relationships",
'summary',
'title'
]
}
},
updateSummary: {
description: "Updates a story summary (in total) as referenced by itemId",
description: "Updates (overwrites) the summary referenced by itemId",
name: "updateSummary",
strict: true,
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"
}
},
additionalProperties: false,
required: [
"itemId",
"summary"
Expand Down
48 changes: 24 additions & 24 deletions inc/js/mylife-agent-factory.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const mExcludeProperties = {
definitions: true,
name: true
}
const mGeneralBotId = 'asst_piDEJKYjqvAZbLstjd6u0ZMb'
const mGeneralBotId = 'asst_yhX5mohHmZTXNIH55FX2BR1m'
const mLLMServices = new LLMServices()
const mMyLifeTeams = [
{
Expand Down Expand Up @@ -121,17 +121,7 @@ const mReservedJSWords = ['break', 'case', 'catch', 'class', 'const', 'continue'
const mShadows = [
{
being: 'shadow',
categories: ['world events'],
form: 'story',
id: 'e3701fa2-7cc8-4a47-bcda-a5b52d3d2e2f',
name: 'shadow_e3701fa2-7cc8-4a47-bcda-a5b52d3d2e2f',
proxy: '/shadow',
text: `What was happening in the world at the time?`,
type: 'agent',
},
{
being: 'shadow',
categories: ['personal', 'residence'],
categories: ['personal', 'location'],
form: 'story',
id: '0087b3ec-956e-436a-9272-eceed5e97ad0',
name: 'shadow_0087b3ec-956e-436a-9272-eceed5e97ad0',
Expand Down Expand Up @@ -171,15 +161,25 @@ const mShadows = [
},
{
being: 'shadow',
categories: ['observational', 'objectivity', 'reflection'],
categories: ['personal', 'observation'],
form: 'story',
id: '3bfebafb-7e44-4236-86c3-938e2f42fdd7',
name: 'shadow_e3701fa2-7cc8-4a47-bcda-a5b52d3d2e2f',
id: '6465905a-328e-4df1-8d3a-c37c3e05e227',
name: 'shadow_6465905a-328e-4df1-8d3a-c37c3e05e227',
proxy: '/shadow',
text: `What would a normal person have done in this situation?`,
type: 'agent',
text: `The mood of the scene was...`,
type: 'member',
},
] // **note**: members use shadows to help them add content to the summaries of their experiences, whereas agents return the requested content
{
being: 'shadow',
categories: ['personal', 'reflection', 'observation'],
form: 'story',
id: 'e61616c7-00f9-4c23-9394-3df7e98f71e0',
name: 'shadow_e61616c7-00f9-4c23-9394-3df7e98f71e0',
proxy: '/shadow',
text: `This was connected to larger themes in my life by ...`,
type: 'member',
},
]
const vmClassGenerator = vm.createContext({
exports: {},
console: console,
Expand Down Expand Up @@ -793,11 +793,12 @@ class AgentFactory extends BotFactory {
* @returns {object} - The story document from Cosmos
*/
async story(story){
const defaultForm = 'memory'
const defaultType = 'story'
const {
const {
assistantType='biographer',
being=defaultType,
form=defaultType,
form=defaultForm,
id=this.newGuid,
keywords=[],
mbr_id=(!this.isMyLife ? this.mbr_id : undefined),
Expand All @@ -807,8 +808,7 @@ class AgentFactory extends BotFactory {
} = story
if(!mbr_id) // only triggered if not MyLife server
throw new Error('mbr_id required for story summary')
let { name, } = story
name = name ?? `${ defaultType }_${ form }_${ title.substring(0,64) }_${ mbr_id }`
const { name=`${ being }_${ form }_${ title.substring(0,64) }_${ mbr_id }`, } = story
if(!summary?.length)
throw new Error('story summary required')
/* assign default keywords */
Expand Down Expand Up @@ -1283,7 +1283,6 @@ function mCreateBotInstructions(factory, bot){
/* compile instructions */
switch(type){
case 'diary':
case 'journaler':
instructions = purpose
+ preamble
+ prefix
Expand All @@ -1295,7 +1294,8 @@ function mCreateBotInstructions(factory, bot){
instructions = preamble
+ general
break
case 'personal-biographer':
case 'journaler':
case 'personal-biographer':
instructions = preamble
+ purpose
+ prefix
Expand Down
16 changes: 13 additions & 3 deletions inc/js/mylife-avatar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,17 @@ class Avatar extends EventEmitter {
if(shadowId)
messages = await this.shadow(shadowId, itemId, message)
else {
// @stub - one weakness in the chain might also be the fact that I am not including in instructions how to create integrated summary and left it primarily to the JSON description of function
if(itemId)
message = `update-memory-request: itemId=${ itemId }\n` + message
if(itemId){
// @todo - check if item exists in memory, fewer pings and inclusions overall
const { summary, } = await factory.item(itemId)
if(summary?.length){
message = `possible **update-summary-request**: itemId=${ itemId }\n`
+ `**member-update-request**:\n`
+ message
+ `\n**current-summary-in-database**:\n`
+ summary
}
}
messages = await mCallLLM(this.#llmServices, conversation, message, factory, this)
}
conversation.addMessages(messages)
Expand Down Expand Up @@ -636,6 +644,7 @@ class Avatar extends EventEmitter {
message = `update-memory-request: itemId=${ itemId }\n` + message
break
case 'agent':
/*
// @stub - develop additional form types, entry or idea for instance
const dob = new Date(this.#factory.dob)
const diff_ms = Date.now() - dob.getTime()
Expand All @@ -647,6 +656,7 @@ class Avatar extends EventEmitter {
thread_id: bot.thread_id,
}
break
*/
default:
break
}
Expand Down
Loading