Below is the documentation for integrating Reconify with Mistral via Node NPM module.
Currently we support Chat actions with Mistral.
The first step is to create an account at app.reconify.com.
In the Reconify console, add an Application to your account. This will generate both an API_KEY and an APP_KEY which will be used in the code below to send data to Reconify.
The easiest way to integrate in Node.js is with the NPM module.
npm install reconify --save
import {reconifyMistralHandler} from 'reconify';
Prior to initializing the Reconify module, make sure to import and initialize the Mistral module.
import { MistralClient } from "@mistral/mistralai";
const mistral_client = new MistralClient({
apiKey: process.env.MISTRAL_API_KEY
});
Initialize the module passing in the Mistral client and the keys created above.
const reconify = reconifyMistralHandler(mistral_client, {
appKey: process.env.RECONIFY_APP_KEY,
apiKey: process.env.RECONIFY_API_KEY,
})
This is all that is needed, and the NPM takes care of the rest when you call mistral_client.chat.
You can optionally turn on "debug" mode by passing in "debug: true" in the JSON above. This will print debug messages to the console.
You can also disable image tracking, by passing in "trackImages : false" in the JSON.
const reconify = reconifyMistralHandler(mistral_client, {
appKey: process.env.RECONIFY_APP_KEY,
apiKey: process.env.RECONIFY_API_KEY,
debug: true,
})
You can optionally pass in a user object or session ID to be used in the analytics reporting. The session ID will be used to group interactions together in the same session transcript.
The user object should include a unique userId, the other fields are optional.
reconify.setUser ({
"userId": "123",
"isAuthenticated": 1,
"firstName": "Francis",
"lastName": "Smith",
"email": "",
"phone": "",
"gender": "female"
});
The session ID is a simple string.
reconify.setSession('MySessionId');
import { MistralClient } from '@mistralai/mistralai';
import { reconifyMistralHandler } from 'reconify';
const mistral_client = new MistralClient(process.env.MISTRAL_API_KEY)
const reconify = reconifyMistralHandler(mistral_client, {
appKey: process.env.RECONIFY_APP_KEY,
apiKey: process.env.RECONIFY_API_KEY,
});
reconify.setUser({
userId: "12345",
isAuthenticated: 1,
firstName: "Jim",
lastName: "Stand",
gender: "male"
});
const response = await mistral_client.chat({
model: "mistral-tiny",
messages: [
{role: "system", content: "You are a stand up comic"},
{role: "user", content: "Tell me a cat joke"}
],
});