fi_sdk_js
v1.0.6
Published
Feedback Intelligence SKD
Downloads
111
Maintainers
Readme
Feedback Intelligence SDK for JavaScript
The Feedback Intelligence SDK for JavaScript provides a simple and intuitive way to interact with the Feedback Intelligence API. It allows you to add contexts, chats, and feedback to your projects.
Installation
You can install the SDK via npm:
npm install fi_sdk_js
const { FeedbackIntelligenceSDK, Message, Context, Feedback } = require('fi_sdk_js');
const sdk = new FeedbackIntelligenceSDK('your_api_key');
// Add context
sdk.addContext(17, 'This is the context')
.then(response => console.log(response))
.catch(error => console.error(error));
// Add chat
const messages = [
new Message({
role: 'human',
text: 'Hello there!',
prompt: "This is prompt",
date: "2024-01-20T13:04:04", // optional
context: new Context({text: "This is context"})
}),
new Message({
role: 'ai',
text: 'Hi, how can I help you?',
feedback: new Feedback({thumbsUp: true, rating: 3, message: "feedback message"}) //optional
})
];
sdk.addChat(17, 12345, messages)
.then(response => console.log(response))
.catch(error => console.error(error));