reicore-sdk
v2.0.1
Published
The Rei Core SDK is a powerful tool designed to interact with the Rei Agent, enabling seamless integration for authentication, agent retrieval, and chat completions. This SDK simplifies the process of connecting to the Rei Agent and utilizing its features
Readme
Rei Core SDK
The Rei Core SDK is a powerful tool designed to interact with the Rei Agent, enabling seamless integration for authentication, agent retrieval, and chat completions. This SDK simplifies the process of connecting to the Rei Agent and utilizing its features.
Installation
To install the SDK, use the following command:
npm install reicore-sdkUsage
Importing the SDK First, import the SDK into your project:
const ReiCoreSdk = require('reicore-sdk');Constructor
The SDK requires an API key for authentication. Initialize the SDK with your API key as follows:
const apiKey = 'your-api-key-here';
// #1 by passing params
const reiAgent = new ReiCoreSdk({ agentSecretKey: apiKey });
// #2 by env
process.env.REI_AGENT_SECRET_ACCESS_KEY = 'reiAgentSecretAccessKey';
const reiAgent = new ReiCoreSdk();Functions
Get Agent
Retrieve details about the Rei Agent using the getAgent function.
reiAgent
.getAgent()
.then((agent) => {
console.log('Agent Details:', agent);
})
.catch((error) => {
console.error('Error fetching agent:', error);
});Chat Completion
Send a message to the Rei Agent and receive a chat completion using the chatCompletion function.
Usage
reiAgent
.chatCompletion(payload)
.then((response) => {
console.log('Chat Completion:', response);
})
.catch((error) => {
console.error('Error in chat completion:', error);
});Sample payload
Text
const payload = {
messages: [
{
role: 'user',
content: 'Hello, can you help me with my research?'
}
]
};Image
const payload = {
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Hello, can you help me with my research?' },
{
type: 'image_url',
image_url: {
url: 'https://image.png'
}
}
]
}
]
};
// Image URL must end with extension
// Supported extension: .jpg .jpeg .png .gif .bmp .webp .svg .tiffDocuments (PDF)
const payload = {
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Hello, can you help me with my research?' },
{
type: 'file',
file: {
filename: 'Sample File Name',
file_data: `data:application/pdf;base64,ewrawsdasdgfff....`
}
}
]
}
]
};With Tools
const payload = {
messages: [
{
role: 'user',
content: 'Hello, can you help me with my research?'
}
],
tools: [
{
type: 'function',
function: {
name: 'search',
description: 'Search for academic papers and research',
parameters: {
type: 'object',
properties: {
query: {
type: 'string'
}
},
required: ['query']
}
}
}
]
};License
This project is licensed under the MIT License. See the LICENSE file for details.
Support
For support, please open an issue on our GitHub repository or contact us at [email protected].
