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

@optimaxer/web-text

v1.2.5

Published

Welcome to the **@optimaxer/web-text** documentation! This library is a powerful tool designed to bring the benefits of generative AI directly to your web applications. By leveraging a small language model that runs on the end user's device, **@optimaxer/

Downloads

373

Readme

@optimaxer/web-text

Welcome to the @optimaxer/web-text documentation! This library is a powerful tool designed to bring the benefits of generative AI directly to your web applications. By leveraging a small language model that runs on the end user's device, @optimaxer/web-text allows you to generate high-quality texts with ease. Whether you're looking to create concise summaries, compelling titles, or even entire text sections, this library offers a flexible and efficient solution. Our goal is to simplify the tasks of your employees, reducing their workload and increasing productivity through intelligent text generation.

Overview

@optimaxer/web-text is a generative AI library that harnesses the power of a small language model to create various types of text content. The library is designed to operate directly within the user's browser, ensuring quick and secure processing without relying on external servers. This makes it an ideal choice for applications where privacy, speed, and ease of integration are crucial.

Key Features:

  • Text Summarization: Automatically condense long documents or articles into brief, coherent summaries that capture the essence of the content.
  • Title Generation: Generate attention-grabbing titles for articles, reports, or other content, tailored to the context and tone of the text.
  • Custom Text Sections: Users have the freedom to generate their own text sections, enabling creative and context-specific content creation.

By integrating @optimaxer/web-text into your applications, you can provide users with a powerful tool that simplifies content creation, streamlines workflows, and enhances overall productivity.

Quickstart

Getting Started with web-text Library

Getting started with @optimaxer/web-text is straightforward. Follow these steps to integrate the library into your project and start generating text content:

Step 1: Install the Library

npm install @optimaxer/web-text

This command will add the library to your project's dependencies.

Step 2: Setting Up the Text Generator

Once the library is installed, you need to set up the Text Generator component. This step involves initializing the Text Generator with the appropriate configurations, including the Small Language Model.

Here’s how to do it:

1. Import the Text Generator component:
import { TextGenerator } from '@optimaxer/web-text';
2. Create an instance of the Text Generator:
const textGenerator = new TextGenerator();
3. Configure the Text Generator:
You need to specify the model and engine for the form. For example, if you are using `gemma` as your model and `media-pipe` as your embedding engine, you can set it up like this:
await textGenerator.setup('gemma', 'media-pipe');

Step 3: Generating Text

Now that everything is set up, you can start generating text. Here's an example of how to create a summary, title, and custom text section:

Generate a Summary

To generate a concise summary of a long text, use the generateSummary method. The second parameter specifies the desired length of the summary:

const summary = await textGenerator.value.generateSummary('Your long text here', 50);

Parameters:

  • Input Text (string): The main text that you want to summarize. This parameter is required and should contain the content that needs to be condensed.

  • Number of Words (number, optional): This optional parameter allows you to specify the desired length of the summary in terms of the number of words. If not provided, the function will generate a summary based on the default settings, balancing conciseness and content coverage.

This command will return a summary that captures the key points of the provided text, making it easier for users to digest large amounts of information quickly.

Generate a Title

Creating an attention-grabbing title is just as easy. The generateTitle method can be used to generate a title based on the given text content:

const title = await textGenerator.value.generateTitle('Your text here');

Parameters:

  • Input Text (string): This parameter is required and decided on which the title is created.

This function is particularly useful for content management systems, blog post generators, or any application where creating compelling titles is essential.

Generate a Custom Text Section

If you need to create a more personalized or context-specific section of text, you can use the generateText method:

const customText = textGenerator.generateText('Your text here', 'Your custom text type');

Parameters:

  • Input Text (string): The text that serves as the basis for the generated content. This is the core content from which the custom text will be derived.

  • Custom Text Type (string): This parameter specifies the type of custom text you want to generate. It could be an abstract, order note, subtitle, or any other defined category. This ensures that the generated content is contextually relevant to the specific use case.

  • Number Of Words (number, optional): An optional parameter that defines the length of the custom text in terms of the number of words. If not specified, the function will use default settings to create a text section of appropriate length.

This allows you to tailor the generated text to specific requirements, making it adaptable to a wide range of applications and user needs.

When using the generateText function, it's important to define the customTextType in a clear and easily understandable manner. Using simple and specific terms like "abstract," "order note," or "subtitle" helps the text generator produce content that closely aligns with your intended output. Avoid overly complex or ambiguous text types, as this could lead to less accurate or relevant generated text. Keeping it straightforward ensures the best results for your custom text sections.