fi_sdk_js
Version:
Feedback Intelligence SKD
43 lines (34 loc) • 1.25 kB
Markdown
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.
You can install the SDK via npm:
```bash
npm install fi_sdk_js
```
```js
const { FeedbackIntelligenceSDK, Message, Context, Feedback } = require('fi_sdk_js');
const sdk = new FeedbackIntelligenceSDK('your_api_key');
const project_id = 17 // Enter your project id
// Add context
sdk.addContext(project_id, '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: 1, rating: 3, message: "feedback message"}) //optional
})
];
sdk.addChat(project_id, "chat-1", messages)
.then(response => console.log(response))
.catch(error => console.error(error));
```