@elmoziml/multiyo
v1.2.0
Published
A provider-agnostic AI SDK for Node.js. Switch between Google Gemini and OpenAI easily with pre-built services for Moderation, Analysis, and more.
Maintainers
Readme
Multiyo.ai 🤖
Multiyo is a powerful, provider-agnostic AI SDK for Node.js.
It helps developers integrate AI services (like Content Moderation, Summarization, and Sentiment Analysis) without worrying about Prompt Engineering, messy API responses, or vendor lock-in.
Easily switch between Google Gemini and OpenAI with a single line of configuration.
✨ Key Features
- Unified API: Write code once, run it with Google or OpenAI.
- Strict JSON Outputs: No more Regex parsing! All services return clean, typed JSON objects.
- Pre-engineered Prompts: Optimized system instructions for common tasks.
- Lightweight: Uses Dynamic Imports to keep your project size small (loads SDKs only when needed).
📦 Installation
Install the package via npm:
npm i @elmoziml/multiyo🔔 Note:
- The Google Gemini SDK (
@google/generative-ai) is installed automatically as a dependency.- If you plan to use OpenAI, you must install it manually:
npm install openai
⚙️ Configuration
Multiyo works out-of-the-box with Google Gemini as the default provider. You don't need complex setup files; just use Environment Variables.
1. Set up Environment Variables
Create a .env file in your project root:
# Required for default usage
GEMINI_API_KEY=your_google_api_key_here
# Required only if you use OpenAI
OPENAI_API_KEY=your_openai_api_key_here2. Basic Usage (Default: Google Gemini)
Initialize the service without arguments to use the default provider.
import Multiyo from '@elmoziml/multiyo';
import dotenv from 'dotenv';
dotenv.config();
const service = new Multiyo.Moderation();
// 🚀 Automatically connects to Google Gemini3. Switching Providers (OpenAI)
To use a different provider, pass a configuration object:
const service = new Multiyo.Moderation({
provider: 'openai'
});🚀 Usage Examples
🛡️ Content Moderation
Check if a user comment is safe, toxic, or spam.
import Multiyo from '@elmoziml/multiyo';
async function checkComment() {
const mod = new Multiyo.Moderation();
try {
const result = await mod.reviewComment("You are stupid and I hate you!");
if (!result.isSafe) {
console.log(`❌ Comment rejected: ${result.reason}`);
console.log(`Category: ${result.category}`);
} else {
console.log("✅ Comment published.");
}
} catch (error) {
console.error("AI Error:", error.message);
}
}
checkComment();Output Example:
{
"isSafe": false,
"reason": "Contains personal insults.",
"category": "harassment"
}📊 Text Analysis (Summarization & Sentiment)
Summarize long texts or detect emotions.
import Multiyo from '@elmoziml/multiyo';
async function analyzePost() {
const analyzer = new Multiyo.Analysis(); // Default: Google
const text = "I absolutely love this product! It changed my life completely, although it's a bit expensive.";
// 1. Get Sentiment
const sentiment = await analyzer.getSentiment(text);
console.log("Sentiment:", sentiment);
// Output: { sentiment: "positive", score: 0.8 }
// 2. Summarize
const summary = await analyzer.summarize(text);
console.log("Summary:", summary.summary);
}📚 API Reference
ModerationService
| Method | Input | Returns | Description |
| :--- | :--- | :--- | :--- |
| reviewComment(text) | string | Promise<{ isSafe, reason, category }> | Analyzes text for toxicity/spam. |
AnalysisService
| Method | Input | Returns | Description |
| :--- | :--- | :--- | :--- |
| summarize(text) | string | Promise<{ summary, keyPoints[] }> | Summarizes text and extracts bullets. |
| getSentiment(text) | string | Promise<{ sentiment, score }> | Detects positive/negative tone. |
🛠 Advanced Configuration
You can override specific settings (like the Model ID) for a specific instance.
const customService = new Multiyo.Analysis({
provider: 'google',
providers: {
google: {
model: 'gemini-1.5-pro' // Force specific model
}
}
});📄 License
ISC
