Skip to content

Repository files navigation

🌟 Sashi - Your Magical AI-Powered Admin Companion! πŸ€–

Transforming admin tasks into a delightful experience! ✨

πŸš€ Welcome to the Enchanted World of Sashi!

Imagine a world where managing your application is as easy as having a conversation with a friend. Sashi is here to make that dream a reality! With its AI-powered chat interface, you can perform admin tasks with the ease of a magical spell. πŸͺ„

✨ Why You'll Love Sashi

  • πŸ€– AI-Powered Chat: Execute admin tasks with simple, natural language commands.
  • πŸ”— Seamless Integration: Effortlessly connect with Sashi-labeled functions in your backend.
  • πŸ’¬ User-Friendly: No need for complex commandsβ€”just speak your mind!
  • ⚑ Real-Time Updates: Get instant feedback and results.

πŸ› οΈ Setting Up Your Magical Portal

Sashi is served directly from the Sashi middleware. Here's how to set it up:

  1. Prepare Your Backend: Use @sashimo/lib to set up the Sashi middleware.
import express from "express"
import { createMiddleware } from "@sashimo/lib"

const app = express()

app.use(
    "/sashi",
    createMiddleware({
        openAIKey: process.env.OPENAI_API_KEY || "",
        apiSecretKey: process.env.SASHI_API_SECRET_KEY || "",
        hubUrl: "https://hub.usesashi.com", // Optional: Connect to Sashi Hub
        // Other configuration options
    })
)
  1. Access the Admin Chat: Open your browser and navigate to the path where you've mounted the middleware, followed by /bot. For example:

    • http://yourwebsite.com/sashi/bot
  2. Customize Your Path: Use the sashiServerUrl option to set a custom route.

app.use(
    "/control-panel",
    createMiddleware({
        sashiServerUrl: "http://yourwebsite.com/control-panel",
        apiSecretKey: process.env.SASHI_API_SECRET_KEY || "",
        hubUrl: "https://hub.usesashi.com", // Optional: Connect to Sashi Hub
        // other options...
    })
)

πŸͺ„ Sashi CLI - Your Installation Wizard

The Sashi CLI makes setting up and managing your Sashi installation a breeze! Here are the magical commands at your disposal:

Quick Setup Commands

# Setup Sashi in an existing project
sashi setup

# Create a new project with Sashi pre-configured
sashi init my-awesome-project

# Add Sashi middleware to your project
sashi add

# Update Sashi packages to latest version
sashi update

# Check your Sashi setup and configuration
sashi check

Framework Support

The CLI automatically detects your project type and provides the perfect setup:

  • Next.js: Full-stack admin capabilities
  • Node.js/Express: Backend admin functions
  • TypeScript: Enhanced type safety and IntelliSense

CLI Options

# Setup with specific framework
sashi setup --framework nextjs

# Use TypeScript setup
sashi setup --typescript

# Skip prompts and use defaults
sashi setup --yes

# Provide API key directly
sashi setup --api-key your-openai-key

# Provide Sashi Hub URL
sashi setup --hub-url https://hub.usesashi.com

🏷️ Labeling and Registering Functions

Before diving into the magic, label and register your functions:

Basic Example

import {
    AIArray,
    AIFunction,
    AIObject,
    registerFunctionIntoAI,
} from "@sashimo/lib"

const UserObject = new AIObject("User", "a user in the system", true).field({
    name: "email",
    description: "the email of the user",
    type: "string",
    required: true,
})

const GetUserByIdFunction = new AIFunction("get_user_by_id", "get a user by id")
    .args({
        name: "userId",
        description: "a user's id",
        type: "number",
        required: true,
    })
    .returns(UserObject)
    .implement(async (userId: number) => {
        const user = await getUserById(userId)
        return user
    })

registerFunctionIntoAI("get_user_by_id", GetUserByIdFunction)

Advanced Example: Handling Multiple Objects

const ProductObject = new AIObject(
    "Product",
    "a product in the inventory",
    true
)
    .field({
        name: "productId",
        description: "the unique identifier for a product",
        type: "number",
        required: true,
    })
    .field({
        name: "productName",
        description: "the name of the product",
        type: "string",
        required: true,
    })

const GetProductsFunction = new AIFunction(
    "get_products",
    "retrieve a list of products"
)
    .returns(new AIArray(ProductObject))
    .implement(async () => {
        const products = await getAllProducts()
        return products
    })

registerFunctionIntoAI("get_products", GetProductsFunction)

Example: Using AIArray for Complex Returns

const OrderObject = new AIObject("Order", "an order placed by a user", true)
    .field({
        name: "orderId",
        description: "the unique identifier for an order",
        type: "number",
        required: true,
    })
    .field({
        name: "orderDate",
        description: "the date when the order was placed",
        type: "string",
        required: true,
    })

const GetUserOrdersFunction = new AIFunction(
    "get_user_orders",
    "get all orders for a user"
)
    .args({
        name: "userId",
        description: "a user's id",
        type: "number",
        required: true,
    })
    .returns(new AIArray(OrderObject))
    .implement(async (userId: number) => {
        const orders = await getOrdersByUserId(userId)
        return orders
    })

registerFunctionIntoAI("get_user_orders", GetUserOrdersFunction)

πŸ›‘οΈ Security Spells

Protect your magical realm with robust security:

  • Custom Middleware: Validate session tokens before reaching Sashi.
  • Session Management: Use the getSession function to manage sessions securely.
import { Request, Response, NextFunction } from "express"
import { createMiddleware } from "@sashimo/lib"

const verifySessionMiddleware = async (
    req: Request,
    res: Response,
    next: NextFunction
) => {
    const sessionToken = req.headers["x-sashi-session-token"]

    if (!sessionToken) {
        return res.status(401).send("Unauthorized")
    }

    if (sessionToken !== "userone-session-token") {
        return res.status(401).send("Unauthorized")
    }

    next()
}

app.use(
    "/sashi",
    verifySessionMiddleware,
    createMiddleware({
        openAIKey: process.env.OPENAI_API_KEY || "",
        getSession: async (req, res) => {
            return "userone-session-token"
        },
    })
)

πŸ“š Dive Deeper into the Magic

For more spells and incantations, visit our Sashi documentation (coming soon.).

🀝 Join the Sashi Fellowship

Are you ready to make admin tasks a breeze? Join us on this magical journey! Check out our Contributing Guide.

βš–οΈ License

Sashi is released under the MIT License.

πŸ”„ Workflow System

This update introduces a powerful workflow system that enables users to create automated sequences of your registered functions.

πŸ“Š How Workflows Work

Once you register your functions with Sashi, they automatically become available for use in workflows. Users can then:

  1. Create sequences of actions using your registered functions
  2. Pass data between steps - Output from one function becomes input to another
  3. Save and reuse workflows for common tasks
  4. Execute workflows with a single click instead of multiple manual steps

🌐 Data Flow Between Systems

The workflow system handles all the data flow between your registered functions and external systems without you needing to implement any additional code:

sequenceDiagram
    participant Dev as Developer
    participant Sashi as Sashi System/Your Backend
    participant User as User
    participant Ext as External Services

    Dev->>Sashi: Register functions
    User->>Sashi: Create workflows using functions
    User->>Sashi: Execute workflow
    Sashi->>Ext: Call external APIs if needed
    Ext-->>Sashi: Return results
    Sashi->>Sashi: Process data between steps
    Sashi-->>User: Display final results
Loading

πŸ“ What You Need To Do

As a developer, you only need to:

  1. Register your functions using the AIFunction system (as shown in previous examples)
  2. Ensure proper input/output typing so the workflow system knows what data can be passed between steps
  3. Document your functions well so users understand what each function does

The workflow storage, execution, and visualization are all handled automatically by the Sashi system.

For more information on how users can use the workflows you enable, direct them to our Workflow Documentation.

πŸš€ Quick Start - Try Sashi Now!

Deploy a complete Sashi integration example with one click:

🌟 Live Demo & Integration Example

Deploy with Vercel

A comprehensive Express.js server showcasing all Sashi features with extensive AI functions.

✨ What's Included:

  • πŸ€– AI Admin Panel - Natural language interface at /sashi/bot
  • πŸ‘₯ User Management - Complete CRUD operations
  • πŸ“§ Email Services - Templates, sending, analytics
  • πŸ“Š Analytics - Event tracking, metrics, conversion funnels
  • πŸ’³ Payment Processing - Transactions, subscriptions, refunds
  • πŸ“ File Operations - Upload, storage, metadata, search
  • πŸ“ Content Management - Articles, publishing, SEO
  • πŸ” Authentication Examples - Session tokens, security patterns

πŸš€ Deployment Requirements:

  • Only requires an OpenAI API key to get started
  • Deploys in under 2 minutes
  • No database setup needed (uses in-memory data for demo)

πŸ“š Perfect For:

  • Testing Sashi capabilities
  • Learning integration patterns
  • Backend API development
  • Comprehensive feature exploration

Crafted with πŸ’– by the Sashimotors

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages