martian-api
v1.0.1
Published
The Martian Node.js library allows developers to easily access the martian api.
Readme
Martian Node.js Library
The Martian Node.js library allows developers to easily access the martian api.
This package should only be used server-side. Using this package client-side would expose your secret key.
Installation
npm install martian-api
Usage
Martian allows you to easily access AI models and to log the outputs from AI models.
Logging values:
const { logToMartian } = require("martian-api")
const inputs = ["The", "inputs", "to", "your", "function"]
const outputs = "Your outputs"
logToMartian(
{apiKey: process.env.MARTIAN_API_KEY},
inputs,
outputs,
{martian_name: "yourFunction"}
)Logging a function:
const { withMartian } = require("martian-api")
function yourFunction(args){
// your function definition
}
const yourFunctionWithLogging = withMartian({apiKey: process.env.MARTIAN_API_KEY})(yourFunction)Logging with an object:
const { withMartian } = require("martian-api")
const yourObject = new YourClass(configuration);
yourObject.oldYourFunction = yourObject.yourFunction
yourObject.yourFunction = yourObject({apiKey: process.env.MARTIAN_API_KEY})(yourObject.oldYourFunction.bind(yourObject))