Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@optimaxer/web-commands
Advanced tools
Welcome to the **@Optimaxer/Web-Commands** library documentation! Developed under the Optimaxer framework by 99x-Labs, this open-source frontend library is a groundbreaking tool that enables users to run small language models directly on their end devices
Welcome to the @Optimaxer/Web-Commands library documentation! Developed under the Optimaxer framework by 99x-Labs, this open-source frontend library is a groundbreaking tool that enables users to run small language models directly on their end devices. By integrating this library into their products, developers can automate simple tasks through natural language queries in their web applications.
The web-command library offers a seamless and efficient way to enhance user experiences without requiring extensive computational resources or backend scaling solutions. By utilizing the end user's device resources, this library ensures data privacy and leverages advanced algorithms, vector databases, and compact language models to deliver accurate and effective results.
Due to the restrictions of the Firefox browser, these libraries and functionalities may not work well on Firefox. Please note this limitation.
Getting started with the web-command library is straightforward. Follow these steps to integrate and utilize the library in your web application effectively.
First, you need to add the web-command library to your project. Use the following npm command:
npm install @optimaxer/web-commands
You need three JSON configuration files: config.json
, commands.json
, and actions.json
. These files define the overall configuration, commands, and actions of your automation pipeline.
configs.json
)The config.json
file is essential for defining the entities and their associated actions within your application. Each object in the file represents an entity and contains the necessary details for executing specific actions.
A config object has the following structure:
Here's an example of a config file having an entity named "Order":
[
{
"name": "Order",
"id": 1,
"actions": {
"new": {
"endpoint": "",
"params": {},
"functionName": "createNewOrder"
},
"edit": {
"endpoint": "order/edit/${order_id}",
"params": {
"order_id": "Extract the id of the order"
}
},
"delete": {
"endpoint": "order/delete/${order_id}",
"params": {
"order_id": "Extract the id of the order"
},
"functionName": "deleteOrder",
"validations": {
"order_id": "function order_id(order_id) { return !isNaN(num) && typeof num === 'number' && isFinite(num); }"
}
}
}
}
]
commands.json
)The commands.json
file is used to define sample commands and map them to the appropriate entity IDs. This file helps create embeddings that facilitate the identification of entities based on user commands.
The commands file has the following structure:
config.json
file.To ensure that any changes made to the commands file are applied and the index database is updated, make sure to increment the version of the command file each time you make changes to the command file.
Here's an example of a command file for various "order" commands:
{
"version": "1.0.1",
"data":[
{
"content": "show order",
"metadata": {
"id": 1
}
},
{
"content": "I want to place a new order",
"metadata": {
"id": 1
}
}
]
}
actions.json
)The actions.json
file is used to define actions (verbs) and their associated metadata. This file helps create embeddings that enable the identification of user intents or actions in real-time based on user commands.
The actions file has the following structure:
config.json
file.To ensure that any changes made to the actions file are applied and the index database is updated, make sure to increment the version of the action file each time you make changes to the command file.
Here's an example of an action object:
{
"version": "1.0.1",
"data":[
{
"content": "update",
"metadata": {
"name": "edit"
}
},
{
"content": "delete",
"metadata": {
"name": "delete"
}
}
]
}
Load your command and action definitions from the JSON files and initialize the CommandPipeline
. Here's an example:
// Import the library
import { CommandPipeline } from '@optimaxer/web-commands';
// Function to load JSON files (example implementation)
async function loadJson(filePath) {
const response = await fetch(filePath);
return await response.json();
}
// Load command and action definitions from JSON files
const commandJson = await loadJson('/commands.json');
const actionsJson = await loadJson('/actions.json');
const configsJson = await loadJson('/config.json');
// Initiate Command Pipeline and Set up the pipeline with the loaded commands and actions
const cmdPipeline = await CommandPipeline.setup(configsJson, commandJson, actionsJson, {});
function createNewOrder(params) {
// Logic to create a new order
console.log('Order created with params:', params);
}
function deleteOrder(params) {
// Logic to delete an existing order
console.log('Order deleted with params:', params);
}
// Define the function registry
const functionRegistry = {
createNewOrder,
deleteOrder
};
To run the command pipeline, load the configuration file and execute the pipeline with a user command.
// Run the pipeline with a user command, configuration, model type, and function registry
const userCommand = 'create new order';
const response = await cmdPipeline.run(userCommand, functionRegistry);
console.log(response);
By following these steps, you can quickly integrate the web-command library into your web application and start automating tasks with natural language commands. For more detailed information and advanced usage, please refer to the other sections of our documentation.
FAQs
Welcome to the **@Optimaxer/Web-Commands** library documentation! Developed under the Optimaxer framework by 99x-Labs, this open-source frontend library is a groundbreaking tool that enables users to run small language models directly on their end devices
We found that @optimaxer/web-commands demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.