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

cboard-ai-engine

v1.7.0

Published

This engine powers the Cboard AI builder, designed to generate content suggestions for communication boards and create new pictograms as necessary.

Downloads

27

Readme

Cboard AI Engine

This engine powers the Cboard AI builder, designed to generate content suggestions for communication boards and create new pictograms as necessary.

With a simple prompt, it will generate a list of suggestions that can be used to create an AAC board. Each suggestion will be associated with a text description and a list of images.

The images can be retrieved from ARASAAC or Global Symbols, and the text descriptions are generated using the OpenAI Node API Library.

Table of Contents

Installation

npm install cboard-ai-engine

or

yarn add cboard-ai-engine

Usage

The code below shows how to get started using the Cboard AI Engine.

import { initEngine } from "cboard-ai-engine";

const engineInstance = initEngine({
  openAIConfiguration,
  globalSymbolsApiURL,
});

const suggestions = await engineInstance.getSuggestionsAndProcessPictograms({
  prompt: "Brazilian food",
  maxSuggestions: 5,
  language: "en", // Use two letter language code or locale (en.US for example)
  symbolSet: "arasaac"
});

Initialization

const engineInstance = initEngine({
  openAIConfiguration,
  globalSymbolsApiURL,
  pictonizerConfiguration,
  arasaacURL
});

The initEngine function is used to initialize the engine. Takes an object with the following properties as its only argument:

  • openAIConfiguration: Object with the OpenAI configuration. Required.
const openAIConfiguration = {
  apiKey: "your openai api key",
  basePath: "https://your-openai-base-path.com",
  baseOptions: {
    headers: { "api-key": "your openai api key" },
    params: { "api-version": "2022-12-01" },
  },
};
  • globalSymbolsApiURL: The Global Symbols API URL. Default is https://www.globalsymbols.com/api/v1/labels/search/. Optional.

  • arasaacURL: The ARASAAC API URL. Default is https://api.arasaac.org/api/pictograms. Optional.

Return:

It returns an instance of the engine with the following methods:

  • getSuggestions: This method is used to get suggestions with images solely from Global Symbols.

  • isContenSafe: This method is used to check if the content is safe.

Types

The engine uses the following types:

export type Suggestion = {
  id: string; // Unique identifier for the suggestion
  label: string; // The text description of the suggestion
  locale: string; // The language of the suggestion
  pictogram: { 
    images:
      | {
          id: string; // Indentifier for the image from Global Symbols
          symbolSet: string; // The symbol set of the image
          url: string; // The URL of the image
        }[]
  };
};

Methods

getSuggestions

async function getSuggestions({
  prompt,
  maxSuggestions,
  symbolSet,
  language = DEFAULT_LANGUAGE,
}: {
  prompt: string;
  maxSuggestions: number;
  symbolSet?: string;
  language: string;
}): Promise<Suggestion[]>;

This method is used to get the suggestions with images solely from Global Symbols. It will not generate new pictograms with the Cboard Pictonizer.

Parameters:

  • prompt : The prompt to be used to generate the suggestions. Required. Type: string.

  • maxSuggestions: The maximum number of suggestions to be returned. Default is 10. Optional. Type: number.

  • symbolSet: The symbol set to be used. If undefined, images will be searched across all Global Symbol image banks. Optional. Type: string.

  • language: The language to be used. Default is en. Use two-letters code or locale Optional. Type: string.

Return:

It returns an array of Suggestion.

isContentSafe

async function isContentSafe({
  text,
}: {
  text: string;
}): Promise<boolean>;

This method is used to check if the provided text is safe for use.

Parameters:

  • text: The text to be checked. Required. Type: string.

Return:

It returns a boolean indicating whether the content is safe.

Error Handling

When an error occurs, an error will be thrown. It is recommended to use a try/catch block to handle it.

try {
  const suggestions = await engineInstance.getSuggestions({
    prompt,
    maxSuggestions,
    symbolSet,
    language
  });
} catch (error) {
  console.error(error);
}
NOTE: Is not needed on the initialization method.

License

Copyright © 2024 Cboard

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.