Skip to content

toolpack-ai/toolpack-sdk-integration-demos

Repository files navigation

Toolpack SDK Integration Examples

Demo Project — This repository is part of the Toolpack SDK ecosystem. It provides minimal, runnable examples demonstrating various integration patterns.

This directory contains minimal Node.js examples demonstrating various integration patterns with the Toolpack SDK.

Directory Structure

samples/toolpack-sdk-integrations/
├── 01-basic-providers/          # Basic provider integrations
├── 02-multi-provider/           # Multi-provider setup
├── 03-custom-provider/          # Custom provider implementation
├── 04-tools-integration/        # Tool loading and usage
├── 05-modes-and-workflows/      # Mode-based execution
├── 06-streaming/                # Real-time streaming
├── 07-multimodal/               # Image and file handling
├── 08-embeddings/               # Text embeddings
├── 09-event-driven/             # Event handling
├── 10-advanced-config/          # Configuration patterns
├── 11-knowledge/                # Knowledge & RAG integrations
└── README.md                    # This file

Quick Start

  1. Install dependencies (from SDK root):

    npm install
    npm run build
  2. Set up environment variables:

    export TOOLPACK_OPENAI_KEY="sk-..."
    export TOOLPACK_ANTHROPIC_KEY="sk-ant-..."
    export TOOLPACK_GEMINI_KEY="AIza..."
  3. Run any example:

    cd samples/toolpack-sdk-integrations/01-basic-providers
    node openai.js

Examples Overview

01. Basic Providers

  • openai.js - OpenAI/GPT integration
  • anthropic.js - Anthropic/Claude integration
  • gemini.js - Google Gemini integration
  • ollama.js - Local Ollama models

02. Multi-Provider

  • switch-providers.js - Dynamic provider switching
  • list-models.js - Discover available models
  • fallback-strategy.js - Provider fallback logic

03. Custom Provider

  • custom-adapter.js - Implement custom provider
  • openai-compatible.js - OpenAI-compatible endpoints

04. Tools Integration

  • builtin-tools.js - Use built-in tools
  • custom-tools.js - Create custom tools
  • runtime-loading.js - Dynamic tool loading

05. Modes and Workflows

  • agent-mode.js - Autonomous agent execution
  • workflow-planning.js - Multi-step workflows
  • custom-mode.js - Define custom modes

06. Streaming

  • basic-streaming.js - Token-by-token streaming
  • workflow-streaming.js - Stream workflow progress
  • progress-tracking.js - Real-time progress events

07. Multimodal

  • image-input.js - Process images (file, base64, URL)
  • file-upload.js - Provider file upload API
  • vision-models.js - Vision-capable models

08. Embeddings

  • generate-embeddings.js - Create text embeddings
  • similarity-search.js - Vector similarity

09. Event-Driven

  • status-events.js - Provider status tracking
  • tool-events.js - Tool execution monitoring
  • workflow-events.js - Workflow lifecycle events

10. Advanced Config

  • config-file.js - Use toolpack.config.json
  • environment-vars.js - Environment-based config
  • system-prompts.js - Custom system prompts

11. Knowledge Integrations

  • persistent-cache.js - Build a Knowledge base with PersistentKnowledgeProvider and skip re-embedding using reSync: false
  • knowledge-search.js - Attach Knowledge to Toolpack.init() so AI calls knowledge_search with cached docs

Environment Variables

Each example may require different API keys:

# OpenAI
export TOOLPACK_OPENAI_KEY="sk-..."

# Anthropic
export TOOLPACK_ANTHROPIC_KEY="sk-ant-..."

# Google Gemini
export TOOLPACK_GEMINI_KEY="AIza..."

# Optional: Custom base URLs
export OPENAI_BASE_URL="https://api.openai.com/v1"
export OLLAMA_BASE_URL="http://localhost:11434"

Documentation

For complete API documentation, visit: Toolpack SDK Docs

Tips

  • Start with 01-basic-providers to understand the fundamentals
  • Each example is self-contained and can run independently
  • Check the comments in each file for detailed explanations
  • Examples use ES modules - ensure your Node.js version supports them

Contributing

Feel free to add more examples or improve existing ones!

Support


Author: Sajeer

About

Simple demo integrations for toolpack SDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors