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

Azure deploy prod #334

Merged
merged 2 commits into from
Aug 19, 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
3 changes: 3 additions & 0 deletions inc/js/core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ class Organization extends Member { // form=organization
get values(){
return this.core.values
}
get version(){
return this.core.version ?? '0.0.17'
}
get vision(){
return this.core.vision
}
Expand Down
5 changes: 2 additions & 3 deletions inc/js/globals.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const mAiJsFunctions = {
}
},
storySummary: {
description: 'Generate a STORY summary with keywords and other critical data elements.',
description: 'Generate a complete multi-paragraph STORY summary with keywords and other critical data elements.',
name: 'storySummary',
parameters: {
type: 'object',
Expand Down Expand Up @@ -119,8 +119,7 @@ const mAiJsFunctions = {
maxItems: 24
},
summary: {
description: 'Generate a STORY summary from input.',
maxLength: 20480,
description: 'A complete multi-paragraph STORY summary composed from relevant user input.',
type: 'string'
},
title: {
Expand Down
14 changes: 9 additions & 5 deletions inc/js/mylife-avatar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class Avatar extends EventEmitter {
const conversation = new (this.#factory.conversation)({ mbr_id: this.mbr_id, type, }, this.#factory, thread, botId)
if(saveToConversations){
this.#conversations.push(conversation)
console.log('createConversation::save in memory', conversation.thread_id)
console.log('createConversation::saving into local memory', conversation.thread_id)
}
return conversation
}
Expand Down Expand Up @@ -699,6 +699,8 @@ class Avatar extends EventEmitter {
const currentVersion = this.#factory.botInstructionsVersion(type)
if(botVersion!==currentVersion){
this.updateInstructions(newActiveId, true, false, true)
/* update bot in this.#bots */

}
this.#activeBotId = newActiveId
}
Expand Down Expand Up @@ -1290,15 +1292,15 @@ function mAvatarDropdown(globals, avatar){
*/
async function mBot(factory, avatar, bot){
/* validation */
const { bots, id: avatarId, isMyLife, mbr_id, vectorstore_id, } = avatar
const { id: avatarId, mbr_id, vectorstore_id, } = avatar
const { newGuid, } = factory
const { id: botId=newGuid, object_id: objectId, type: botType, } = bot
if(!botType?.length)
throw new Error('Bot type required to create.')
bot.mbr_id = mbr_id /* constant */
bot.object_id = objectId ?? avatarId /* all your bots belong to me */
bot.id = botId // **note**: _this_ is a Cosmos id, not an openAI id
let originBot = bots.find(oBot=>oBot.id===botId)
let originBot = avatar.bots.find(oBot=>oBot.id===botId)
if(originBot){ /* update bot */
const options = {}
const updatedBot = Object.keys(bot)
Expand All @@ -1317,8 +1319,9 @@ async function mBot(factory, avatar, bot){
avatar.conversations.push(conversation)
}
}
let updatedOriginBot
if(Object.keys(updatedBot).length){
let updatedOriginBot = {...originBot, ...updatedBot} // consolidated update
updatedOriginBot = {...originBot, ...updatedBot} // consolidated update
const { bot_id, id, } = updatedOriginBot
updatedBot.bot_id = bot_id
updatedBot.id = id
Expand All @@ -1331,8 +1334,9 @@ async function mBot(factory, avatar, bot){
options.tools = false /* tools not updated through this mechanic */
}
updatedOriginBot = await factory.updateBot(updatedBot, options)
originBot = mSanitize(updatedOriginBot)
}
originBot = mSanitize(updatedOriginBot ?? originBot)
avatar.bots[avatar.bots.findIndex(oBot=>oBot.id===botId)] = originBot
} else { /* create assistant */
bot = mSanitize( await factory.createBot(bot, vectorstore_id) )
avatar.bots.push(bot)
Expand Down
15 changes: 5 additions & 10 deletions inc/js/mylife-llm-services.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -392,26 +392,21 @@ async function mRunFunctions(openai, run, factory, avatar){ // add avatar ref
case 'story summary':
const story = await factory.story(toolArguments)
if(story){
const { keywords, phaseOfLife='unknown', } = story
const { keywords, phaseOfLife, } = story
let { interests, updates, } = factory.core
if(typeof interests=='array')
interests = interests.join(', ')
if(typeof updates=='array')
updates = updates.join(', ')
// @stub - action integrates with story and interests/phase
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
case phaseOfLife!=='unknown':
action = `ask about another encounter during this phase of life: ${ phaseOfLife }`
console.log('mRunFunctions()::story-summary::phaseOfLife', phaseOfLife)
break
case updates?.length:
action = `ask about current events related to or beyond: ${ updates }`
console.log('mRunFunctions()::story-summary::updates', updates)
break
default:
action = 'ask about another event in member\'s life'
break
Expand Down
2 changes: 1 addition & 1 deletion inc/js/routes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function connectRoutes(_Menu){
* @returns {function} Koa next function
*/
async function memberValidation(ctx, next) {
if(ctx.state.locked)
if(ctx.state?.locked ?? true)
ctx.redirect(`/?type=select`) // Redirect to /members if not authorized
await next() // Proceed to the next middleware if authorized
}
Expand Down
5 changes: 2 additions & 3 deletions inc/json-schemas/openai/functions/storySummary.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"description": "Generate a STORY summary with keywords and other critical data elements.",
"description": "Generate a complete multi-paragraph STORY summary with keywords and other critical data elements.",
"name": "storySummary",
"parameters": {
"type": "object",
Expand Down Expand Up @@ -44,8 +44,7 @@
"maxItems": 24
},
"summary": {
"description": "Generate a STORY summary from input.",
"maxLength": 20480,
"description": "A complete multi-paragraph STORY summary composed from relevant user input.",
"type": "string"
},
"title": {
Expand Down
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ app.use(koaBody({
ctx.state.avatar = ctx.state.member.avatar
ctx.state.interfaceMode = ctx.state.avatar?.mode ?? 'standard'
ctx.state.menu = ctx.MyLife.menu
ctx.state.version = ctx.MyLife.version
if(!await ctx.state.MemberSession.requestConsent(ctx))
ctx.throw(404,'asset request rejected by consent')
await next()
Expand Down
32 changes: 20 additions & 12 deletions views/assets/css/bots.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* document vars */
:root {
--border-radius: 0.22rem;
--collection-item-popup-z-index: calc(var(--mylife-sidebar-z-index)+50);
--slider-height: 1rem;
--slider-margin: 0.1rem;
--slider-width: 2rem;
Expand Down Expand Up @@ -32,11 +33,9 @@
height: 2.5rem;
margin: 0 0.1rem; /* Default margin */
transition: transform 0.3s ease, margin 0.3s ease;
z-index: 1;
}
.bot-thumb:hover {
transform: scale(1.5);
z-index: 2;
margin: 0 1rem; /* Increase margin on hover in em */
}
.bot-thumb-container {
Expand All @@ -50,7 +49,6 @@
.bot-thumb-active {
background-image: radial-gradient(circle at center, rgba(255, 255, 0, 0.75) 0%, transparent 100%);
cursor: not-allowed;
z-index: 3;
}
/* bot widget */
.bot { /* along with widget */
Expand All @@ -72,10 +70,6 @@
display: flex;
overflow: auto;
}
.bot-content.visible {
/* Show content when active */
display: block;
}
/* team */
.add-team-member-icon {
font-size: 1.5rem;
Expand All @@ -100,7 +94,6 @@
flex-direction: column;
justify-content: flex-start;
position: absolute;
z-index: 50;
}
.team-popup-content {
background-color: #333; /* Change as needed */
Expand Down Expand Up @@ -358,11 +351,14 @@
left: auto;
margin: 0;
overflow: auto;
opacity: 0; /* Start with hidden popup */
/* transition: opacity 0.3s; /* Smooth transition */
padding: 0;
position: absolute;
right: 110vw;
top: 0;
width: 40em;
z-index: var(--collection-item-popup-z-index); /* above sidebar and other popups */
}
.collection-popup-body {
display: flex;
Expand Down Expand Up @@ -563,14 +559,26 @@ input:checked + .publicity-slider:before {
padding: 0.5rem;
transition: opacity 0.5s ease; /* Smooth transition for opacity */
}
.share-memory-container { /* panel for how others `experience` memory story */
.relive-memory-button.button {
display: flex;
margin: 0.2rem 0;
padding: 0 0.2rem;
max-width: 80%;
min-width: 60%;
}
.relive-memory-container { /* panel for how others `experience` memory story */
align-items: center;
display: flex;
flex-direction: column;
justify-content: flex-start;
margin: 0;
padding: 0;
margin: 0.2rem;
padding: 0.2rem;
}
.relive-memory-explanation {
display: flex;
padding: 0.2rem;
}
.share-memory-select { /* container for share memory selection packet */
.relive-memory-select { /* container for share memory selection packet */
display: flex;
flex-direction: row;
justify-content: space-between;
Expand Down
Loading