@squiz/dxp-ai-conversation-client
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

DXP AI CONVERSATION CLIENT SDK

Overview

The @squiz/dxp-ai-conversation-client is an auto-generated SDK designed to simplify integration with the DXP AI Service for handling chat interactions and conversation rating.

Purpose

  • Abstract the complexity of HTTP requests and OpenAPI interactions, enabling developers to easily integrate AI functionalities related to chat message processing and conversation rating.
  • Provide a consistent, strongly-typed TypeScript interface for seamless integration with the DXP AI Service.
  • Support both CommonJS (CJS) and ECMAScript Module (ESM) variants for flexible usage in various JavaScript environments.

Installation

Install the SDK package using your preferred package manager:

npm install @squiz/dxp-ai-conversation-client

Usage

1. Initialize the SDK Client

Create an instance of the SDK client by providing the necessary configuration such as the base URL and authentication/session information.

import { DxpAiConversationClient } from '@squiz/dxp-ai-conversation-client';

const client = new DxpAiConversationClient();

2. Process Chat Messages

Use the processChatMessage method to start or continue a conversation by sending chat messages.

const aiId = 'your-ai-id';

client.processChatMessage(aiId, {
message: 'Hello, how can I get help?'
})
.then(response => {
    console.log('Chat response:', response);
})
.catch(error => {
    console.error('Error processing chat message:', error);
});

3. Rate Conversations

Use the rateConversation method to submit user feedback on whether a conversation was helpful.

const aiId = 'your-ai-id';
const threadId = 'conversation-thread-id';

client.rateConversation(aiId, threadId, {
rating: 'positive', # positive | negative
})
.then(response => {
    console.log('Rating submitted:', response);
})
.catch(error => {
    console.error('Error submitting rating:', error);
});

API Methods

  • processChatMessage(aiId: string, payload: ProcessChatMessagePayload): Promise<ProcessChatMessageResponse>
    Handles processing or starting a new conversation and sending messages in ongoing conversations. Requires an active DXP Session.

  • rateConversation(aiId: string, threadId?: string, payload: RateConversationPayload): Promise<RateConversationResponse>
    Allows users to rate if a conversation was helpful.

Development & Contribution

If you need to extend or modify the SDK, please refer to the Contribution Guidelines in the DXP AI service repository.

Repository

The SDK source code and OpenAPI specification are located in the DXP AI service repository at:

packages/dxp-ai-conversation-client

Versioning and Release

This SDK uses Changesets for versioning and release management, integrated into the release pipeline to publish both CommonJS (CJS) and ECMAScript Module (ESM) variants to NPM.

Readme

Keywords

none

Package Sidebar

Install

npm i @squiz/dxp-ai-conversation-client

Weekly Downloads

7

Version

2.0.0

License

ISC

Unpacked Size

172 kB

Total Files

45

Last publish

Collaborators

  • squiz-npm-publish
  • cdloh
  • pcoshansquiz
  • tadams_squiz
  • abarnes_squiz
  • gsherwood
  • pnolland
  • chadszinow-squiz
  • deborahsherwood
  • griseborough
  • akarelia
  • sdanis
  • tbernardes
  • oliverneal
  • azakens
  • azenderowska.squiz
  • lnowak
  • mdobie
  • bmatters
  • ewyatt
  • lwright-sq
  • cupreti
  • jmatthew_squiz
  • wjarosz
  • bxwu
  • carlfoster
  • samort
  • yyang1029
  • squiz-dwebster
  • tsmyth
  • aqureshi-sqz
  • rainger_squiz
  • ajhawar
  • hlee_squiz_npm
  • uqureshi
  • thomasgrob
  • avanschoor-squiz
  • ata-squiz
  • asharpe-squiz
  • aj12
  • squiz-lstephan
  • squiz-ncallahan
  • squiz-dschoen
  • squiz-ksilalahi
  • jpolgar-squiz
  • pkiriakou
  • hnarayanasamy
  • rmcavoy-squiz
  • asittirangsan
  • jchaware
  • lunowak-squiz
  • mnowakowski1
  • sholloway
  • pantyporowicz-squiz
  • djarrott.squiz.net
  • dkaczmarek
  • lineenan
  • aaronchan1010
  • haleesquiz
  • dpedroso
  • rszarafinski
  • tmadden
  • zackyang214
  • gdemelloesilva.squiz
  • jwrobel
  • bpottier
  • hkapoor_squiz
  • jhendersonsquiz
  • joshsquiz
  • dstaskiewicz
  • cross-squiz
  • sjamesquiz
  • dheffernan