0.0.57 • Published 5 months ago

@websolutespa/bom-llm v0.0.57

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@websolutespa/bom-llm

npm version

status alpha

LLM module of the BOM Repository by websolute.

Bom LLM Plugin

This plugin automatically adds UI components to manage LLM Chatbot by websolute.

Requirements:

  • You need a personal appKey and apiKey to use this plugin, for more info contact websolute

Usage

You can load the script directly via jsDelivr or installing via npm.

Using jsDelivr

<script type="module" src="https://cdn.jsdelivr.net/npm/@websolutespa/bom-llm/dist/umd/index.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@websolutespa/bom-llm/dist/umd/index.css">
<script>
  document.addEventListener('DOMContentLoaded', () => {
    if ('bomLlm' in window) {
      const searchParams = new URLSearchParams(window.location.search);
      const options = {
        appKey: 'MY_APP_KEY',
        apiKey: 'MY_API_KEY',
        threadId: searchParams.get('llmThreadId'),
      };
      bomLlm(options);
    }
  });
</script>

Using npm

Install library using npm.

npm i @websolutespa/bom-llm --save

Import css from node_modules.

<link rel="stylesheet" href="node_modules/@websolutespa/bom-llm/dist/umd/index.css">

Import and consume plugin.

import { bomLlm } from '@websolutespa/bom-llm';

document.addEventListener('DOMContentLoaded', () => {
  if ('bomLlm' in window) {
    const searchParams = new URLSearchParams(window.location.search);
    const options = {
      appKey: 'MY_APP_KEY',
      apiKey: 'MY_API_KEY',
      threadId: searchParams.get('llmThreadId'),
    };
    // returned instance
    const llm = bomLlm(options);
  }
});

Using imperatively.

const options = {
  appKey: 'MY_APP_KEY',
  apiKey: 'MY_API_KEY',
  imperative: true, // hide trigger button
};
const llm = bomLlm(options);
// using open command imperatively
setTimeout(() => {
  llm.open();
}, 4000);

Using embed tag.

<llm-embed />

Running test

Add parameter test = true.

  const searchParams = new URLSearchParams(window.location.search);
  const options = {
    appKey: 'MY_APP_KEY',
    apiKey: 'MY_API_KEY',
    threadId: searchParams.get('llmThreadId'),
    test: true,
  };
  bomLlm(options);

Decorate external url

You can decorate every json item from the knowledgeBase customizing its external url.
decorateUrl method can be a promise.

  const searchParams = new URLSearchParams(window.location.search);
  const options = {
    appKey: 'MY_APP_KEY',
    apiKey: 'MY_API_KEY',
    threadId: searchParams.get('llmThreadId'),
    decorateUrl: (item) => {
      switch (item.type) {
        case 'event':
        case 'eventItem':
          return `https://acme.com/event?id=${item.id}`;
        default:
          return;
      }
    },
  };
  bomLlm(options);

Handling external actions

You can handle the click event of the generated cta action with the onAction handler.

  const searchParams = new URLSearchParams(window.location.search);
  const options = {
    appKey: 'MY_APP_KEY',
    apiKey: 'MY_API_KEY',
    threadId: searchParams.get('llmThreadId'),
    onAction: (item) => {
      console.log('onAction', item.id, item.title);
    },
  };
  bomLlm(options);

Supported types

Currently available types are:

  • event
  • eventItem
  • poi
  • poiItem
  • tripadvisor
  • tripadvisorItem

this library is for internal usage and not production ready
0.0.55

5 months ago

0.0.56

5 months ago

0.0.57

5 months ago

0.0.53

7 months ago

0.0.54

6 months ago

0.0.52

7 months ago

0.0.51

7 months ago

0.0.50

7 months ago

0.0.48

8 months ago

0.0.49

8 months ago

0.0.47

8 months ago

0.0.45

9 months ago

0.0.46

9 months ago

0.0.44

9 months ago

0.0.40

10 months ago

0.0.41

10 months ago

0.0.42

10 months ago

0.0.43

10 months ago

0.0.39

10 months ago

0.0.37

10 months ago

0.0.38

10 months ago

0.0.30

11 months ago

0.0.31

11 months ago

0.0.32

11 months ago

0.0.33

11 months ago

0.0.34

10 months ago

0.0.35

10 months ago

0.0.36

10 months ago

0.0.24

12 months ago

0.0.25

11 months ago

0.0.26

11 months ago

0.0.27

11 months ago

0.0.28

11 months ago

0.0.29

11 months ago

0.0.20

1 year ago

0.0.21

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago