-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from MyLife-Services/azure-base-prune
Version 0.0.1.0063
- Loading branch information
Showing
58 changed files
with
5,511 additions
and
1,506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Ignore files that are already ignored by git | ||
.gitignore | ||
# Ignore files that are specific to your development environment | ||
.git | ||
.env | ||
postman | ||
.postman | ||
.vscode | ||
.github | ||
# Ignore docker-specific files | ||
.dockerignore | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
# basic js installations | ||
package-lock.json | ||
/node_modules/ | ||
/in-progress/ | ||
.env* | ||
.vscode/ | ||
__*/ # ignore all folders starting with an underscore | ||
__*/ # ignore all folders starting with an underscore | ||
.hintrc | ||
.uploads | ||
.tmp | ||
.DS_Store | ||
.code-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
FROM node:14 | ||
|
||
WORKDIR /app | ||
COPY . /app | ||
|
||
RUN npm install | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["npm", "run", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# MyLife System Assistants | ||
|
||
The MyLife system incorporates a suite of specialized assistants, each designed to augment various aspects of the avatars within the platform. These assistants follow consistent coding protocols and are currently intended exclusively for integration with avatars, enhancing their functionality and interactivity. | ||
|
||
- **Asset-Assistant (File Handler)**: This assistant manages file-related operations, ensuring efficient handling, storage, and retrieval of files within the system. It acts as a central hub for file management tasks, streamlining the process of dealing with various file formats and data types. | ||
|
||
- **Evolution-Assistant**: Central to the avatar's developmental journey, the Evolution Assistant orchestrates the growth and maturation of avatars. It guides avatars through different phases of evolution, from creation to retirement, tailoring the development process according to the avatar's specific needs and contexts. | ||
|
||
- **DOM-Assistant**: The Document Object Model (DOM) Assistant is pivotal in managing and manipulating the structure of data and documents within the system. It plays a key role in ensuring the data is organized and accessible in a way that is both efficient and intuitive. | ||
|
||
- **Preferences-Assistant**: This assistant is dedicated to personalizing user experiences by managing and adapting to user preferences. It ensures that avatars can cater to individual tastes and requirements, making interactions more tailored and relevant. | ||
|
||
- **Settings-Assistant**: Focused on configuration management, the Settings Assistant allows for the customization and adjustment of system settings. This ensures that avatars can operate within the parameters that best suit the user's needs and the system's operational environment. | ||
|
||
- **Connector-Assistant (External Service Manager)**: Acting as a bridge to the outside world, the Connector Assistant manages interactions with external services and platforms. Whether it's cloud services, music, information databases, or external avatar services, this assistant facilitates seamless integration and interaction with a variety of external resources and services. | ||
|
||
Each of these assistants contributes to a more dynamic, efficient, and personalized avatar experience within the MyLife system. By specializing in different domains, they collectively enhance the overall functionality and adaptability of the avatars, making them more capable and versatile in serving the users' diverse needs. | ||
|
||
## Evolution Assistant (Evo-Agent) | ||
|
||
### Overview | ||
|
||
The Evolution Assistant, referred to as Evo-Agent, is a core component in the MyLife asset-assistant project. It is implemented in the `evolution-assistant.mjs` file and serves as an integral part of the system, managing the evolutionary process of avatars within the MyLife platform. | ||
|
||
### Design and Functionality | ||
|
||
- **Class Definition**: `EvolutionAssistant` class extends `EventEmitter`. | ||
- **Private Members**: | ||
- `#avatar`: A reference to the symbiotic avatar object. | ||
- `#contributions`: An array to manage contributions related to the avatar. | ||
- `#phase`: Tracks the current phase of evolution, such as 'create', 'init', 'develop', etc. | ||
- **Constructor**: | ||
- Initializes the Evo-Agent with a default phase and binds it to a specific avatar. | ||
- **Key Methods**: | ||
- `init()`: Initializes the Evo-Agent, setting up initial contributions. | ||
- `avatar()`, `being()`, `categories()`, etc.: Getters for various avatar properties. | ||
- `#advancePhase()`: A private method to advance the evolutionary phase of the avatar. | ||
|
||
### Event Handling | ||
|
||
The Evo-Agent is designed to emit events at different stages of its lifecycle, signaling the beginning and completion of various phases. It leverages Node.js's `EventEmitter` for event-driven programming. | ||
|
||
### Modular Design | ||
|
||
The codebase follows a modular approach, with functions like `mAdvancePhase()` and `mAssessData()` externalized for specific operations, maintaining a clean and manageable structure. | ||
|
||
### Phases of Evolution | ||
|
||
The Evo-Agent guides the avatar through multiple phases: | ||
|
||
- `create` | ||
- `init` | ||
- `develop` | ||
- `mature` | ||
- `maintain` | ||
- `retire` | ||
|
||
Each phase has specific goals and criteria, ensuring a comprehensive and dynamic evolution process for the avatar. | ||
|
||
### Contribution Management | ||
|
||
The Evo-Agent actively manages contributions that aid in the growth and development of the avatar. It assesses and selects categories most in need of contributions, facilitating continuous evolution. | ||
|
||
## Appendix | ||
|
||
### Notes | ||
|
||
modular assistants, not actual agents, but system functionality that can be used _by_ agents | ||
all outputs thereby should be in the form of a consistent class, that is at least initially defined by the global config at its heart (i.e., inclusive at least, if one-day not fully birthed from, the raw json config file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// imports | ||
import fs from 'fs' | ||
import mime from 'mime-types' | ||
import FormData from 'form-data' | ||
import axios from 'axios' | ||
// modular constants | ||
const aAdmins = JSON.parse(process.env.MYLIFE_HOSTED_MBR_ID) | ||
// modular variables | ||
let AgentFactory | ||
let Globals | ||
// modular class definition | ||
class oAIAssetAssistant { | ||
// pseudo-constructor | ||
#ctx | ||
#file | ||
#mbr_id | ||
constructor(_ctx){ | ||
// primary direct assignment | ||
this.#ctx = _ctx | ||
this.#mbr_id = this.#ctx.state.member.mbr_id | ||
// modular direct assignment | ||
if(!AgentFactory) AgentFactory = this.#ctx.AgentFactory | ||
if(!Globals) Globals = this.#ctx.Globals | ||
// secondary direct assignment | ||
this.#file = this.#extractFile(this.#ctx) | ||
// validate asset construction | ||
this.#validateFile() | ||
} | ||
async init(){ | ||
await this.#embedFile() // critical step | ||
await this.#enactFile() // critical step | ||
return this | ||
} | ||
// getters | ||
get ctx(){ | ||
return this.#ctx | ||
} | ||
get file(){ | ||
return this.#file | ||
} | ||
get mbr_id(){ | ||
return this.#mbr_id | ||
} | ||
get session(){ | ||
return this.#ctx.session?.MemberSession??null | ||
} | ||
// setters | ||
// private functions | ||
async #embedFile(){ | ||
console.log(this.file) | ||
console.log('#embedFile() begin') | ||
const _metadata = { | ||
source: 'corporate', // logickify this | ||
source_id: this.file.originalFilename, | ||
url: 'testing-0001', // may or may not use url | ||
author: 'MAHT', // convert to session member (or agent) | ||
} | ||
const _token = process.env.MYLIFE_EMBEDDING_SERVER_BEARER_TOKEN | ||
const _data = new FormData() | ||
_data.append('file', fs.createReadStream(this.file.filepath), { contentType: this.file.mimetype }) | ||
_data.append('metadata', JSON.stringify(_metadata)) | ||
const _request = { | ||
method: 'post', | ||
maxBodyLength: Infinity, | ||
url: 'http://localhost:8000/upsert-file', | ||
headers: { | ||
'Authorization': `Bearer ${_token}`, | ||
..._data.getHeaders() | ||
}, | ||
data : _data | ||
} | ||
return await axios.request(_request) | ||
.then((response) => { | ||
console.log(`#embedFile() finished: ${response.data.ids}`) | ||
return response.data | ||
}) | ||
.catch((error) => { | ||
console.error(error.message) | ||
return {'#embedFile() finished error': error.message } | ||
}) | ||
} | ||
async #enactFile(){ // vitalizes by saving to MyLife database | ||
console.log('#enactFile() begin') | ||
const _fileContent = { | ||
...this.file, | ||
...{ mbr_id: this.mbr_id } | ||
} | ||
const oFile = new (AgentFactory.file)(_fileContent) | ||
console.log('testing factory',oFile.inspect(true)) | ||
return oFile | ||
} | ||
#extractFile(){ | ||
if(!this.#ctx.request?.files?.file??false) throw new Error('No file found in request.') | ||
const { lastModifiedDate, filepath, newFilename, originalFilename, mimetype, size } = this.#ctx.request.files.file | ||
return { | ||
...{ lastModifiedDate, filepath, newFilename, originalFilename, mimetype, size, localFilename: `${Globals.newGuid}.${mime.extension(mimetype)}` }, | ||
...this.#ctx.request.body | ||
} | ||
} | ||
#validateFile(){ | ||
const allowedMimeTypes = [ | ||
'application/json', | ||
'application/msword', | ||
'application/pdf', | ||
'application/rtf', | ||
'application/vnd.ms-powerpoint', | ||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document', | ||
'application/vnd.openxmlformats-officedocument.presentationml.presentation', | ||
'text/csv', | ||
'text/html', | ||
'text/markdown', | ||
'text/plain', | ||
] | ||
// reject size | ||
let _mbr_id = this.#ctx.state.member.mbr_id | ||
let _maxFileSize = (aAdmins.includes(_mbr_id) || _mbr_id === process.env.MYLIFE_SERVER_MBR_ID) | ||
? process.env.MYLIFE_EMBEDDING_SERVER_FILESIZE_LIMIT_ADMIN | ||
: process.env.MYLIFE_EMBEDDING_SERVER_FILESIZE_LIMIT | ||
if (this.#file.size > _maxFileSize) throw new Error(`File size too large: ${this.#file.size}. Maximum file size is 1MB.`) | ||
// reject mime-type | ||
if (!allowedMimeTypes.includes(this.#file.mimetype)) throw new Error(`Unsupported media type: ${this.#file.mimetype}. File type not allowed.`) | ||
} | ||
} | ||
// exports | ||
export default oAIAssetAssistant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// connector for external resources | ||
// - cloud services (dropbox, google drive, etc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* | ||
A dom assistant is able to retrieve and pre-consume src html/js and reinterpret according to member's consent preferences. Essential for any ux-agent to function. It would alter the content and/or issue js post-load content (at some temp-created consume-once endpoint [i.e., if failure, alert security]) to alter the page. | ||
*/ |
Oops, something went wrong.