npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, πŸ‘‹, I’m Ryan HefnerΒ  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you πŸ™

Β© 2024 – Pkg Stats / Ryan Hefner

easy-assistants-sdk

v1.0.3

Published

## πŸš€ Getting Started

Downloads

18

Readme

README.md for easy-assistant-sdk

πŸš€ Getting Started

This guide will help you understand how to integrate and use the easy-assistant-sdk with your applications to interact with the easy-assistant-server. This SDK simplifies sending queries and managing tool functionalities. Prerequisites

Node.js environment
Basic knowledge of JavaScript and Node.js
easy-assistant-server setup and running

Installation

To start using easy-assistant-sdk, follow these steps:

Ensure Node.js is installed on your system.
Clone or download the easy-assistant-sdk repository.
Navigate to the project directory.
Install necessary dependencies (if any).

πŸ› οΈ Configuration

Configure the SDK to connect with your easy-assistant-server:

Import the SDK into your project.
Create an instance of the SDK, providing the server URL and a map of tool functions.

Example:


import { ChatAPI } from 'easy-assistant-sdk';

const serverUrl = 'http://localhost:3001'; // Replace with your server's URL
const toolsMap = {
    // Define your tool functions here
};

const chatApi = new ChatAPI(serverUrl, toolsMap);

πŸ–₯️ Using the SDK

Sending a Query

To send a query, use the sendQuery method. This method sends a user's query to the server and returns the response.

Example:


const response = await chatApi.sendQuery("Your query here");
console.log(response);

Managing Threads

For continuous conversations, manage thread IDs:

Store and reuse thread IDs returned by the server.
Pass the thread ID with subsequent queries to maintain conversation context.

Handling Files

Use getFile to download files:

The SDK provides the getFile method to handle file downloads.
This method takes a file ID and handles the download process.

Example:


chatApi.getFile("file_id_here")
    .then(stream => /* Handle the file stream */)
    .catch(error => console.error(error));

Custom Tools Integration

Integrate custom tools by mapping tool names to functions in the toolsMap.

Example assuming you have a tool called customTool in your assistant:


const toolsMap = {
    customTool: consoleLogTool
};

function consoleLogTool(parameter){
    console.log("consoleLog tool executed with parameter" + parameter)
    return true;
}

Setting Tools Map

Use setToolsMap to update the tools at any time:


const toolsMap = {
    // Define your tool functions here
};

chatApi.setToolsMap(toolsMap);

Viewing the Current Tools Map

Use viewCurrentTools to view the current state of the tools map at any time. This function retrieves and displays the current tools registered in the ToolsHandler. Usage


const viewCurrentTools = () => {
    const currentToolsMap = chatApi.getToolsMap();
    console.log('Current Tools:', currentToolsMap);
};

viewCurrentTools();

Deleting a Tool from the Tools Map

Use removeTool to delete a specific tool from the tools map. This function takes the name of the tool as an argument and removes it from the ToolsHandler. Usage


const removeTool = (toolName) => {
    try {
        chatApi.removeTool(toolName);
        console.log(`Tool ${toolName} successfully removed`);
    } catch (error) {
        console.error(`Error removing tool: ${error.message}`);
    }
};

// Example: Remove a tool named 'exampleTool'
removeTool('exampleTool');

πŸ“ Example Implementation

To see a comprehensive example of how to implement all the features of the easy-assistant-sdk, refer to the src/test/testChatScript.js file in the SDK repository. This script provides a hands-on demonstration and can be directly run using Node.js.

This script demonstrates:

Establishing a connection with the easy-assistant-server.
Sending queries and handling responses.
Managing thread IDs for ongoing conversations.
Using the getFile method for file downloads.
Integrating and using custom tools defined in the toolsMap.

🌟 Features

Simple and intuitive interface for sending queries to easy-assistant-server.
Thread management for maintaining conversation flow.
File handling capabilities for downloading files from the server.
Extensibility for integrating custom client-side tools.

πŸ“š Additional Information

Ensure proper connection and configuration with the easy-assistant-server.
Familiarize yourself with JavaScript and async programming for effective SDK usage.
The SDK is designed to be lightweight and easy to integrate into various projects.

πŸ“ž Support

For support or questions regarding the SDK, contact the maintainer or refer to the documentation.