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

dialogue-smith-api-library

v2.1.0

Published

This library helps with making requests to the Dialogue Smith API. For more info on dialogue smith refer to this website [Dialogue Smith Homepage](https://dialoguesmith.com/), for the API reference refer to [the api docs](https://api.dialoguesmith.com/).

Downloads

12

Readme

Dialogue Smith Typescript/Javascript API Library

This library helps with making requests to the Dialogue Smith API. For more info on dialogue smith refer to this website Dialogue Smith Homepage, for the API reference refer to the api docs. Usage below Example.

On The Website they also should have a link to their discord server if your interested!

Example


import { DialogueSmithAPI, Result, ResultLike} from "../src/index";
import { ResultIsError, ResultIsResponse } from "../src/index";

const key = "KEY";

let instance = new DialogueSmithAPI(key);

async function main()
{
    let scifi_character_sheet = await instance.world_building_scifi_character_sheet(
        "Zycrasion, She is the developer of the package"
    );
    // Check if it resulted in an error
    if (ResultIsError(scifi_character_sheet))
    {
        // If it did, do error handling
        console.error("Error in scifi character sheet:");
        console.error(scifi_character_sheet.errorText);
    } else if (ResultIsResponse(scifi_character_sheet))
    {
        // Otherwise you have your output
        for (let dialogue of scifi_character_sheet.result.dialogue)
        {
            console.log(dialogue);
        }
        console.log("Remaining Tokens = ", scifi_character_sheet.result.remaining_tokens);
    }
    /*
    Name: Zycrasion
    Race: Human
    Sex: Female
    Appearance: Tall and slender, long black hair, wears a white lab coat and glasses.
    Temperament: Intelligent and curious 
    Occupation: Scientist/Developer 
    Primary Location: Research Lab 
    Specialization: Developing technological packages 
    Equipment: Computer, various tools for tinkering with technology  
    Inventory: Various components (5) small notebook (1) pen (1) 
    Finances : 500  
    Relationship to Player : A scientist who will develop new technological packages for the player at a price.
    */
    let drunk_npc = await instance.dialogue_drunk_response(
        "Hello Frank! Have you heard about this package? It's amazing!"
    );
    if (ResultIsError(drunk_npc))
    {
        console.error("Error in drunk npc:");
        console.error(drunk_npc.errorText);
    } else if (ResultIsResponse(drunk_npc))
    {
        for (let dialogue of drunk_npc.result.dialogue)
        {
            console.log(dialogue);
        }
        console.log("Remaining Tokens = ", drunk_npc.result.remaining_tokens);
    }
    /*
     Hey Frank! Package? What package? Lemme see it! I love packages! 
    */

    let varied_responses = await instance.dialogue_variations(
        "Hey! Can you install the package in node package manager?"
    );
    if (ResultIsError(varied_responses))
    {
        console.error("Error in varied responses:");
        console.error(varied_responses.errorText);
    } else if (ResultIsResponse(varied_responses))
    {
        for (let dialogue of varied_responses.result.dialogue)
        {
            console.log(dialogue);
        }
        console.log("Remaining Tokens = ", varied_responses.result.remaining_tokens);
    }
    /*
    Hey! Are you able to install the package in node package manager?
    Hey! Do you know how to install the package in node package manager?
    Hey! Could you help me install the package in node package manager?
    Hey! Would it be possible for you to install the package in node package manager?
    Hey! Is it within your capability to install the package in node package manager?
    */

}

main();

Usage

First, you have to create an API instance,

let api_key = "<your api key>";

let instance = new DialogueSmithAPI(api_key)

To make a request to the api you can call function on the instance,

let response = await instance.dialogue_drunk_response(
"I would love to purchase your finest armours"
);

The to get the result, you have to do a little bit of error handling in case the response resulted in an error

if (ResultIsError(response))
{
    console.error(response.errorText);
} else if (ResultIsResponse(response))
{
    for (let dialogue of response.result.dialogue)
    {
        console.log(dialogue);
    }
    console.log("Remaining Tokens = ", response.result.remaining_tokens);
}

And that's it! If you have any suggestions feel free to submit an Issue on the repository.