1.0.2 • Published 8 months ago

abnk-assistant-client v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

ABNK Assistant Client

The ABNK Assistant Client is a versatile JavaScript library that simplifies interaction with the ABNK Assistant API. With this library, you can effortlessly send questions to the API and receive text responses. It provides flexibility by supporting multiple module systems, including UMD, CommonJS (CJS), and ECMAScript Modules (ESM).

Installation

You can install the ABNK Assistant Client via npm by running the following command:

npm install abnk-assistant-client

Usage

UMD Module (<script> tag)

When using the ABNK Assistant Client as a UMD module, you can include it directly in an HTML file using a <script> tag. Here's an example:

<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <title>ABNK Assistant Client Example</title>
    </head>
    <body>
        <script src="path/to/abnk-assistant-client/dist/index.umd.js"></script>
        <script>
            const client = new AIClient('your-api-endpoint-url')
            // also possible to access from window.AIClient

            // Example usage:
            client.invoke('What is the weather today?').then((response) => {
                console.log(response)
            })
        </script>
    </body>
</html>

CommonJS (CJS) Module (Node.js)

When working in a Node.js environment, you can use the ABNK Assistant Client as a CommonJS module. Here's an example:

const AIClient = require('abnk-assistant-client') // Access the CJS module

const client = new AIClient('your-api-endpoint-url')

// Example usage:
client.invoke('What is the weather today?').then((response) => {
    console.log(response)
})

ECMAScript Modules (ESM)

If you prefer using ECMAScript Modules (ESM) in modern JavaScript environments, you can import the ABNK Assistant Client like this:

import AIClient from 'abnk-assistant-client'

// Access the ESM module

const client = new AIClient('your-api-endpoint-url')

// Example usage:
async function getResponse() {
    const response = await client.invoke('What is the weather today?')
    console.log(response)
}

getResponse()

API Reference

AIClient(apiEndpoint: string)

  • apiEndpoint (string): The URL endpoint of the ABNK Assistant API.

invoke(payload: string)

  • payload (string): The question to send to the ABNK Assistant API.
  • Returns a Promise that resolves with the response from the API.
1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago