Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JavaScript for MultiMindSDK – bring advanced context transfer and multi-LLM orchestration, Node.js apps, and web tools

License

NotificationsYou must be signed in to change notification settings

multimindlab/multimind-sdk-js

Repository files navigation

npmLicenseTypeScriptNode.js

NPM Version

This SDK gives JavaScript developers full access to advanced AI features like agent orchestration, RAG, and fine-tuning — without needing to manage backend code.

🚀 What This SDK Does

The MultiMind SDK provides a comprehensive JavaScript interface for advanced AI capabilities:

  • 🤖 AI Agent Orchestration: Create intelligent agents that can reason, plan, and execute complex tasks
  • 🔍 RAG (Retrieval-Augmented Generation): Build knowledge systems that combine your data with AI reasoning
  • 🎯 Model Fine-tuning: Customize AI models for your specific use cases and domains
  • 🔄 Model Routing: Automatically select the best AI model for each task
  • 📊 Model Evaluation: Assess and compare AI model performance
  • 🔧 Adapter Management: Enhance models with specialized capabilities
  • 🛠️ Advanced Workflows: LoRA fine-tuning, document processing, compliance monitoring, and more

📦 Installation

npm install multimind-sdk

🚀 Quick Start

Basic Usage

import{MultiMindSDK}from'multimind-sdk';asyncfunctionmain(){constsdk=newMultiMindSDK();try{awaitsdk.initialize();// Generate a response with an AI agentconstresponse=awaitsdk.generateWithAgent("What is artificial intelligence?",{model:"mistral",temperature:0.7});console.log(response);}finally{awaitsdk.close();}}main();

Advanced Usage

import{MultiMindSDK}from'multimind-sdk';constsdk=newMultiMindSDK();// Advanced Fine-tuning with LoRAconstfineTuneResult=awaitsdk.advancedFineTune({baseModelName:"bert-base-uncased",outputDir:"./output",method:"lora",epochs:10,learningRate:0.001,batchSize:32,loraConfig:{r:16,alpha:32,dropout:0.1,targetModules:["query","value"]}});// Advanced RAG with Document Managementconstdocuments=[{text:"MultiMind SDK provides comprehensive AI capabilities.",metadata:{type:"introduction",source:"docs"}}];awaitsdk.addDocumentsToRAG(documents);constragResponse=awaitsdk.queryAdvancedRAG({query:"What is MultiMind SDK?",topK:5,includeMetadata:true});// Model ConversionconstconversionResult=awaitsdk.pytorchToONNX("./models/model.pt","./models/model.onnx",{quantization:{method:"int8",targetDevice:"cpu"},graphOptimization:{fuseOperations:true,optimizeMemory:true}});// Compliance MonitoringconstcomplianceResult=awaitsdk.checkCompliance({modelId:"model_123",dataCategories:["text","user_data"],useCase:"customer_support",region:"EU"});// Advanced Agent with ToolsconstagentResponse=awaitsdk.runAdvancedAgent("Calculate 15 * 23 and search for quantum computing information",{context:"mathematical and scientific inquiry"});// Model Client SystemconstlstmClient=awaitsdk.createLSTMModelClient({modelPath:"./models/lstm.pt",modelName:"custom_lstm"});constmoeClient=awaitsdk.createMoEModelClient({experts:{"expert1":{modelName:"gpt-3.5-turbo"},"expert2":{modelName:"claude-3"}},router:(input:string)=>input.length>100 ?"expert2" :"expert1"});// Gateway APIconstgateway=awaitsdk.startGateway({host:"0.0.0.0",port:8000,enableMiddleware:true,corsEnabled:true,rateLimit:100});

🤖 Models and Agents

Supported AI Models

  • OpenAI Models: GPT-3.5, GPT-4, GPT-4 Turbo
  • Anthropic Models: Claude-2, Claude-3, Claude-3.5 Sonnet
  • Open Source Models: Mistral, Llama, BERT, and many more
  • Custom Models: Load and use your own fine-tuned models

Agent Types

  • Basic Agents: Simple question-answering and text generation
  • Advanced Agents: Multi-step reasoning, tool usage, and memory
  • Specialized Agents: Code generation, data analysis, creative writing
  • Custom Agents: Build agents tailored to your specific domain

RAG Capabilities

  • Document Processing: PDF, DOCX, TXT, and more
  • Vector Storage: Efficient similarity search
  • Knowledge Graphs: Structured information retrieval
  • Hybrid Search: Combine semantic and keyword search

🖥️ Command Line Interface (CLI)

The MultiMind SDK includes a powerful CLI for automation and batch operations:

Installation

npm install -g multimind-sdk

Basic CLI Usage

# Transfer context between different AI modelsmultimind-cli --source chatgpt --target claude --input conversation.json --output prompt.txt# List supported modelsmultimind-cli --list-models# Run batch transfer operationsmultimind-cli --batch# Generate Chrome extension configurationmultimind-cli --chrome-config

CLI Options

# Basic Transfer--source, -s<model>           Source model name (e.g., chatgpt, claude)--target, -t<model>           Target model name (e.g., deepseek, gemini)--input, -i<file>             Input conversation file (JSON, TXT, MD)--output, -o<file>            Output formatted prompt file# Transfer Options--last-n<number>              Number of recent messages to extract (default: 5)--summary-type<type>          Summary type: concise, detailed, structured--output-format<format>       Output format: txt, json, markdown--no-smart-extraction          Disable smart context extraction--no-metadata                  Exclude metadata from output# Model-Specific Options--include-code                 Include code context (for coding models)--include-reasoning            Include reasoning capabilities--include-safety               Include safety considerations--include-creativity           Include creative capabilities--include-examples             Include example generation--include-step-by-step         Include step-by-step explanations--include-multimodal           Include multimodal capabilities--include-web-search           Include web search capabilities# Advanced Features--batch                        Run batch transfer operations--validate                     Validate conversation format--list-models                  List all supported models--chrome-config                Generate Chrome extension configuration--help, -h                     Showhelp message

CLI Examples

# Basic transfer from ChatGPT to Claudemultimind-cli --source chatgpt --target claude --input conversation.json --output prompt.txt# Advanced transfer with custom optionsmultimind-cli --source gpt-4 --target deepseek --input chat.txt --output formatted.md \  --summary-type detailed --include-code --include-reasoning# Batch transfer with validationmultimind-cli --batch --validate# Generate Chrome extension configmultimind-cli --chrome-config

🔧 Automation Potential

Node.js Scripts

// Automated content generationconstsdk=newMultiMindSDK();awaitsdk.initialize();// Generate blog posts from outlinesconstoutline="AI trends in 2024";constblogPost=awaitsdk.generateWithAgent(`Write a comprehensive blog post about:${outline}`,{model:"gpt-4",temperature:0.7});// Automated customer supportconstcustomerQuery="How do I reset my password?";constresponse=awaitsdk.queryAdvancedRAG({query:customerQuery,topK:3,includeMetadata:true});

CI/CD Integration

# GitHub Actions example-name:Generate Documentationrun:|    npm install multimind-sdk    node scripts/generate-docs.js

Batch Processing

// Process multiple documentsconstdocuments=awaitloadDocuments('./data/');constresults=[];for(constdocofdocuments){constsummary=awaitsdk.generateWithAgent(`Summarize this document:${doc.content}`,{model:"claude-3"});results.push({id:doc.id, summary});}

📚 Examples

Running Examples

# Basic agent examplenpm run example:agent# Advanced usage examplenpm run example:advanced# Comprehensive demonpm run demo# CLI directlynpm run cli -- --help

Example Files

  • example/run-agent.ts: Basic agent generation example
  • example/advanced-usage.ts: Advanced features example
  • example/comprehensive-demo.ts: Complete feature demonstration
  • example/context-transfer-cli.ts: CLI implementation

📚 API Reference

MultiMindSDK Class

The main SDK class that provides a unified interface to all MultiMind functionality.

Basic Methods

Agent Methods
  • generateWithAgent(prompt: string, config?: AgentConfig): Generate responses using AI agents
  • createAgent(config?: AgentConfig): Create a new agent instance
Fine-tuning Methods
  • fineTuneModel(config: FineTuneConfig): Fine-tune a model
  • createFineTuner(config: FineTuneConfig): Create a fine-tuner instance
RAG Methods
  • queryRAG(prompt: string, config: RAGConfig): Query a RAG system
  • createRAGEngine(config: RAGConfig): Create a RAG engine instance
Adapter Methods
  • loadAdapter(config: AdapterConfig): Load a model adapter
  • listAdapters(model: string): List available adapters for a model
  • removeAdapter(model: string, adapterPath: string): Remove an adapter
Evaluation Methods
  • evaluateModel(config: EvaluationConfig): Evaluate a model
  • compareModels(models: string[], task: string, dataset?: string): Compare multiple models
Model Methods
  • loadModel(config: ModelConfig): Load a model
  • routeModel(input: string, availableModels?: string[]): Route to the best model
  • listAvailableModels(): List all available models

Advanced Methods

Advanced Fine-tuning
  • advancedFineTune(config: AdvancedFineTuneConfig): Advanced fine-tuning with LoRA, Adapters, etc.
  • createAdvancedTuner(config: AdvancedFineTuneConfig): Create advanced tuner
Advanced RAG
  • createAdvancedRAG(config?: AdvancedRAGConfig): Create advanced RAG client
  • addDocumentsToRAG(documents: Document[]): Add documents to RAG
  • queryAdvancedRAG(config: QueryConfig): Query advanced RAG system
Model Conversion
  • createModelConverter(): Create model converter
  • convertModel(config: ConversionConfig): Convert model between formats
  • pytorchToONNX(inputPath: string, outputPath: string, config?): Convert PyTorch to ONNX
  • tensorflowToTFLite(inputPath: string, outputPath: string, config?): Convert TensorFlow to TFLite
  • pytorchToGGUF(inputPath: string, outputPath: string, config?): Convert PyTorch to GGUF
Compliance
  • createComplianceMonitor(config: ComplianceConfig): Create compliance monitor
  • checkCompliance(check: ComplianceCheck): Check compliance
Advanced Agents
  • createAdvancedAgent(config: AdvancedAgentConfig): Create advanced agent
  • runAdvancedAgent(input: string, context?): Run advanced agent with tools
Model Client System
  • createLSTMModelClient(config: ModelClientConfig): Create LSTM model client
  • createMoEModelClient(config: MoEConfig): Create MoE model client
  • createMultiModalClient(config: MultiModalConfig): Create MultiModal client
  • createFederatedRouter(config: FederatedConfig): Create federated router
Gateway
  • createGateway(config?: GatewayConfig): Create gateway
  • startGateway(config?: GatewayConfig): Start gateway API
  • stopGateway(): Stop gateway
Context Transfer
  • transferContext(sourceModel: string, targetModel: string, conversationData: ConversationMessage[], options?: TransferOptions): Transfer context between models
  • quickTransfer(sourceModel: string, targetModel: string, conversationData: ConversationMessage[], options?: Record<string, any>): Quick context transfer
  • getSupportedModels(): Get supported models for context transfer
  • validateConversationFormat(data: ConversationMessage[]): Validate conversation format
  • batchTransfer(transfers: Array<{sourceModel: string, targetModel: string, conversationData: ConversationMessage[], options?: TransferOptions}>): Batch context transfer
  • createChromeExtensionConfig(): Create Chrome extension configuration

Utility Methods

  • getSDKInfo(): Get SDK information
  • healthCheck(): Check SDK health
  • initialize(): Initialize SDK
  • close(): Close SDK

🛠️ Development

Setup

# Clone the repositorygit clone<repository-url>cd multimind-sdk# Install dependenciesnpm install# Build the projectnpm run build:examples# Run testsnpmtest# Run lintingnpm run lint

Available Scripts

npm run build# Build TypeScript to JavaScriptnpm run build:examples# Build with example fixesnpm runtest# Run test suitenpm run test:watch# Run tests in watch modenpm run test:coverage# Run tests with coveragenpm run lint# Run ESLintnpm run lint:fix# Fix linting issuesnpm run sync-features# Sync with backend featuresnpm run cli# Run CLInpm run demo# Run comprehensive demo

Project Structure

multimind-sdk/├── src/│   ├── bridge/│   │   └── multimind-bridge.ts    # Backend bridge setup│   ├── agent.ts                   # Basic agent functionality│   ├── fineTune.ts               # Basic fine-tuning functionality│   ├── rag.ts                    # Basic RAG functionality│   ├── adapters.ts               # Adapter management│   ├── evaluation.ts             # Model evaluation│   ├── models.ts                 # Model loading and routing│   ├── advancedFineTuning.ts     # Advanced fine-tuning (LoRA, Adapters, etc.)│   ├── advancedRAG.ts            # Advanced RAG with document management│   ├── modelConversion.ts        # Model conversion and optimization│   ├── compliance.ts             # Compliance monitoring and validation│   ├── advancedAgent.ts          # Advanced agents with tools and memory│   ├── modelClientSystem.ts      # LSTM, MoE, MultiModal, Federated routing│   ├── gateway.ts                # Gateway API and middleware│   ├── contextTransfer.ts        # Context transfer functionality│   └── index.ts                  # Main SDK class and exports├── example/│   ├── run-agent.ts              # Basic example│   ├── advanced-usage.ts         # Advanced example│   ├── comprehensive-demo.ts     # Complete feature demo│   └── context-transfer-cli.ts   # CLI implementation├── test/│   ├── sdk-smoke.test.ts         # Basic SDK tests│   ├── module-tests.test.ts      # Module functionality tests│   └── cli.test.ts               # CLI tests├── scripts/│   ├── fix-example-imports.js    # Fix example import paths│   ├── fix-all-imports.js        # Fix all import paths│   └── sync-features.js          # Sync with backend features├── package.json├── tsconfig.json└── README.md

🔧 Error Handling

The SDK includes comprehensive error handling. All methods throw errors with descriptive messages when operations fail:

try{constresponse=awaitsdk.generateWithAgent("Hello world");}catch(error){console.error('Generation failed:',error.message);}

🚨 Troubleshooting

Common Issues

  1. Initialization failed: Ensure all required dependencies are installed
  2. Model loading issues: Check that model files are accessible and valid
  3. Memory issues: For large models, ensure sufficient RAM and consider using quantization
  4. GPU issues: Ensure CUDA is properly installed for GPU acceleration
  5. Network issues: Check internet connectivity for cloud-based models

Debug Mode

Enable debug logging by setting the environment variable:

DEBUG=multimind-sdk npm run dev

📊 Testing

# Run all testsnpmtest# Run tests with coveragenpm run test:coverage# Run specific test filenpmtest -- test/sdk-smoke.test.ts

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite
  6. Submit a pull request

📄 License

Apache License 2.0 - seeLICENSE file for details.

🆘 Support

For issues and questions:

  • Create an issue on GitHub
  • Check the troubleshooting section
  • Ensure you have the latest version installed
  • Review the comprehensive examples

🔗 Related Links


Built with ❤️ by the MultiMind Team

Sponsor this project

  •  

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp