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

watson-conversation-ui

v1.0.0

Published

Angular component to visualize conversations generated with Watson Conversation and the details of each element of the conversation

Downloads

4

Readme

WatsonConversationUI

This project provides an angular component to visualize conversations generated with Watson Conversation and the details of each element of the conversation.

Component preview

Installation

npm install watson-conversation-ui --save

Dependencies

npm install bootstrap
npm install --save @angular/material @angular/cdk @angular/animations
  • And don't forget to include into your styles.css the Angular Material Theme:
// styles.css
@import '~@angular/material/prebuilt-themes/indigo-pink.css';
  • Alternatively, if you are not using Angular CLI, you can add it directly to your index.html
<link href="node_modules/@angular/material/prebuilt-themes/indigo-pink.css" rel="stylesheet">

Usage

In a typical Watson Conversation architecture, we have a database that stores all the conversations that Watson has received.

This component allows you to visualize conversations stored in the database in a dialog style.

To do this, we build a JavaScript array with the records of the conversation and we provide it to the component. We also provide a configuration variable to indicate which are the fields corresponding to the user input and the watson output.

Example:

  1. We have all the conversations records in a DB2 database and the conversations are identified by the field "conversationid".
  2. We include WatsonConversationUi in our module.ts.
// app.module.ts
import { WatsonConversationUiModule } from 'watson-conversation-ui';
  1. We construct an array with all records with the same "conversationid".
// app.component.ts
const myConversation = [
    {
        _ID: 'bfe1303e-fdd6-11e7-8be5-0ed5f89f718b',
        INPUT: 'This is the user\'s first question',
        OUTPUT: 'This is watson\'s answer to the question',
        CONFIDENCE: 0.87847,
        NODES_VISITED: 'Default_counter-node_1_123456789',
        CONVERSATIONID: 'dd877964-fdda-11e7-8be5-0ed5f89f718b'
    },
    {
        _ID: 'a51bbd6a-fdda-11e7-8be5-0ed5f89f718b',
        INPUT: 'This is the user\'s second question',
        OUTPUT: 'This is watson\'s answer to the question',
        CONFIDENCE: 0.97483,
        NODES_VISITED: 'node_2_2134544',
        CONVERSATIONID: 'dd877964-fdda-11e7-8be5-0ed5f89f718b'
    }
]
  1. Then we pass the array to our component using "conversation" attribute.
<!-- app.component.html -->
<watson-conversation-ui [conversation]="myConversation"></watson-conversation-ui>

This would show the following dialog:

Dialog example

If your conversation shows backwards you cann use a component attribute called "reverse" and set it to "true. Example:

<watson-conversation-ui [conversation]="myConversation" [reverse]="true"></watson-conversation-ui>

Conversation details

We use to store a lot of information about conversations but to visualize them only a few are relevant. So, this component allows you to hide some attributes of the conversation by unchecking them in the details list.

To show them again you only have to check them in the "hidden fields" tab.

Details example

Configuration

By default, this component assumes the input field is called "INPUT", the output field "OUTPUT" and the field that identifies each iteration of the conversation "_ID".

// Default configuration object
{
    iterationid: '_ID',
    input: 'INPUT',
    output: 'OUTPUT'
}

If we have different fields to identify these properties, we can use a configuration object and pass it to the component.

// app.component.ts
const config: {
    iterationid?: string,
    input?: string,
    output?: string
  } = {
      iterationid: 'id',
      input: 'userinputfield',
      output: 'watsonoutputfield'
    }

Map attributes

It may be that some of the attributes of the conversation need to be processed before displaying them. To do this, within the configuration object, we can add the property "map" which is an object that has, as keys, the names of the attributes to be mapped and, as values, the mapping functions.

// app.component.ts
const config: {
    iterationid?: string,
    input?: string,
    output?: string,
    map?: any
  } = {
      iterationid: '_ID',
      input: 'INPUT',
      output: 'OUTPUT',
      map: {
          CONFIDENCE: (item) => {
              return item.toFixed(2);
          },
          INPUT: (item) => {
              return item.toUppercase();
          }
      }
    }