@renaiss-ai/renforce-js
v0.0.1-alpha.20
Published
## Installation
Downloads
1,292
Maintainers
Readme
Renforce JS
Installation
npm install @renaiss-ai/renforce-js
Example
Orchestator
import { AIOrchestrator, Model } from '@renaiss-ai/renforce-js'
async function run (): Promise<void> {
const aiOrchestrator = new AIOrchestrator({
credentials: {
apiToken: process.env.RENFORCE_API_KEY!,
spaceId: process.env.RENFORCE_SPACE_ID!
}
model: Model.GEMINI, // gemini-1.5-flash-002
system_prompt: 'You are a helpful assistant.',
output_prompt: 'Provide a concise response.',
temperature: 0.3,
max_output_tokens: 550,
min_output_tokens: 1
})
const { status, result } = await aiOrchestrator.run({
query: 'Hi, how are you?',
/**
* You can override the default parameters here
model: Model.GEMINI, // gemini-1.5-flash-002
system_prompt: 'You are a helpful assistant.',
output_prompt: 'Provide a concise response.',
temperature: 0.3,
max_output_tokens: 550,
min_output_tokens: 1
*/
})
console.log(`Status: ${status}, Model Answer: ${result.model_answer}`)
}
void run()
Pods
Simple
import { AIOrchestrator, Model } from '@renaiss-ai/renforce-js'
async function run (): Promise<void> {
const pod = new Pod({ podId: process.env.POD_ID! })
const { result, logEntry } = await pod.run({
query: 'Hi, how are you?'
})
console.log(`Model Answer: ${result} Usage: ${JSON.stringify(logEntry)}`)
}
void run()
Transcribe this audio
import { AIOrchestrator, Model } from '@renaiss-ai/renforce-js'
import fs from 'fs'
const filePath = process.env.AUDIO_FILE_PATH
if (filePath == null) {
console.error('Please set the AUDIO_FILE_PATH environment variable')
process.exit(1)
}
const file = fs.readFileSync(filePath)
const blob = new Blob([file], { type: 'audio/mp3' })
async function run (): Promise<void> {
const podId = process.env.POD_ID != null ? process.env.POD_ID : 'YOUR_POD_ID'
const pod = new Pod({ podId })
const { result, logEntry } = await pod.run({
query: 'transcribe este audio',
data: {
index: false
},
attachments: [
{
data: blob,
filename: 'sample.mp3'
}
]
})
console.log(`Model Answer: ${result} Usage: ${JSON.stringify(logEntry)}`)
}
void run()
If the environment variable RENFORCE_API_KEY
is not set, you must specify the API key in the apiToken
field.
If the environment variable RENFORCE_SPACE_ID
is not set, you must specify the space ID in the spaceId
field.