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

@ronaldzav/chatbot

v1.0.1

Published

Generar respuestas automáticas basadas en un conjunto de opciones de entrada y salida, y también permite realizar cálculos matemáticos simples a partir de texto.

Downloads

166

Readme

🤖 CHATBOT

Generar respuestas automáticas basadas en un conjunto de opciones de entrada y salida, y también permite realizar cálculos matemáticos simples a partir de texto.

Instalación

Asegúrate de que tienes Node.js instalado. Luego, puedes instalar este paquete en tu proyecto ejecutando:

npm install @ronaldzav/chatbot

🛠️ Uso

const { ChatGeneration } = require('@ronaldzav/chatbot');

const chat = new ChatGeneration()
    .setName("Roni Bot")
    .setOptions([{
        input: ["Hola", "Qué tal"],
        output: ["Hola, ¿cómo estás?", "¡Qué gusto saludarte!"]
    }, {
        input: ["Adiós", "Hasta luego"],
        output: ["Adiós, que tengas un buen día", "Hasta pronto!"]
    }]);

const response = chat.send("Hola");
console.log(response); // => "Hola, ¿cómo estás?" o "¡Qué gusto saludarte!"

📡 API

ChatGeneration

La clase ChatGeneration te permite definir opciones de interacción y generar respuestas basadas en las entradas del usuario. Las respuestas se pueden personalizar con un nombre y con un nivel de precisión para mejorar la correspondencia de las respuestas.

🔌 Propiedades

name (string):

El nombre que usará el bot o el chat en las respuestas.

accuracy (number):

Define qué tan precisa debe ser la comparación entre el mensaje del usuario y las entradas definidas. Por defecto, es 40 (40% de coincidencia).

options (array):

Conjunto de opciones que contienen entradas posibles del usuario y las respuestas correspondientes.

📬 Métodos

setName(name: string):

Establece el nombre que se utilizará en las respuestas. Retorna la instancia para permitir encadenamiento de métodos.

chat.setName("Roni Bot");

setAccuracy(accuracy: number):

Define la precisión para las respuestas. Cuanto más alto el valor, más exacta debe ser la coincidencia de texto con las entradas definidas. El valor debe estar entre 0 y 100.

chat.setAccuracy(50); // Se requiere una coincidencia del 50%

setOptions(options: array):

Define las posibles entradas y respuestas del chat. Cada opción es un objeto que contiene un arreglo input con posibles entradas del usuario y un arreglo output con posibles respuestas.

chat.setOptions([
  {
    input: ["Hola", "Qué tal"],
    output: ["Hola, ¿cómo estás?", "¡Qué gusto saludarte!"]
  },
  {
    input: ["Adiós", "Hasta luego"],
    output: ["Adiós, que tengas un buen día", "Hasta pronto!"]
  }
]);

send(message: string): string

Envía un mensaje al chat para obtener una respuesta. Si el mensaje coincide con alguna de las entradas en las opciones, devolverá una respuesta aleatoria de las definidas. Si no hay coincidencias, se devuelve una respuesta predeterminada.

const response = chat.send("Hola");
console.log(response); // => "Hola, ¿cómo estás?" o "¡Qué gusto saludarte!"

📐 Resolución de Matematica Basica

Reconocimiento de Expresiones Matemáticas ChatGeneration también es capaz de detectar cálculos matemáticos en texto. Si el mensaje contiene palabras como "calcula", "resuelve" o "problema", intentará interpretar la expresión matemática y devolver el resultado.

Ejemplos de expresiones matemáticas soportadas:

5 mas 3 (suma)
10 menos 2 (resta)
4 por 2 (multiplicación)
9 dividido 3 (división)
2 elevado a 3 (potencia)
const response = chat.send("Calcula 5 mas 3");
console.log(response); // => "El resultado de 5+3 es 8"