Skip to content

Commit 561c230

Browse files
authored
316 version 0017 updates (#332)
### Enhancements - [x] #302 - [x] #272 - [x] #324 (partial fix for alpha) - [x] #306 - [x] #310 - [x] #315 - [x] #287 ### Fixes - [x] dead session/api mgmt; if session broken, clicking on bots will only fire internal error, not reload page - [x] Message tabs copying for Members needed reconfiguring - [x] Conversation logs created every session start [avoid] - [x] `mSetBot` updates to server do not survive page refresh, presume server memory not dynamically updated; confirmed, still a problem, but rest of pipeline working--similarly affects name changes - [x] #329 - [x] #295 - [x] #319 - [x] #322 duplicates #319 - [x] #320 ### Cosmetic - [x] chat box in `index.html` is not divided same way and so appears on left
1 parent b185d29 commit 561c230

17 files changed

+345
-232
lines changed

inc/js/core.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ class Organization extends Member { // form=organization
225225
get values(){
226226
return this.core.values
227227
}
228+
get version(){
229+
return this.core.version ?? '0.0.17'
230+
}
228231
get vision(){
229232
return this.core.vision
230233
}

inc/js/globals.mjs

+2-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const mAiJsFunctions = {
7474
}
7575
},
7676
storySummary: {
77-
description: 'Generate a STORY summary with keywords and other critical data elements.',
77+
description: 'Generate a complete multi-paragraph STORY summary with keywords and other critical data elements.',
7878
name: 'storySummary',
7979
parameters: {
8080
type: 'object',
@@ -119,8 +119,7 @@ const mAiJsFunctions = {
119119
maxItems: 24
120120
},
121121
summary: {
122-
description: 'Generate a STORY summary from input.',
123-
maxLength: 20480,
122+
description: 'A complete multi-paragraph STORY summary composed from relevant user input.',
124123
type: 'string'
125124
},
126125
title: {

inc/js/mylife-avatar.mjs

+9-5
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class Avatar extends EventEmitter {
192192
const conversation = new (this.#factory.conversation)({ mbr_id: this.mbr_id, type, }, this.#factory, thread, botId)
193193
if(saveToConversations){
194194
this.#conversations.push(conversation)
195-
console.log('createConversation::save in memory', conversation.thread_id)
195+
console.log('createConversation::saving into local memory', conversation.thread_id)
196196
}
197197
return conversation
198198
}
@@ -699,6 +699,8 @@ class Avatar extends EventEmitter {
699699
const currentVersion = this.#factory.botInstructionsVersion(type)
700700
if(botVersion!==currentVersion){
701701
this.updateInstructions(newActiveId, true, false, true)
702+
/* update bot in this.#bots */
703+
702704
}
703705
this.#activeBotId = newActiveId
704706
}
@@ -1290,15 +1292,15 @@ function mAvatarDropdown(globals, avatar){
12901292
*/
12911293
async function mBot(factory, avatar, bot){
12921294
/* validation */
1293-
const { bots, id: avatarId, isMyLife, mbr_id, vectorstore_id, } = avatar
1295+
const { id: avatarId, mbr_id, vectorstore_id, } = avatar
12941296
const { newGuid, } = factory
12951297
const { id: botId=newGuid, object_id: objectId, type: botType, } = bot
12961298
if(!botType?.length)
12971299
throw new Error('Bot type required to create.')
12981300
bot.mbr_id = mbr_id /* constant */
12991301
bot.object_id = objectId ?? avatarId /* all your bots belong to me */
13001302
bot.id = botId // **note**: _this_ is a Cosmos id, not an openAI id
1301-
let originBot = bots.find(oBot=>oBot.id===botId)
1303+
let originBot = avatar.bots.find(oBot=>oBot.id===botId)
13021304
if(originBot){ /* update bot */
13031305
const options = {}
13041306
const updatedBot = Object.keys(bot)
@@ -1317,8 +1319,9 @@ async function mBot(factory, avatar, bot){
13171319
avatar.conversations.push(conversation)
13181320
}
13191321
}
1322+
let updatedOriginBot
13201323
if(Object.keys(updatedBot).length){
1321-
let updatedOriginBot = {...originBot, ...updatedBot} // consolidated update
1324+
updatedOriginBot = {...originBot, ...updatedBot} // consolidated update
13221325
const { bot_id, id, } = updatedOriginBot
13231326
updatedBot.bot_id = bot_id
13241327
updatedBot.id = id
@@ -1331,8 +1334,9 @@ async function mBot(factory, avatar, bot){
13311334
options.tools = false /* tools not updated through this mechanic */
13321335
}
13331336
updatedOriginBot = await factory.updateBot(updatedBot, options)
1334-
originBot = mSanitize(updatedOriginBot)
13351337
}
1338+
originBot = mSanitize(updatedOriginBot ?? originBot)
1339+
avatar.bots[avatar.bots.findIndex(oBot=>oBot.id===botId)] = originBot
13361340
} else { /* create assistant */
13371341
bot = mSanitize( await factory.createBot(bot, vectorstore_id) )
13381342
avatar.bots.push(bot)

inc/js/mylife-llm-services.mjs

+5-10
Original file line numberDiff line numberDiff line change
@@ -392,26 +392,21 @@ async function mRunFunctions(openai, run, factory, avatar){ // add avatar ref
392392
case 'story summary':
393393
const story = await factory.story(toolArguments)
394394
if(story){
395-
const { keywords, phaseOfLife='unknown', } = story
395+
const { keywords, phaseOfLife, } = story
396396
let { interests, updates, } = factory.core
397397
if(typeof interests=='array')
398398
interests = interests.join(', ')
399399
if(typeof updates=='array')
400400
updates = updates.join(', ')
401-
// @stub - action integrates with story and interests/phase
402401
switch(true){
402+
case phaseOfLife?.length:
403+
action = `ask about another encounter during member's ${ phaseOfLife }`
404+
console.log('mRunFunctions()::story-summary::phaseOfLife', phaseOfLife)
405+
break
403406
case interests?.length:
404407
action = `ask about a different interest from: ${ interests }`
405408
console.log('mRunFunctions()::story-summary::interests', interests)
406409
break
407-
case phaseOfLife!=='unknown':
408-
action = `ask about another encounter during this phase of life: ${ phaseOfLife }`
409-
console.log('mRunFunctions()::story-summary::phaseOfLife', phaseOfLife)
410-
break
411-
case updates?.length:
412-
action = `ask about current events related to or beyond: ${ updates }`
413-
console.log('mRunFunctions()::story-summary::updates', updates)
414-
break
415410
default:
416411
action = 'ask about another event in member\'s life'
417412
break

inc/js/routes.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function connectRoutes(_Menu){
146146
* @returns {function} Koa next function
147147
*/
148148
async function memberValidation(ctx, next) {
149-
if(ctx.state.locked)
149+
if(ctx.state?.locked ?? true)
150150
ctx.redirect(`/?type=select`) // Redirect to /members if not authorized
151151
await next() // Proceed to the next middleware if authorized
152152
}

inc/json-schemas/openai/functions/storySummary.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"description": "Generate a STORY summary with keywords and other critical data elements.",
2+
"description": "Generate a complete multi-paragraph STORY summary with keywords and other critical data elements.",
33
"name": "storySummary",
44
"parameters": {
55
"type": "object",
@@ -44,8 +44,7 @@
4444
"maxItems": 24
4545
},
4646
"summary": {
47-
"description": "Generate a STORY summary from input.",
48-
"maxLength": 20480,
47+
"description": "A complete multi-paragraph STORY summary composed from relevant user input.",
4948
"type": "string"
5049
},
5150
"title": {

server.js

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ app.use(koaBody({
166166
ctx.state.avatar = ctx.state.member.avatar
167167
ctx.state.interfaceMode = ctx.state.avatar?.mode ?? 'standard'
168168
ctx.state.menu = ctx.MyLife.menu
169+
ctx.state.version = ctx.MyLife.version
169170
if(!await ctx.state.MemberSession.requestConsent(ctx))
170171
ctx.throw(404,'asset request rejected by consent')
171172
await next()

views/assets/css/bots.css

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* document vars */
22
:root {
33
--border-radius: 0.22rem;
4+
--collection-item-popup-z-index: calc(var(--mylife-sidebar-z-index)+50);
45
--slider-height: 1rem;
56
--slider-margin: 0.1rem;
67
--slider-width: 2rem;
@@ -32,11 +33,9 @@
3233
height: 2.5rem;
3334
margin: 0 0.1rem; /* Default margin */
3435
transition: transform 0.3s ease, margin 0.3s ease;
35-
z-index: 1;
3636
}
3737
.bot-thumb:hover {
3838
transform: scale(1.5);
39-
z-index: 2;
4039
margin: 0 1rem; /* Increase margin on hover in em */
4140
}
4241
.bot-thumb-container {
@@ -50,7 +49,6 @@
5049
.bot-thumb-active {
5150
background-image: radial-gradient(circle at center, rgba(255, 255, 0, 0.75) 0%, transparent 100%);
5251
cursor: not-allowed;
53-
z-index: 3;
5452
}
5553
/* bot widget */
5654
.bot { /* along with widget */
@@ -72,10 +70,6 @@
7270
display: flex;
7371
overflow: auto;
7472
}
75-
.bot-content.visible {
76-
/* Show content when active */
77-
display: block;
78-
}
7973
/* team */
8074
.add-team-member-icon {
8175
font-size: 1.5rem;
@@ -100,7 +94,6 @@
10094
flex-direction: column;
10195
justify-content: flex-start;
10296
position: absolute;
103-
z-index: 50;
10497
}
10598
.team-popup-content {
10699
background-color: #333; /* Change as needed */
@@ -358,11 +351,14 @@
358351
left: auto;
359352
margin: 0;
360353
overflow: auto;
354+
opacity: 0; /* Start with hidden popup */
355+
/* transition: opacity 0.3s; /* Smooth transition */
361356
padding: 0;
362357
position: absolute;
363358
right: 110vw;
364359
top: 0;
365360
width: 40em;
361+
z-index: var(--collection-item-popup-z-index); /* above sidebar and other popups */
366362
}
367363
.collection-popup-body {
368364
display: flex;

views/assets/css/chat.css

+98-26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/* css chat variables */
2+
:root {
3+
--chat-base-z-index: calc(var(--mylife-base-z-index) + 10);
4+
}
15
/* MyLife chat container */
26
.agent-bubble {
37
background-color: rgba(0, 86, 179, .85); /* A darker shade of blue for the agent */
@@ -25,26 +29,30 @@
2529
margin-right: 0.5em;
2630
}
2731
.chat-bubble {
28-
border-radius: 18px; /* Rounded corners for a modern look */
29-
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); /* Subtle shadow for depth */
32+
background-color: #3427ec; /* Assuming a dark bubble color */
33+
border-radius: 0.8rem;
34+
box-shadow: 0.2rem 0.2rem 0.4rem rgba(0, 0, 0, 0.3);
35+
display: flex;
36+
flex-direction: column;
37+
font-size: 0.9em;
3038
margin-bottom: 0.5rem;
3139
max-width: 90%;
3240
min-width: 30%;
33-
padding: 10px 15px; /* Padding for content inside bubble */
34-
font-size: .9em;
35-
width: fit-content; /* Fit the content's width */
36-
word-wrap: break-word; /* Ensure long words don't overflow */
41+
padding: 0.5rem 0.8rem;
42+
width: fit-content;
43+
word-wrap: break-word;
44+
z-index: calc(var(--chat-base-z-index) + 1);
3745
}
3846
.chat-container {
3947
align-items: flex-start;
4048
background-image:
41-
linear-gradient(
42-
to bottom,
43-
rgba(255, 255, 255, 0.85) 0%,
49+
linear-gradient(
50+
to bottom,
51+
rgba(255, 255, 255, 0.85) 0%,
4452
rgba(255, 255, 255, 0.85) 50%,
4553
rgba(66, 66, 66, 0.85) 100%
46-
), /* White overlay with 50% opacity */
47-
url('../jpg/cosmos.jpg'); /* Your original background image */
54+
), /* White overlay with 50% opacity */
55+
url('../jpg/cosmos.jpg'); /* Your original background image */
4856
background-size: cover; /* Ensures the image covers the whole area */
4957
background-position: center; /* Centers the image */
5058
border-radius: 22px;
@@ -59,16 +67,16 @@
5967
position: relative;
6068
width: 100%;
6169
}
62-
.chat-member,
63-
.chat-user {
64-
align-items: center;
65-
display: flex;
66-
flex: 1 1 auto;
67-
flex-direction: row;
68-
flex-wrap: wrap;
69-
margin: 0.5em 0;
70-
max-height: 60%;
71-
width: 100%;
70+
.chat-copy,
71+
.chat-feedback {
72+
cursor: pointer;
73+
font-size: 0.8rem;
74+
margin: 0.2rem;
75+
position: absolute;
76+
top: 0.2rem;
77+
}
78+
.chat-feedback {
79+
right: 0.6rem;
7280
}
7381
.chat-input {
7482
background-color: #ffffff; /* White background color */
@@ -87,6 +95,70 @@
8795
padding: 0.3em; /* Padding for space inside the container */
8896
resize: none; /* Allows vertical resizing, none to disable */
8997
}
98+
.chat-member,
99+
.chat-user {
100+
align-items: center;
101+
display: flex;
102+
flex: 1 1 auto;
103+
flex-direction: row;
104+
flex-wrap: wrap;
105+
margin: 0.5em 0;
106+
max-height: 60%;
107+
width: 100%;
108+
}
109+
.chat-message-container {
110+
display: flex;
111+
position: relative;
112+
}
113+
.chat-message-container-agent {
114+
flex-direction: row;
115+
}
116+
.chat-message-container-member,
117+
.chat-message-container-user {
118+
flex-direction: row-reverse;
119+
}
120+
.chat-message-tab {
121+
border-bottom-right-radius: 0.2rem;
122+
border-bottom-left-radius: 0.2rem;
123+
display: flex;
124+
flex-direction: column;
125+
height: 100%;
126+
justify-content: flex-end;
127+
opacity: 0;
128+
padding: 0.2rem;
129+
pointer-events: none;
130+
transition: transform 0.5s, opacity 0.5s;
131+
width: 2.5rem;
132+
z-index: var(--chat-base-z-index);
133+
}
134+
.chat-message-tab-agent {
135+
align-items: flex-end;
136+
background-color: #9f9dff; /* Lighter shade of the bubble color */
137+
border: thin solid #3427ec;
138+
border-top-left-radius: 0;
139+
border-top-right-radius: 0.2rem;
140+
transform: translateX(-100%);
141+
}
142+
.chat-message-tab-hover {
143+
opacity: 1;
144+
pointer-events: all;
145+
}
146+
.chat-message-tab-hover-agent,
147+
.chat-message-tab-agent:hover {
148+
transform: translateX(-33%); /* accommodate for 2.5rem */
149+
}
150+
.chat-message-tab-member {
151+
align-items: flex-start;
152+
background-color: #d6ffd9; /* Lighter shade of the bubble color */
153+
border: thin solid #27bbec;
154+
border-top-left-radius: 0.2rem;
155+
border-top-right-radius: 0;
156+
transform: translateX(100%);
157+
}
158+
.chat-message-tab-hover-member, /* **note**: must come after tab-member */
159+
.chat-message-tab-member:hover {
160+
transform: translateX(33%); /* accommodate for 2.5rem */
161+
}
90162
.chat-refresh {
91163
position: absolute; /* Position relative to parent */
92164
top: 0; /* Adjust as needed */
@@ -96,7 +168,7 @@
96168
color: #888; /* Icon color, change as needed */
97169
font-size: 24px; /* Icon size, adjust as needed */
98170
cursor: pointer; /* Pointer cursor on hover */
99-
z-index: 2; /* Ensure it's above other content */
171+
z-index: calc(var(--chat-base-z-index) + 5);
100172
}
101173
/* chat-submit button; requires special treament to overwrite button class for now */
102174
button.chat-submit { /* need specificity to overwrite button class */
@@ -175,14 +247,14 @@ button.chat-submit:disabled {
175247
margin: 0 0.5em;
176248
justify-content: flex-start;
177249
}
178-
.member-bubble, .user-bubble {
250+
.member-bubble,
251+
.user-bubble {
179252
background-color: rgba(225, 245, 254, 1); /* A light shade of blue for the user */
180253
color: #333333; /* Dark grey for contrast and easy reading */
181254
font-size: .75em;
182-
margin-left: auto;
183-
margin-right: 12px;
184255
}
185-
.member-bubble a, .user-bubble a {
256+
.member-bubble a,
257+
.user-bubble a {
186258
color: #333333; /* Dark grey for contrast and easy reading */
187259
}
188260
.spinner-green-glow {

0 commit comments

Comments
 (0)