0.0.57 • Published 4 months ago

@websolutespa/bom-llm v0.0.57

Weekly downloads
-
License
MIT
Repository
github
Last release
4 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

4 months ago

0.0.56

4 months ago

0.0.57

4 months ago

0.0.53

6 months ago

0.0.54

5 months ago

0.0.52

6 months ago

0.0.51

6 months ago

0.0.50

6 months ago

0.0.48

7 months ago

0.0.49

7 months ago

0.0.47

7 months ago

0.0.45

8 months ago

0.0.46

8 months ago

0.0.44

8 months ago

0.0.40

9 months ago

0.0.41

9 months ago

0.0.42

9 months ago

0.0.43

9 months ago

0.0.39

9 months ago

0.0.37

9 months ago

0.0.38

9 months ago

0.0.30

10 months ago

0.0.31

10 months ago

0.0.32

10 months ago

0.0.33

10 months ago

0.0.34

10 months ago

0.0.35

10 months ago

0.0.36

9 months ago

0.0.24

11 months ago

0.0.25

10 months ago

0.0.26

10 months ago

0.0.27

10 months ago

0.0.28

10 months ago

0.0.29

10 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