1.2.18 • Published 8 months ago

@adobe/spacecat-shared-gpt-client v1.2.18

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

Spacecat Shared - GPT Client

The FirefallClient library offers a streamlined way to interact with the Firefall API, enabling applications to fetch insights, recommendations, and codes based on provided prompts. Designed with simplicity and efficiency in mind, this client handles all aspects of communication with the Firefall API, including request authentication, error handling, and response parsing.

Configuration

To use the FirefallClient, you need to configure it with the following parameters:

  • FIREFALL_API_ENDPOINT: The endpoint URL for the Firefall API.
  • FIREFALL_API_KEY: Your API key for accessing the Firefall API.
  • FIREFALL_API_CAPABILITY_NAME: The capability name for the Firefall API.

These parameters can be set through environment variables or passed directly to the FirefallClient.createFrom method.

Additionally, the configuration for the @adobe/spacecat-shared-ims-client library is required to fetch the service access token from the IMS API:

  • IMS_HOST: The hostname of the IMS API.
  • IMS_CLIENT_ID: Your IMS client ID.
  • IMS_CLIENT_CODE: Your IMS client code, used for authentication.
  • IMS_CLIENT_SECRET: Your IMS client secret, used for authentication.

Usage Examples

Instantiating the Firefall Client

import FirefallClient from 'path/to/firefall-client';

// Assuming environment variables are set
const context = {
  env: process.env,
  log: console, // Using console for logging in this example
};

try {
  const client = FirefallClient.createFrom(context);
  console.log('FirefallClient created successfully.');
} catch (error) {
  console.error('Error creating FirefallClient:', error.message);
}

Fetching Insights

async function fetchInsights(prompt) {
  try {
    const client = FirefallClient.createFrom({
      env: {
        FIREFALL_API_ENDPOINT: 'https://api.firefall.example.com',
        FIREFALL_API_KEY: 'yourApiKey',
        FIREFALL_API_CAPABILITY_NAME: 'yourCapabilityName',
        IMS_HOST: 'ims.example.com',
        IMS_CLIENT_ID: 'yourClientId',
        IMS_CLIENT_CODE: 'yourClientCode',
        IMS_CLIENT_SECRET: 'yourClientSecret',
      },
      log: console,
    });

    const insights = await client.fetch(prompt);
    console.log('Insights:', insights);
  } catch (error) {
    console.error('Failed to fetch insights:', error.message);
  }
}

fetchInsights('How can we improve customer satisfaction?');

Ensure that you replace 'path/to/firefall-client' with the actual path to the FirefallClient class in your project and adjust the configuration parameters according to your Firefall API credentials.

Testing

To run tests:

npm test

Linting

Lint your code:

npm run lint

Cleaning

To remove node_modules and package-lock.json:

npm run clean

Additional Information

1.2.18

8 months ago

1.2.17

8 months ago

1.2.16

8 months ago

1.2.13

9 months ago

1.2.14

9 months ago

1.2.15

9 months ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.9

12 months ago

1.2.12

10 months ago

1.2.10

11 months ago

1.2.11

11 months ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago