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 🙏

© 2026 – Pkg Stats / Ryan Hefner

chat-parameters-utils

v1.0.0

Published

A utility library for processing and managing chat parameters, prompts, and suggested questions

Downloads

4

Readme

Chat Parameters Utils

A utility library for processing and managing chat parameters, prompts, suggested questions, and conversation configuration.

Installation

npm install chat-parameters-utils

Usage

import {
  processParametersNoDify,
  processParameters,
  extractSuggestedQuestions,
  extractOpeningStatement,
  formatSuggestedQuestions,
  createPromptMessage,
  updateMessagesWithPrompt,
  validateParameters,
  mergeParameters,
  createReactiveObject
} from 'chat-parameters-utils';

// Create reactive objects
const PROMPT_MESSAGE = createReactiveObject('');
const messages = createReactiveObject([]);

// Process parameters without Dify API
const containerProps = {
  firstwrod: 'Welcome!',
  cuewordlist: ['How can I help?', 'What would you like to know?']
};

await processParametersNoDify(containerProps, PROMPT_MESSAGE, messages);

// Process parameters from API response
const apiResponse = await fetch('/api/parameters');
await processParameters(apiResponse, PROMPT_MESSAGE, messages);

// Extract and format suggested questions
const parameters = await apiResponse.json();
const questions = extractSuggestedQuestions(parameters);
const formattedTips = formatSuggestedQuestions(questions);

// Create and update prompt message
const prompt = createPromptMessage('New prompt message');
updateMessagesWithPrompt(messages.value, prompt);

// Validate parameters
const isValid = validateParameters(parameters);

// Merge multiple parameters
const merged = mergeParameters(param1, param2, param3);

API Reference

Core Processing Functions

  • processParametersNoDify(ContainerProps, PROMPT_MESSAGE, messages) - Process parameters without Dify API
  • processParameters(parameters, PROMPT_MESSAGE, messages) - Process parameters from API response

Extraction Functions

  • extractSuggestedQuestions(parameters) - Extract suggested questions from parameters
  • extractOpeningStatement(parameters) - Extract opening statement from parameters
  • formatSuggestedQuestions(questions) - Format suggested questions as tips

Message Management

  • createPromptMessage(text) - Create a default prompt message object
  • updateMessagesWithPrompt(messages, promptMessage, index) - Update messages array with prompt

Validation & Utilities

  • validateParameters(parameters) - Validate parameters object structure
  • mergeParameters(...parameters) - Merge multiple parameters objects
  • createReactiveObject(value) - Create a simple reactive object (Vue compatibility)

Features

  • Dual Processing: Support for both API-based and local parameter processing
  • Parameter Extraction: Easy extraction of opening statements and suggested questions
  • Message Management: Comprehensive prompt message creation and management
  • Validation: Robust parameter validation
  • Merging: Ability to merge multiple parameters objects
  • Error Handling: Comprehensive error handling with detailed logging
  • Vue Compatibility: Helper functions for Vue reactivity patterns

Parameter Structure

Expected parameters object structure:

{
  opening_statement: string,      // Opening statement/text
  suggested_questions: string[],  // Array of suggested questions
  cuewordlist: string[],          // Array of cue words
  firstwrod: string               // First word/text
}

Use Cases

  1. Chat Initialization: Process initial parameters for chat sessions
  2. Dynamic Prompts: Update prompts based on user context or API responses
  3. Suggested Questions: Manage and display suggested questions to users
  4. Parameter Validation: Validate incoming parameter objects
  5. Configuration Management: Handle chat configuration parameters

Error Handling

All functions include comprehensive error handling:

try {
  await processParameters(apiResponse, PROMPT_MESSAGE, messages);
} catch (error) {
  console.error('Parameter processing failed:', error);
  // Fallback to default parameters
}

Browser Support

This library requires modern browser features:

  • ES6 Modules
  • Fetch API (for processParameters)
  • Console API for error logging

License

MIT