this.me 2.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # **me** CLI
2
+ THIS IS NOT A STABLE VERSION, I AM DOING SOME CHANGES WILL UPLOAD THE NEW SETUP, IT HAS LOTS OF CHANGES IN THE STRUCTURE AND IT MAKES EVERYTHING EASIER.
3
+ THANKS, gracias amigos!
4
+ The **me CLI** is the command-line interface that puts you in control of managing your neural networks with ease using the powerful neurons.me library. With just a few simple commands, you can create neurons, build neural networks, interact with Cleaker, and harness the capabilities of Netget, all from the comfort of your terminal.
5
+
6
+ ### Installation
7
+
8
+ #### Option 1 Global
9
+
10
+ To empower yourself with the **me CLI**, simply install it globally using npm. Open your terminal and enter the following command:
11
+
12
+ ```
13
+ npm install -g @sui.gn/me
14
+ ```
15
+
16
+ **Pro-tip:** Depending on your system, you might need to use sudo with the above command for global installation.
17
+
18
+ **Running CLI Commands Globally**: If you have installed the CLI globally, and you run the CLI command from any directory in your terminal, it will execute the globally installed version of the CLI. The local dependency within the project will not affect the global CLI in this case.
19
+
20
+ #### Option 2 Local (Recommended)
21
+
22
+ ```bash
23
+ # Installing the CLI as a dev dependency in the project
24
+ npm install --save-dev @sui.gn/me
25
+
26
+ # Using the CLI
27
+ npx .me command --option value
28
+ ```
29
+
30
+ **Running CLI Commands Locally**: If you have the CLI installed as a local dependency within a specific project, you have two options to run the CLI command:
31
+
32
+ a. Using `npx`: The `npx` command is a utility that comes with npm and allows you to run locally installed Node.js packages. If you run the CLI command using `npx`, it will execute the locally installed version of the CLI, and the globally installed version will be ignored.
33
+
34
+ ### Getting Started
35
+
36
+ Once installed, the me CLI becomes your trusted companion. Just type me to unlock a world of possibilities.
37
+
38
+ ### Create Your First Neuron
39
+ To craft a neuron tailored to your needs, use the newNeuron command with various options. For example:
40
+
41
+ ```
42
+ npx .me newNeuron -n MyNeuron -d 2023-07-28 -t "12:00 PM" -c blue -a "x => x * 2" -w "[0.5, 0.3, -0.1]" -b 0.2
43
+ ```
44
+
45
+ # CLI Command Structure:
46
+ We can define a set of commands that users can use to interact with the neurons.me library.
47
+ For example:
48
+
49
+ For classes and methods in the `neurons.me` library:
50
+
51
+ - `.me newNeuron`: Create a new neuron with custom properties.
52
+ - `.me newNeuralNetwork`: Create a new neural network.
53
+
54
+ For defacto modules, the `me` prefix is combined with the module name.
55
+
56
+ The `.me` CLI simplifies and streamlines interactions with `neurons.me` and its defacto modules, making it easier for users to manage neural networks and leverage powerful functionalities.
57
+
58
+ ### Create a new neuron:
59
+ ```
60
+ npx .me createNeuron
61
+ ```
62
+
63
+ ```
64
+ npx .me new NeuralNetwork();
65
+ ```
66
+
67
+ ### Access netget functionality:
68
+ ```
69
+ npm .me netget get
70
+ npm .me netget ws
71
+ ```
72
+ # CLI Options:
73
+ For each command, we can provide options that users can use to customize the behavior. For example:
74
+ --name: Specify a custom name for the neuron or neural network.
75
+ --weights: Provide custom weights for the neuron.
76
+ --bias: Specify a custom bias for the neuron.
77
+ --activation: Set a custom activation function for the neuron.
78
+
79
+ # Modularity and Extensibility:
80
+ We can design the CLI to be modular and extensible, allowing users to add custom modules and features easily. For example, users can create their own modules and add them to the defacto module in neurons.me for easy integration into the CLI.
81
+ # Usage and Usefulness:
82
+ The CLI provides a simple and intuitive way for users to interact with the neurons.me library without the need to write code directly. It allows users to create complex neural networks with custom configurations easily. The interactive input and customizable options make it versatile and suitable for various use cases.
83
+ # Flexibility and Automation:
84
+ Users can use the CLI to automate the process of creating and configuring neural networks. They can write scripts that leverage the CLI commands and options to create and manage multiple neural networks programmatically.
85
+ # Memory Storage:
86
+ The neurons.me library uses Map objects to store and manage instances of neurons, layers, and neural networks. Each type of entity (neuron, layer, and neural network) has its own Map, and when a new instance is created, it is added to the corresponding Map.
87
+ For example, when the user executes the command create neuron, a new instance of the Neuron class is created, and it gets added to the Neuron.map. Similarly, when the user creates a layer using the create layer command, the new layer instance is added to the Layer.map.
88
+ # Lifecycle and Cleaning:
89
+ The created entities will remain in memory as long as the Node.js process is running. When the Node.js process is terminated (e.g., by closing the terminal or stopping the application), the memory will be freed, and all the entities stored in memory will be cleaned up by the garbage collector.
90
+ If you want to persist the entities beyond the lifetime of the Node.js process, you would need to implement a mechanism to store them in a database or a file system.
91
+ # Accessing and Deleting Entities:
92
+ Since the created entities are stored in Map objects within the neurons.me library, you can access them later by using the respective get methods of the Map objects.
93
+ For example, to access a specific neuron with ID 1, you can use Neuron.map.get(1). Similarly, to access a specific layer with ID 2, you can use Layer.map.get(2).
94
+
95
+ To delete an entity, you can use the delete method of the Map objects. For example, to delete a neuron with ID 1, you can use Neuron.map.delete(1).
96
+
97
+ Keep in mind that when an entity is deleted from the Map, the corresponding JavaScript object will be eligible for garbage collection, and its memory will be freed once the garbage collector runs.
98
+
99
+ It's important to note that the neurons.me library may have additional internal mechanisms to manage the lifecycle of entities, but the general idea is that created entities are stored in memory during the Node.js process's lifetime and can be accessed and deleted using the appropriate methods.
package/compareit.js ADDED
@@ -0,0 +1,47 @@
1
+ // ./src/NeuronsHandler.js
2
+ const neurons = require('neurons.me');
3
+ const { logError } = require('@sui.gn/me/src/errorHandler');
4
+ const { showMenu } = require('./utils');
5
+ const prompt = (rl, question) => new Promise((resolve) => rl.question(question, resolve));
6
+ //neuron handler
7
+ module.exports = (rl) => {
8
+ // Other functions...
9
+
10
+ const neuronConfig = async (rl, neuron, updateNeuronProperties, cloneNeuron, showMenu) => {
11
+ // Other code...
12
+ switch (action.trim()) {
13
+ case '1':
14
+ await updateNeuronProperties(neuron, rl, cloneNeuron, showMenu);
15
+ break;
16
+ case '2':
17
+ await cloneNeuron(neuron, rl, updateNeuronProperties, showMenu);
18
+ break;
19
+ case '3':
20
+ showNeuronMenu();
21
+ break;
22
+ case '4':
23
+ showMenu(rl, showNeuronMenu);
24
+ break;
25
+ default:
26
+ console.log('Invalid action. Back to Neuron Menu.');
27
+ showNeuronMenu();
28
+ }
29
+ };
30
+
31
+ const createNeuron = async (rl, updateNeuronProperties, cloneNeuron, showMenu) => {
32
+ // Other code...
33
+ await neuronConfig(rl, neuron, updateNeuronProperties, cloneNeuron, showMenu);
34
+ };
35
+
36
+ // Other functions...
37
+
38
+ return {
39
+ showNeuronMenu,
40
+ promptNeuronConfig,
41
+ listAllNeurons,
42
+ createNeuron,
43
+ neuronConfig,
44
+ updateNeuronProperties,
45
+ cloneNeuron
46
+ };
47
+ }
package/docs/design.md ADDED
@@ -0,0 +1,47 @@
1
+ CLI commands:
2
+
3
+ Create a new neuron:
4
+ Usage: me newNeuron [options]
5
+
6
+ Options:
7
+ -n, --name <name> Specify a custom name for the neuron
8
+ -d, --date <date> Specify a custom date for the neuron
9
+ -t, --time <time> Specify a custom time for the neuron
10
+ -c, --color <color> Specify a custom color for the neuron
11
+ -a, --activation <function> Specify a custom activation function for the neuron
12
+ -w, --weights <weights> Specify custom weights for the neuron
13
+ -b, --bias <bias> Specify a custom bias for the neuron
14
+ -h, --help display help for command
15
+
16
+ Login:
17
+ Usage: me login [options]
18
+
19
+ Options:
20
+ -u, --username <username> Enter your username
21
+ -p, --password <password> Enter your password
22
+ -h, --help display help for command
23
+
24
+ Interact with cleaker:
25
+ Usage: me cleaker <command> [options]
26
+
27
+ Commands:
28
+ register Register a new user on cleaker.me
29
+ login Login to your cleaker.me account
30
+ publishModel Publish a neural network model to cleaker.me
31
+ --help display help for command
32
+
33
+ Create a new neural network:
34
+ Usage: me newNeuralNetwork [options]
35
+
36
+ Options:
37
+ -h, --help display help for command
38
+
39
+ Access netget functionality:
40
+ Usage: me netget <command> [options]
41
+
42
+ Commands:
43
+ get Get data using netget
44
+ ws Establish a WebSocket connection using netget
45
+ --help display help for command
46
+
47
+ These commands provide a clear and concise way for users to interact with the neurons.me CLI. The options allow users to customize the properties of neurons and neural networks as needed. The cleaker and netget commands are organized under their respective subcommands for easy access to their functionalities.
package/main.js ADDED
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+ //main entry point to .me suite. Happy bizarre coding....
3
+ const readline = require('readline');
4
+ const neurons = require('neurons.me');
5
+ const cleakerShell = require('cleaker/shell');
6
+ const Menu = require('@sui.gn/me/src/utils');
7
+ // Other imports ...
8
+ console.log(`
9
+ ___________
10
+ [------------]
11
+ | .--------. |
12
+ | |01010101| | __________
13
+ | |11010101| | /__________\
14
+ [--------| -------- |------| --*-- |-------]
15
+ | [----_-.-----] |o ====== | |
16
+ | ______|_|_______ |__________| |
17
+ | / %%%%%%%%%%%% \ |
18
+ | / %%%%%%%%%%%%%% \ |
19
+ | ^^^^^^^^^^^^^^^^^^^^ |
20
+ [---------------------------------.me-----------]
21
+ -^^^^^^^^zzzz...
22
+ Welcome to .me - Your AI Playground
23
+ `);
24
+ // .me Main entry function
25
+ function main() {
26
+ const rl = readline.createInterface({
27
+ input: process.stdin,
28
+ output: process.stdout,
29
+ });
30
+ mainMenu(rl);
31
+ rl.setPrompt('Select module (.me)> ');
32
+ rl.prompt();
33
+ rl.on('line', (input) => {
34
+ switch (input.trim()) {
35
+ case '1':
36
+ const neuronsShell = neurons.shell(rl); // Call neurons.shell to get the object
37
+ neurons.shell(rl).init(); // initiate neurons.me
38
+ break;
39
+ case '2':
40
+ cleakerShell(rl);
41
+ break;
42
+ // Add other cases...
43
+ case '/q':
44
+ rl.close();
45
+ break;
46
+ default:
47
+ console.log('Invalid option. Please choose a valid module.');
48
+ rl.prompt();
49
+ }
50
+ }).on('close', () => {
51
+ console.log('Exiting .me');
52
+ process.exit(0);
53
+ });
54
+ }
55
+ function mainMenu(rl) {
56
+ console.log('\nChoose a module to get started:');
57
+ console.log('1. neurons.me - Manage neural networks');
58
+ console.log('2. cleaker - Work with Cleaker application');
59
+ console.log('\ntype /q to exit');
60
+ rl.prompt();
61
+ }
62
+ // NEURONS.ME SECTION
63
+ function neuronsModule(rl) {
64
+ class NeuronsMeApp {
65
+ constructor() {
66
+ this.rl = rl;
67
+ this.currentMenu = new neuronsme_MainMenu(this);
68
+ this.currentMenu.display(); // Display the main menu
69
+ }
70
+ // ... Rest of your neurons.me related code
71
+ }
72
+
73
+ class neuronsme_MainMenu extends Menu {
74
+ // ... Your existing code for the neurons menu
75
+ }
76
+
77
+ // Other neurons classes...
78
+
79
+ const neurons_me_app_init = new NeuronsMeApp();
80
+ neurons_me_app_init.start();
81
+ }
82
+ // CLEAKER SECTION
83
+ function cleakerModule(rl) {
84
+ // Implement the cleaker module here
85
+ }
86
+ main();
package/mainoLD.js ADDED
@@ -0,0 +1,162 @@
1
+ const readline = require('readline');
2
+ const neurons = require('neurons.me');
3
+ const { logError } = require('./src/errorHandler');
4
+ const Menu = require('./src/utils'); // Import Menu class
5
+ const NeuronsHandler = require('@sui.gn/me/src/NeuronsHandler');
6
+ const NeuralNetworksHandler = require('@sui.gn/me/src/NeuralNetworksHandler');
7
+ const LayersHandler = require('@sui.gn/me/src/LayersHandler');
8
+
9
+ class MainApp {
10
+ constructor() {
11
+ this.rl = readline.createInterface({
12
+ input: process.stdin,
13
+ output: process.stdout,
14
+ });
15
+ this.displayMainMenu();
16
+ }
17
+
18
+ displayMainMenu() {
19
+ console.log('\nWelcome to .me CLI! Choose a module to get started:\n');
20
+ console.log('1. neurons - Manage neural networks');
21
+ console.log('2. cleaker - Work with Cleaker application');
22
+ console.log('3. v:// - Kind of like c path');
23
+ console.log('\ntype /q to exit');
24
+ this.rl.prompt();
25
+ }
26
+
27
+ start() {
28
+ this.rl.on('line', (input) => {
29
+ switch (input.trim()) {
30
+ case '1':
31
+ neuronsHandler.run(this.rl); // Run neurons module
32
+ break;
33
+ // Handle other cases...
34
+ }
35
+ }).on('close', () => {
36
+ console.log('Exiting .me');
37
+ process.exit(0);
38
+ });
39
+ }
40
+ }
41
+
42
+ const app = new MainApp();
43
+ app.start();
44
+
45
+
46
+
47
+ //NEURONS.ME SECTION
48
+ class neuronsme_MainMenu extends Menu {
49
+ constructor(app) {
50
+ super(app.rl);
51
+ this.app = app; // Store the reference to the main app
52
+ }
53
+ async display() {
54
+ console.log('\nRunning .me! Your AI playground.\n');
55
+ console.log('┌──────────────────────────────────────────┐');
56
+ console.log('│ MAIN MENU │');
57
+ console.log('└──────────────────────────────────────────┘');
58
+ console.log('\ntype /q to exit:');
59
+ console.log('1. Neurons: Create, list, update, and delete neurons');
60
+ console.log('2. Neural Networks: Create, list, update, and delete neural networks');
61
+ console.log('3. Layers: Create, list, update, and delete layers');
62
+ console.log('4. Show Info...');
63
+ this.rl.prompt();
64
+ }
65
+ async handleInput(input) {
66
+ switch (input) {
67
+ case '/q':
68
+ this.rl.close();
69
+ break;
70
+ case '1':
71
+ this.currentMenu = new neuronsme_NeuronsMenu(this.rl);
72
+ break;
73
+ case '2':
74
+ this.currentMenu = new neuronsme_NeuralNetworksMenu(this.rl);
75
+ break;
76
+ case '3':
77
+ this.currentMenu = new neuronsme_LayersMenu(this.rl);
78
+ break;
79
+ case '4':
80
+ console.log('Showing information of neurons.me...');
81
+ console.log(neurons);
82
+ break;
83
+ default:
84
+ console.log('Invalid option. Please choose a valid menu option.');
85
+ }
86
+ this.currentMenu.display();
87
+ }
88
+ }
89
+ class neuronsme_NeuronsMenu extends Menu {
90
+ constructor(app) {
91
+ super(app.rl);
92
+ this.app = app; // Store the reference to the main app
93
+ }
94
+ async display() {
95
+ console.log('\nNeurons:');
96
+ console.log('0. Back to Home');
97
+ console.log('1. Create a new neuron');
98
+ console.log('2. List all neurons');
99
+ this.rl.prompt();
100
+ }
101
+ async handleInput(input) {
102
+ // Handle input based on the neurons menu options
103
+ // E.g., if input is '1', create a new neuron
104
+ }
105
+ }
106
+ class neuronsme_NeuralNetworksMenu extends Menu {
107
+ constructor(app) {
108
+ super(app.rl); // Pass the readline interface to the parent class
109
+ this.app = app; // Store the reference to the main app
110
+ }
111
+ async display() {
112
+ console.log('\nNeural Networks:');
113
+ console.log('0. Back to Home');
114
+ console.log('1. Create a new neural network');
115
+ console.log('2. List all neural networks');
116
+ this.rl.prompt();
117
+ }
118
+ async handleInput(input) {
119
+ // Handle input based on the neural networks menu options
120
+ // E.g., if input is '1', create a new neural network
121
+ }
122
+ }
123
+ class neuronsme_LayersMenu extends Menu {
124
+ constructor(app) {
125
+ super(app.rl); // Pass the readline interface to the parent class
126
+ this.app = app; // Store the reference to the main app
127
+ }
128
+ async display() {
129
+ console.log('\nLayers:');
130
+ console.log('0. Back to Home');
131
+ console.log('1. Create a new layer');
132
+ console.log('2. List all layers');
133
+ this.rl.prompt();
134
+ }
135
+ async handleInput(input) {
136
+ // Handle input based on the layers menu options
137
+ // E.g., if input is '1', create a new layer
138
+ }
139
+ }
140
+
141
+ class NeuronsMeApp {
142
+ constructor() {
143
+ this.rl = readline.createInterface({
144
+ input: process.stdin,
145
+ output: process.stdout,
146
+ });
147
+ this.currentMenu = new neuronsme_MainMenu(this); // Pass the entire app instance
148
+ this.currentMenu.display(); // Display the main menu
149
+ }
150
+ start() {
151
+ this.rl.setPrompt('neurons.me> '); // Use 'this.rl'
152
+ this.rl.prompt();
153
+ this.rl.on('line', (input) => {
154
+ this.currentMenu.handleInput(input.trim());
155
+ }).on('close', () => {
156
+ console.log('Exiting .me');
157
+ process.exit(0);
158
+ });
159
+ }
160
+ }
161
+ const neurons_me_app_init = new NeuronsMeApp();
162
+ neurons_me_app_init.start();
package/neurons.js ADDED
@@ -0,0 +1,4 @@
1
+ const neurons = require('neurons.me');
2
+ console.log(neurons.defacto.getModule('Cleaker'));
3
+ console.log(neurons.scripts);
4
+ console.log(neurons.NeuralNetwork);
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "this.me",
3
+ "version": "2.1.5",
4
+ "description": "CLI for managing the .me suite.",
5
+ "bin": {
6
+ ".me": "./index.js"
7
+ },
8
+ "main": "index.js",
9
+ "scripts": {
10
+ "test": "test"
11
+ },
12
+ "keywords": [
13
+ "me",
14
+ "DeepLearning",
15
+ "neuralnetworks",
16
+ "uthopias"
17
+ ],
18
+ "author": "suiGn",
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "neurons.me": "^2.2.9",
22
+ "cleaker": "^2.1.0",
23
+ "monadlisa": "^2.1.1",
24
+ "netget": "^2.1.6",
25
+ "v.path": "^2.1.3",
26
+ "@sui.gn/haiku": "1.2.2",
27
+ "@sui.gn/me": "2.1.3"
28
+ }
29
+ }
@@ -0,0 +1,29 @@
1
+ const neurons = require('neurons.me');
2
+ const { logError } = require('./errorHandler');
3
+ module.exports = (rl) => {
4
+ const showLayerMenu = () => {
5
+ console.log('\nLayers:');
6
+ console.log('1. Create a new layer');
7
+ console.log('2. List all layers');
8
+ console.log('3. Back to Main Menu');
9
+ };
10
+
11
+ const createLayer = () => {
12
+ // Logic to create a new layer
13
+ const layer = new neurons.Layer();
14
+ console.log('New layer created:', layer);
15
+ };
16
+
17
+ const listAllLayers = () => {
18
+ const allLayers = neurons.Layer.map;
19
+ if (allLayers.size === 0) {
20
+ console.log('No layers found.');
21
+ } else {
22
+ console.log('List of all layers:');
23
+ allLayers.forEach((layer, id) => {
24
+ console.log(`Layer ID: ${id}`, layer);
25
+ });
26
+ }
27
+ };
28
+ return { showLayerMenu, createLayer, listAllLayers };
29
+ };// end module exports
@@ -0,0 +1,32 @@
1
+ const neurons = require('neurons.me');
2
+ const { logError } = require('./errorHandler');
3
+ const prompt = (question) => new Promise((resolve) => rl.question(question, resolve));
4
+
5
+ module.exports = (rl) => {
6
+ const showNeuralNetworkMenu = () => {
7
+ console.log('\nNeural Networks:');
8
+ console.log('1. Create a new neural network');
9
+ console.log('2. List all neural networks');
10
+ console.log('3. Back to Main Menu');
11
+ };
12
+
13
+ const createNeuralNetwork = () => {
14
+ // Logic to create a new neural network
15
+ const neuralNetwork = new neurons.NeuralNetwork();
16
+ console.log('New neural network created:', neuralNetwork);
17
+ };
18
+
19
+ const listAllNeuralNetworks = () => {
20
+ const allNeuralNetworks = neurons.NeuralNetwork.map;
21
+ if (allNeuralNetworks.size === 0) {
22
+ console.log('No neural networks found.');
23
+ } else {
24
+ console.log('List of all neural networks:');
25
+ allNeuralNetworks.forEach((neuralNetwork, id) => {
26
+ console.log(`Neural Network ID: ${id}`, neuralNetwork);
27
+ });
28
+ }
29
+ };
30
+
31
+ return { showNeuralNetworkMenu, createNeuralNetwork, listAllNeuralNetworks };
32
+ };
@@ -0,0 +1,201 @@
1
+ // ./src/NeuronsHandler.js
2
+ const neurons = require('neurons.me');
3
+ const { logError } = require('@sui.gn/me/src/errorHandler');
4
+ const { showMenu } = require('./utils');
5
+ const prompt = (rl, question) => new Promise((resolve) => rl.question(question, resolve));
6
+ //neuron handler
7
+ module.exports = (rl) => {
8
+ const showNeuronMenu = () => {
9
+ console.log('\nNeurons:');
10
+ console.log('0. Back to Main Menu');
11
+ console.log('1. Create a new neuron');
12
+ console.log('2. List all neurons');
13
+ console.log('3. Editing Neurons');
14
+ };
15
+ const neuronConfig = async (rl, neuron, updateNeuronProperties, cloneNeuron) => {
16
+ console.log(`\nTailoring Neuron ID: ${neuron.processID}`);
17
+ console.log('0. Back to Main Menu');
18
+ console.log('1. Edit Properties.');
19
+ console.log('2. Clone this neuron');
20
+ console.log('3. Back to Neurons Menu');
21
+ const action = await prompt(rl, 'Choose an action: ');
22
+ switch (action.trim()) {
23
+ case '0':
24
+ showMenu(rl);
25
+ break;
26
+ case '1':
27
+ await updateNeuronProperties(neuron, rl, neuronConfig);
28
+ break;
29
+ case '2':
30
+ await cloneNeuron(neuron, rl, neuronConfig);
31
+ break;
32
+ case '3':
33
+ showNeuronMenu();
34
+ break;
35
+ default:
36
+ console.log('Invalid action. Back to Neuron Menu.');
37
+ showNeuronMenu();
38
+ }
39
+ };
40
+ const showNeuronProperties = (neuron) => {
41
+ console.log('\nSelected Neuron Properties:');
42
+ console.log('Selected Neuron ID:', neuron.processID);
43
+ console.log('Name:', neuron.name);
44
+ console.log('Date:', neuron.date);
45
+ console.log('Time:', neuron.time);
46
+ console.log('Color:', neuron.color);
47
+ console.log('Activation Function:', neuron.activationFunction.toString());
48
+ console.log('Weights:', neuron.weights);
49
+ console.log('Bias:', neuron.bias);
50
+ };
51
+ const promptNeuronConfig = async (rl, updateNeuronProperties, cloneNeuron, showMenu) => {
52
+ try {
53
+ const option = await prompt('Choose the ID of the neuron you want to access (or "back" to go back): ');
54
+ if (option.toLowerCase() === 'back') {
55
+ showNeuronMenu();
56
+ } else {
57
+ const neuronId = parseInt(option);
58
+ const neuron = neurons.Neuron.map.get(neuronId);
59
+ if (!neuron) {
60
+ console.log('Neuron with the specified ID not found.');
61
+ await promptNeuronConfig(updateNeuronProperties, cloneNeuron, showMenu);
62
+ } else {
63
+ await neuronConfig(neuron, updateNeuronProperties, cloneNeuron, showMenu);
64
+ }
65
+ }
66
+ } catch (error) {
67
+ logError(error);
68
+ }
69
+ };
70
+ const listAllNeurons = () => {
71
+ const allNeurons = neurons.Neuron.map;
72
+ if (allNeurons.size === 0) {
73
+ console.log('No neurons found.');
74
+ } else {
75
+ console.log('List of all neurons:');
76
+ allNeurons.forEach((neuron, id) => {
77
+ console.log(`${id}.`, neuron);
78
+ });
79
+ }
80
+ showMenu(rl, showNeuronMenu);
81
+ };
82
+ const createNeuron = async (rl, updateNeuronProperties, cloneNeuron, showMenu) => {
83
+ try {
84
+ const name = await prompt(rl, 'Enter the name of the neuron: ');
85
+ const color = await prompt(rl, 'Enter the color: ');
86
+ const activation = await prompt(rl, 'Enter the activation function: ');
87
+ const weights = await prompt(rl, 'Enter the weights: ');
88
+ const bias = await prompt(rl, 'Enter the bias: ');
89
+ const neuronOptions = {
90
+ name,
91
+ color,
92
+ activation,
93
+ weights,
94
+ bias,
95
+ };
96
+ const neuron = new neurons.Neuron(neuronOptions);
97
+ console.log('New neuron created:', neuron);
98
+ await neuronConfig(rl, neuron, updateNeuronProperties, cloneNeuron, showMenu);
99
+ } catch (error) {
100
+ logError(error);
101
+ }
102
+ };
103
+ const cloneNeuron = async (neuron, rl, updateNeuronProperties, showMenu) => {
104
+ try {
105
+ const name = await prompt(rl, 'Enter the name of the new neuron: ');
106
+
107
+ const clonedNeuron = new neurons.Neuron({
108
+ ...neuron,
109
+ name,
110
+ });
111
+
112
+ console.log('New neuron cloned:', clonedNeuron);
113
+ showNeuronActions(clonedNeuron, rl, updateNeuronProperties, cloneNeuron, showMenu);
114
+ } catch (error) {
115
+ logError(error);
116
+ }
117
+ };
118
+ const updateNeuronProperties = async (rl, neuron, cloneNeuron, showMenu) => {
119
+ try {
120
+ console.log('\nSelected Neuron Properties:');
121
+ showNeuronProperties(neuron);
122
+ const confirmation = await prompt(rl, '\nAre you sure you want to update properties? (yes/no): ');
123
+ if (confirmation.trim().toLowerCase() !== 'yes') {
124
+ console.log('Update canceled. Back to Neuron Menu.');
125
+ showNeuronActions(neuron, rl, updateNeuronProperties, cloneNeuron, showMenu);
126
+ return;
127
+ }
128
+ let updatedActivation = neuron.activationFunction.toString();
129
+ let updatedWeights = neuron.weights;
130
+ let updatedBias = neuron.bias;
131
+ while (true) {
132
+ console.log('\n1. Enter the new activation function');
133
+ console.log('2. Enter the new weights');
134
+ console.log('3. Enter the new bias');
135
+ console.log('4. Update all properties');
136
+ console.log('5. Save changes');
137
+ console.log('6. Back');
138
+ const propertyAction = await prompt(rl, '\nChoose an action: ');
139
+ switch (propertyAction.trim()) {
140
+ case '1':
141
+ updatedActivation = await prompt(rl, 'Enter the new activation function: ');
142
+ break;
143
+ case '2':
144
+ updatedWeights = await prompt(rl, 'Enter the new weights: ');
145
+ break;
146
+ case '3':
147
+ updatedBias = await prompt(rl, 'Enter the new bias: ');
148
+ break;
149
+ case '4':
150
+ const confirmUpdateAll = await prompt(rl, '\nAre you sure you want to update all properties? (yes/no): ');
151
+ if (confirmUpdateAll.trim().toLowerCase() === 'yes') {
152
+ updatedActivation = await prompt(rl, 'Enter the new activation function: ');
153
+ updatedWeights = await prompt(rl, 'Enter the new weights: ');
154
+ updatedBias = await prompt(rl, 'Enter the new bias: ');
155
+ }
156
+ break;
157
+ case '5':
158
+ neuron.activationFunction = eval(updatedActivation); // Converting the updatedActivation string back to a function
159
+ neuron.weights = updatedWeights;
160
+ neuron.bias = updatedBias;
161
+ console.log('\nUpdated Neuron Properties:');
162
+ neuronConfig(rl, neuron, updateNeuronProperties, cloneNeuron, showMenu);
163
+ const finalConfirmation = await prompt(rl, '\nDo you want to apply these changes? (yes/no): ');
164
+ if (finalConfirmation.trim().toLowerCase() !== 'yes') {
165
+ console.log('Changes not applied. Back to Neuron Menu.');
166
+ } else {
167
+ console.log('Neuron properties updated successfully.');
168
+ }
169
+ neuronConfig(rl, neuron, updateNeuronProperties, cloneNeuron, showMenu);
170
+ return;
171
+ case '6':
172
+ console.log('Update canceled. Back to Neuron Menu.');
173
+ neuronConfig(rl, neuron, updateNeuronProperties, cloneNeuron, showMenu);
174
+ return;
175
+ default:
176
+ console.log('Invalid action. Please choose a valid action.');
177
+ }
178
+ }
179
+ } catch (error) {
180
+ logError(error);
181
+ }
182
+ };
183
+ return {
184
+ showNeuronMenu,
185
+ promptNeuronConfig,
186
+ listAllNeurons,
187
+ createNeuron,
188
+ neuronConfig,
189
+ updateNeuronProperties,
190
+ cloneNeuron
191
+ };
192
+ }
193
+
194
+ /*Input Validation: It would be better to add some form of input validation.
195
+ For example, when setting the weights or bias of a neuron,
196
+ you could check that the user's input is a valid number.
197
+ Security: Be careful when using eval().
198
+ eval() evaluates a string of JavaScript code in the global context,
199
+ which can lead to security issues. If the string comes from an untrusted source,
200
+ it can potentially run malicious code. If you need to convert a string to a function,
201
+ consider safer alternatives.*/
@@ -0,0 +1,9 @@
1
+ const logError = (error) => {
2
+ console.error('An error occurred:', error.message);
3
+ process.exit(1);
4
+ };
5
+
6
+ module.exports = {
7
+ logError,
8
+ };
9
+
package/src/utils.js ADDED
@@ -0,0 +1,17 @@
1
+ //CLASSES
2
+ class Menu {
3
+ constructor(rl) {
4
+ this.rl = rl;
5
+ }
6
+ prompt(question) {
7
+ return new Promise((resolve) => this.rl.question(question, resolve));
8
+ }
9
+ async display() {
10
+ throw new Error('Method display() must be implemented by subclass');
11
+ }
12
+ async handleInput(input) {
13
+ throw new Error('Method handleInput() must be implemented by subclass');
14
+ }
15
+ }
16
+
17
+ module.exports = Menu;
package/test.js ADDED
@@ -0,0 +1,13 @@
1
+ const neurons = require('neurons.me');
2
+ // Custom options for the neuron
3
+ let options = {
4
+ name: 'x', // Custom name for the neuron
5
+ date: '2023-07-25', // Custom date
6
+ time: '12:30 PM', // Custom time
7
+ color: 'blue', // Custom color
8
+ activationFunction: x => x * 2 // Custom activation function
9
+ };
10
+ // Create a neuron with custom options
11
+ let neuron = new neurons.createNeuron({ options: options });
12
+ let layer = new neurons.Layer({ neurons: [neuron] });
13
+ console.log(layer.map);
package/x.js ADDED
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ const readline = require('readline');
3
+ const neurons = require('neurons.me');
4
+ const { logError } = require('./src/errorHandler');
5
+ const { Menu } = require('./src/utils');
6
+ const NeuronsHandler = require('@sui.gn/me/src/NeuronsHandler');
7
+ const NeuralNetworksHandler = require('@sui.gn/me/src/NeuralNetworksHandler');
8
+ const LayersHandler = require('@sui.gn/me/src/LayersHandler');
9
+ class neuronsme_MainMenu extends Menu {
10
+ async display() {
11
+ console.log('\nWelcome to neurons.me type /q to close:');
12
+ console.log('1. Neurons: Create, list, update, and delete neurons');
13
+ console.log('2. Neural Networks: Create, list, update, and delete neural networks');
14
+ console.log('3. Layers: Create, list, update, and delete layers');
15
+ console.log('4. Show Info...');
16
+ this.rl.prompt();
17
+ }
18
+ async handleInput(input) {
19
+ switch (input) {
20
+ case '/q':
21
+ this.rl.close();
22
+ break;
23
+ case '1':
24
+ this.currentMenu = new neuronsme_NeuronsMenu(this.rl);
25
+ break;
26
+ case '2':
27
+ this.currentMenu = new neuronsme_NeuralNetworksMenu(this.rl);
28
+ break;
29
+ case '3':
30
+ this.currentMenu = new neuronsme_LayersMenu(this.rl);
31
+ break;
32
+ case '4':
33
+ console.log('Showing information of neurons.me...');
34
+ console.log(neurons);
35
+ break;
36
+ default:
37
+ console.log('Invalid option. Please choose a valid menu option.');
38
+ }
39
+ this.currentMenu.display();
40
+ }
41
+ }
42
+ class neuronsme_NeuronsMenu extends Menu {
43
+ async display() {
44
+ console.log('\nNeurons:');
45
+ console.log('0. Back to Home');
46
+ console.log('1. Create a new neuron');
47
+ console.log('2. List all neurons');
48
+ this.rl.prompt();
49
+ }
50
+ async handleInput(input) {
51
+ // Handle input based on the neurons menu options
52
+ // E.g., if input is '1', create a new neuron
53
+ }
54
+ }
55
+ class neuronsme_NeuralNetworksMenu extends Menu {
56
+ async display() {
57
+ console.log('\nNeural Networks:');
58
+ console.log('0. Back to Home');
59
+ console.log('1. Create a new neural network');
60
+ console.log('2. List all neural networks');
61
+ this.rl.prompt();
62
+ }
63
+ async handleInput(input) {
64
+ // Handle input based on the neural networks menu options
65
+ // E.g., if input is '1', create a new neural network
66
+ }
67
+ }
68
+ class neuronsme_LayersMenu extends Menu {
69
+ async display() {
70
+ console.log('\nLayers:');
71
+ console.log('0. Back to Home');
72
+ console.log('1. Create a new layer');
73
+ console.log('2. List all layers');
74
+ this.rl.prompt();
75
+ }
76
+ async handleInput(input) {
77
+ // Handle input based on the layers menu options
78
+ // E.g., if input is '1', create a new layer
79
+ }
80
+ }
81
+ class neuronsmeApp {
82
+ constructor() {
83
+ this.rl = readline.createInterface({
84
+ input: process.stdin,
85
+ output: process.stdout,
86
+ });
87
+ this.currentMenu = new neuronsme_MainMenu(this.rl);
88
+ }
89
+ start() {
90
+ this.rl.prompt();
91
+ this.rl.on('line', (input) => {
92
+ this.currentMenu.handleInput(input.trim());
93
+ }).on('close', () => {
94
+ console.log('Exiting .me');
95
+ process.exit(0);
96
+ });
97
+ }
98
+ }
99
+ const neurons_me_app_init = new neuronsmeApp();
100
+ neurons_me_app_init.start();
package/y.js ADDED
@@ -0,0 +1,207 @@
1
+ #!/usr/bin/env node
2
+ const readline = require('readline');
3
+ const neurons = require('neurons.me');
4
+ const { logError } = require('./src/errorHandler');
5
+ const { showMenu } = require('./src/utils');
6
+ const NeuronsHandler = require('@sui.gn/me/src/NeuronsHandler');
7
+ const NeuralNetworksHandler = require('@sui.gn/me/src/NeuralNetworksHandler');
8
+ const LayersHandler = require('@sui.gn/me/src/LayersHandler');
9
+ // Create the readline interface
10
+ let rl = readline.createInterface({
11
+ input: process.stdin,
12
+ output: process.stdout,
13
+ });
14
+ /*
15
+ ┳┓┏┓┳┳┳┓┏┓┳┓┏┓
16
+ ┃┃┣ ┃┃┣┫┃┃┃┃┗┓
17
+ ┛┗┗┛┗┛┛┗┗┛┛┗┗┛
18
+ neurons SECTION...*/
19
+ let neuronsHandlerINIT = NeuronsHandler(rl);
20
+ const promptNeuronConfig = async () => {
21
+ await neuronsHandlerINIT.promptNeuronConfig(rl);
22
+ };
23
+ const createNeuronWrapper = async () => {
24
+ await neuronsHandlerINIT.createNeuron(rl);
25
+ };
26
+ // List all neurons
27
+ const listAllNeuronsWrapper = () => {
28
+ neuronsHandlerINIT.listAllNeurons();
29
+ };
30
+ // Update neuron properties
31
+ const updateNeuronPropertiesWrapper = async (neuron) => {
32
+ await neuronsHandlerINIT.updateNeuronProperties(neuron);
33
+ };
34
+ // Clone neuron
35
+ const cloneNeuronWrapper = async (neuron) => {
36
+ await neuronsHandlerINIT.cloneNeuron(neuron);
37
+ };
38
+ // Show neuron actions
39
+ const neuronConfigWrapper = async (neuron) => {
40
+ await neuronsHandlerINIT.neuronConfig(rl, neuron, updateNeuronPropertiesWrapper, cloneNeuronWrapper, showMenu);
41
+ };
42
+ /*
43
+ ┳┓┏┓┳┳┳┓┏┓┓ ┳┓┏┓┏┳┓┓ ┏┏┓┳┓┓┏┓┏┓
44
+ ┃┃┣ ┃┃┣┫┣┫┃ ┃┃┣ ┃ ┃┃┃┃┃┣┫┃┫ ┗┓
45
+ ┛┗┗┛┗┛┛┗┛┗┗┛┛┗┗┛ ┻ ┗┻┛┗┛┛┗┛┗┛┗┛
46
+ neuralNetworks SECTION... */
47
+ const neuralnetworksHandlerINIT = NeuralNetworksHandler(rl);
48
+ const createNeuralNetworkWrapper = async () => {
49
+ await neuralnetworksHandlerINIT.createNeuronNetwork();
50
+ };
51
+ const listAllNeuralNetworksWrappers = async () => {
52
+ await neuralnetworksHandlerINIT.listAllNeuralNetworks();
53
+ };
54
+ /*
55
+ ╦ ╔═╗╦ ╦╔═╗╦═╗╔═╗
56
+ ║ ╠═╣╚╦╝║╣ ╠╦╝╚═╗
57
+ ╩═╝╩ ╩ ╩ ╚═╝╩╚═╚═╝
58
+ layers section... */
59
+ const layersHandlerINIT = LayersHandler(rl);
60
+ const createLayerWrapper = async () => {
61
+ layersHandlerINIT.createLayer();
62
+ };
63
+ const listAllLayersWrapper = () => {
64
+ layersHandlerINIT.listAllLayers();
65
+ };
66
+ /*
67
+ ╔╦╗╔═╗╦╔╗╔╔╦╗╔═╗╔╗╔╦ ╦
68
+ ║║║╠═╣║║║║║║║║╣ ║║║║ ║
69
+ ╩ ╩╩ ╩╩╝╚╝╩ ╩╚═╝╝╚╝╚═╝
70
+ main menu... */
71
+ // MAIN MENU OPTIONS - INDEX ENTRY POINT OF .ME CLI
72
+ let currentMenu = 'main';
73
+ const displayMainMenu = () => {
74
+ console.log('\nMain Menu:');
75
+ console.log('1. Neurons');
76
+ console.log('2. Neural networks');
77
+ console.log('3. Layer');
78
+ console.log('4. Show information about available classes and methods');
79
+ console.log('5. Exit');
80
+ };
81
+
82
+ /*
83
+ ┌─┐┌┬┐┌─┐┬─┐┌┬┐
84
+ └─┐ │ ├─┤├┬┘ │
85
+ └─┘ ┴ ┴ ┴┴└─ ┴
86
+ starting shell session npx .me shell ->*/
87
+ // Starting shell session
88
+ const startShellSession = () => {
89
+ rl.setPrompt('.me> '); // Display the initial prompt
90
+ rl.prompt();
91
+ // Handle user input
92
+ rl.on('line', async (input) => {
93
+ const command = input.trim();
94
+ if (command === '') {
95
+ // Empty input, just re-prompt the current menu
96
+ showMenu(rl, neuronsHandlerINIT.showNeuronMenu);
97
+
98
+ return;
99
+ }
100
+ switch (currentMenu) {
101
+ case 'neuron':
102
+ switch (command) {
103
+ case '1':
104
+ await createNeuronWrapper();
105
+ break;
106
+ case '2':
107
+ listAllNeuronsWrapper();
108
+ break;
109
+ case '3':
110
+ promptNeuronConfig();
111
+ break;
112
+ default:
113
+ console.log('Invalid command. Type the number of the desired option.');
114
+ showMenu(rl, neuronsHandlerINIT.showNeuronMenu);
115
+
116
+ }
117
+ break;
118
+ case 'neuralnetwork':
119
+ switch (command) {
120
+ case '1':
121
+ createNeuralNetworkWrapper();
122
+ break;
123
+ case '2':
124
+ listAllNeuralNetworksWrappers();
125
+ break;
126
+ case '3':
127
+ currentMenu = 'main';
128
+ showMenu(rl, neuronsHandlerINIT.showNeuronMenu);
129
+
130
+ break;
131
+ default:
132
+ console.log('Invalid command. Type the number of the desired option.');
133
+ showMenu(rl, neuronsHandlerINIT.showNeuronMenu);
134
+
135
+ }
136
+ break;
137
+ case 'layer':
138
+ switch (command) {
139
+ case '1':
140
+ createLayerWrapper();
141
+ break;
142
+ case '2':
143
+ listAllLayersWrapper();
144
+ break;
145
+ case '3':
146
+ currentMenu = 'main';
147
+ showMenu(rl, neuronsHandlerINIT.showNeuronMenu);
148
+ break;
149
+ default:
150
+ console.log('Invalid command. Type the number of the desired option.');
151
+ showMenu(rl, neuronsHandlerINIT.showNeuronMenu);
152
+ }
153
+ break;
154
+ default:
155
+ switch (command) {
156
+ case '1':
157
+ currentMenu = 'neuron';
158
+ showMenu(rl, neuronsHandlerINIT.showNeuronMenu);
159
+
160
+ break;
161
+ case '2':
162
+ currentMenu = 'neuralnetwork';
163
+ showMenu(rl, neuronsHandlerINIT.showNeuronMenu);
164
+
165
+ break;
166
+ case '3':
167
+ currentMenu = 'layer';
168
+ showMenu(rl, neuronsHandlerINIT.showNeuronMenu);
169
+
170
+ break;
171
+ case '4':
172
+ console.log('Available classes and methods:');
173
+ console.log(neurons);
174
+ showMenu(rl, neuronsHandlerINIT.showNeuronMenu);
175
+
176
+ break;
177
+ case '5':
178
+ rl.close();
179
+ break;
180
+ case 'menu':
181
+ case 'showmenu':
182
+ showMenu(rl, neuronsHandlerINIT.showNeuronMenu);
183
+
184
+ break;
185
+ default:
186
+ console.log('Invalid command. Type "exit" to quit the session or use "menu" to see options.');
187
+ showMenu(rl, neuronsHandlerINIT.showNeuronMenu);
188
+
189
+ }
190
+ }
191
+ }).on('close', () => {
192
+ console.log('Exiting .me');
193
+ process.exit(0);
194
+ });
195
+ };
196
+ // Define the main 'shell' command
197
+ const mainCommand = process.argv[2];
198
+ if (mainCommand === 'shell') {
199
+ // Start the interactive shell session when the 'shell' command is run
200
+ startShellSession();
201
+ // Display the main menu
202
+ showMenu(rl, displayMainMenu); // Corrected line
203
+ } else {
204
+ // Show usage or help message when the main command is not recognized
205
+ console.log('Usage: .me shell');
206
+ console.log('Type ".me shell" to enter the interactive shell mode.');
207
+ }