Skip to content

365 version 0022 updates (#371) #373

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

Merged
merged 1 commit into from
Sep 24, 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
16 changes: 11 additions & 5 deletions inc/js/mylife-llm-services.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,12 @@ async function mRunFunctions(openai, run, factory, avatar){ // add avatar ref
action = `journal entry failed to save, notify member and continue on for now`
}
confirmation.output = JSON.stringify({ action, success, })
console.log('mRunFunctions()::entrySummary', toolArguments, confirmation.output)
return confirmation
case 'getsummary':
case 'get_summary':
case 'get summary':
let { summary, } = item ?? {}
let { summary, title: _getSummaryTitle, } = item ?? {}
if(!summary?.length){
action = `error getting summary for itemId: ${ itemId ?? 'missing itemId' } - halt any further processing and instead ask user to paste summary into chat and you will continue from there to incorporate their message.`
summary = 'no summary found for itemId'
Expand All @@ -423,16 +424,16 @@ async function mRunFunctions(openai, run, factory, avatar){ // add avatar ref
success = true
}
confirmation.output = JSON.stringify({ action, itemId, success, summary, })
console.log('mRunFunctions()::getSummary::confirmation', itemId)
console.log('mRunFunctions()::getsummary', itemId, _getSummaryTitle)
return confirmation
case 'hijackattempt':
case 'hijack_attempt':
case 'hijack-attempt':
case 'hijack attempt':
console.log('mRunFunctions()::hijack_attempt', toolArguments)
action = 'attempt noted in system and user ejected; greet per normal as first time new user'
success = true
confirmation.output = JSON.stringify({ action, success, })
console.log('mRunFunctions()::hijack_attempt', toolArguments)
return confirmation
case 'registercandidate':
case 'register_candidate':
Expand All @@ -454,6 +455,7 @@ async function mRunFunctions(openai, run, factory, avatar){ // add avatar ref
case 'story-summary':
case 'story_summary':
case 'story summary':
console.log('mRunFunctions()::storySummary', toolArguments)
const story = await factory.story(toolArguments)
if(story){
const { keywords, phaseOfLife, } = story
Expand All @@ -465,11 +467,9 @@ async function mRunFunctions(openai, run, factory, avatar){ // add avatar ref
switch(true){
case phaseOfLife?.length:
action = `ask about another encounter during member's ${ phaseOfLife }`
console.log('mRunFunctions()::story-summary::phaseOfLife', phaseOfLife)
break
case interests?.length:
action = `ask about a different interest from: ${ interests }`
console.log('mRunFunctions()::story-summary::interests', interests)
break
default:
action = 'ask about another event in member\'s life'
Expand All @@ -478,6 +478,7 @@ async function mRunFunctions(openai, run, factory, avatar){ // add avatar ref
success = true
} // error cascades
confirmation.output = JSON.stringify({ action, success, })
console.log('mRunFunctions()::storySummary()::end', story.id)
return confirmation
case 'updatesummary':
case 'update_summary':
Expand All @@ -486,6 +487,11 @@ async function mRunFunctions(openai, run, factory, avatar){ // add avatar ref
const { summary: updatedSummary, } = toolArguments
// remove await once confirmed updates are connected
await factory.updateItem({ id: itemId, summary: updatedSummary, })
avatar.frontendInstruction = {
command: 'updateItemSummary',
itemId,
summary: updatedSummary,
}
action=`confirm success and present updated summary to member`
success = true
confirmation.output = JSON.stringify({ action, success, })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"purpose": "My goal is to specialize in creating, updating, and presenting accurate biographical content for MyLife member <-mFN-> based on our interactions.\n",
"references": [
{
"default": "as yet unknown, please evince at start of process",
"default": "ERROR loading preferences, gather interests directly from member",
"description": "interests are h2 (##) in prefix so that they do not get lost in context window shortening",
"insert": "## interests",
"method": "append-hard",
Expand Down Expand Up @@ -46,5 +46,6 @@
"name": "instructions-personal-biographer-bot",
"purpose": "To be a biographer bot for requesting member",
"type": "personal-biographer",
"$comments": "20240919 updated error return without version update",
"version": 1.4
}
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import chalk from 'chalk'
/* local service imports */
import MyLife from './inc/js/mylife-agent-factory.mjs'
/** variables **/
const version = '0.0.21'
const version = '0.0.22'
const app = new Koa()
const port = process.env.PORT ?? '3000'
const __filename = fileURLToPath(import.meta.url)
Expand Down
21 changes: 11 additions & 10 deletions views/assets/css/bots.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,20 @@
overflow-x: hidden;
overflow-y: auto; /* Enable vertical scrolling */
}
/* Styles the scrollbar itself */
.bot-options::-webkit-scrollbar,
.checkbox-group::-webkit-scrollbar {
width: 6px; /* Adjust the width of the scrollbar */
}
/* Styles the track of the scrollbar */
.bot-options::-webkit-scrollbar-track,
.checkbox-group::-webkit-scrollbar-track {
background: rgba(0, 0, 0, 0.1); /* Color of the track */
border-radius: 10px; /* Optional: adds rounded corners to the track */
}
/* Styles the handle (thumb) of the scrollbar */
.bot-options::-webkit-scrollbar-thumb,
.checkbox-group::-webkit-scrollbar-thumb {
background: rgba(232, 226, 183, .5); /* Color of the thumb */
border-radius: 10px; /* Optional: adds rounded corners to the thumb */
}
/* Changes the color of the thumb when hovered over or clicked */
.bot-options::-webkit-scrollbar-thumb:hover,
.checkbox-group::-webkit-scrollbar-thumb:hover {
background: rgba(214, 198, 75, 0.5); /* Darker shade on hover */
Expand Down Expand Up @@ -238,6 +234,15 @@
margin-right: 0.8rem;
max-width: 50%;
}
.mylife-widget.bots {
flex-direction: column;
justify-content: flex-start;
max-width: 100%;
}
.publicity-toggle-view-icon {
cursor: default;
font-size: 1.25rem;
}
.ticker {
background: radial-gradient(at top left, darkgray, black); /* Radial gradient background */
border: thin solid rgba(255, 255, 255, 0.5); /* Thin white border with 50% opacity */
Expand All @@ -261,11 +266,6 @@
animation: none;
padding: 0;
}
.mylife-widget.bots {
flex-direction: column;
justify-content: flex-start;
max-width: 100%;
}
/* bot-collections */
.collection {
background-color: royalblue;
Expand Down Expand Up @@ -440,7 +440,8 @@
justify-content: space-between;
width: 100%;
}
.passphrase-reset {
.passphrase-reset,
.tutorial-button {
width: 100%;
}
/* publicity sliders */
Expand Down
10 changes: 8 additions & 2 deletions views/assets/html/_bots.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
<span id="personal-avatar-publicity-slider" class="publicity-slider"></span>
<label id="personal-avatar-publicity-public-label" class="publicity-label" data-checked-value="true">Public</label>
</div>
<span id="personal-avatar-publicity-toggle-view-icon" class="fas fa-eye publicity-toggle-view-icon"></span>
<span id="personal-avatar-publicity-toggle-view-icon" class="fas fa-eye-slash publicity-toggle-view-icon"></span>
</div>
<button id="personal-avatar-tutorial" class="button tutorial-button">Run Tutorial</button>
</div>
</div>
<div id="team-header" class="header team-header">
Expand Down Expand Up @@ -147,7 +148,12 @@
</div>
</div>
<!-- bot buttons
<button class="button bot-start" id="personal-biographer-start">Let's get started!</button>-->
<button class="button bot-start" id="personal-biographer-start">Let's get started!</button>
<div id="personal-biographer-retire" class="retire">
Retire this:
<span id="personal-biographer-retire-icon" class="fas fa-retire retire-icon">CHAT</span>
<span id="personal-biographer-retire-text" class="retire-text">BOT</span>-->
</div>
</div>
</div>
<div class="bot-container" id="journaler">
Expand Down
49 changes: 47 additions & 2 deletions views/assets/js/bots.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
addMessage,
addMessages,
decorateActiveBot,
experiences,
expunge,
fetchSummary,
getActiveItemId,
Expand All @@ -13,6 +14,7 @@ import {
setActiveItem,
setActiveItemTitle,
show,
startExperience,
submit,
toggleMemberInput,
toggleVisibility,
Expand Down Expand Up @@ -123,7 +125,8 @@ function getBot(type='personal-avatar', id){
* @returns {object} - The collection item object.
*/
function getItem(id){
/* return collection item by id */
/* return collection elements by id */

}
/**
* Refresh designated collection from server. **note**: external calls denied option to identify collectionList parameter, ergo must always be of same type.
Expand Down Expand Up @@ -205,6 +208,19 @@ function togglePopup(id, bForceState=null){
throw new Error(`No popup found for id: ${ id }`)
toggleVisibility(popup, bForceState)
}
/**
* Update collection item title.
* @todo - Only update local memory and data(sets), not full local refresh
* @param {object} item - The collection item fields to update, requires `{ itemId, }`
* @returns {void}
*/
function updateItem(item){
if(!item?.itemId)
throw new Error(`No item provided to update.`)
/* update collection elements indicated as object keys with this itemId */
// @stub - force-refresh memories; could be more savvy
refreshCollection('story')
}
/**
* Proxy to update bot-bar, bot-containers, and bot-greeting, if desired. Requirements should come from including module, here `members.mjs`.
* @public
Expand Down Expand Up @@ -317,7 +333,7 @@ function mBotIcon(type){
*/
function mCreateCollectionItem(collectionItem){
/* collection item container */
const { assistantType, filename, form, id, keywords, library_id, name, summary, title, type, } = collectionItem
const { assistantType, filename, form, id, keywords, name, summary, title, type, } = collectionItem
const item = document.createElement('div')
item.id = `collection-item_${ id }`
item.name = `collection-item-${ type }`
Expand Down Expand Up @@ -1698,6 +1714,7 @@ function mToggleSwitchPrivacy(event){
let { id, } = this
id = id.replace('-toggle', '') // remove toggle
const type = mGlobals.HTMLIdToType(id)
console.log('mToggleSwitchPrivacy', type)
const publicityCheckbox = document.getElementById(`${ type }-publicity-input`)
const viewIcon = document.getElementById(`${ type }-publicity-toggle-view-icon`)
const { checked=false, } = publicityCheckbox
Expand Down Expand Up @@ -1851,6 +1868,21 @@ function mUpdateBotContainerAddenda(botContainer){
}
})
}
/* publicity */
const publicityToggle = document.getElementById(`${ type }-publicity-toggle`)
if(publicityToggle){
publicityToggle.addEventListener('click', mToggleSwitchPrivacy)
const publicityToggleView = document.getElementById(`${ type }-publicity-toggle-view-icon`)
if(publicityToggleView){
const { checked=false, } = document.getElementById(`${ type }-publicity-input`) ?? {}
mToggleClass(publicityToggleView, !checked ? ['fa-eye-slash'] : ['fa-eye'], checked ? ['fa-eye'] : ['fa-eye-slash'])
publicityToggleView.addEventListener('click', event=>{
// @note - shouldn't be required, but container masters the switch
event.stopImmediatePropagation()
event.stopPropagation()
})
}
}
switch(type){
case 'diary':
case 'journaler':
Expand All @@ -1860,6 +1892,18 @@ function mUpdateBotContainerAddenda(botContainer){
/* attach avatar listeners */
/* set additional data attributes */
mTogglePassphrase(false) /* passphrase */
const tutorialButton = document.getElementById('personal-avatar-tutorial')
if(tutorialButton){
if(experiences().length){
show(tutorialButton)
tutorialButton.addEventListener('click', async event=>{
hide(tutorialButton)
const tutorialId = 'aae28fe4-30f9-4c29-9174-a0616569e762'
startExperience(tutorialId) // no await
}, { once: true })
} else
hide(tutorialButton)
}
break
default:
break
Expand Down Expand Up @@ -2123,5 +2167,6 @@ export {
refreshCollection,
setActiveBot,
togglePopup,
updateItem,
updatePageBots,
}
11 changes: 4 additions & 7 deletions views/assets/js/experience.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,9 @@ async function experiencePlay(memberInput){
* Retrieve full or scoped list of experiences from server.
* @todo - more robust logic underpinning selection of experiences, currently only system-controlled exist.
* @requires mExperiences
* @param {string} scope - The scope of the experiences to retrieve.
* @returns {Promise<Experience[]>} - The return is an array of Experience objects.
* @returns {Experience[]} - The return is an array of Experience objects.
*/
async function experiences(scope){
if(!mExperiences.length)
mExperiences.push(...await mGetExperiences(scope))
function experiences(scope){
return mExperiences
}
/**
Expand All @@ -196,8 +193,8 @@ function experienceSkip(sceneId){
/**
* Start experience onscreen, displaying welcome ande loading remaining data.
* @public
* @param {Guid} experienceId - The Experience object.
* @returns {Promise<void>} - The return is its own success.
* @param {Guid} experienceId - The Experience id
* @returns {Promise<void>}
*/
async function experienceStart(experienceId){
if(!globals.isGuid(experienceId))
Expand Down
Loading