Skip to content

CanvasAnvil is an open source AI diagram maker and flowchart generator - an infinite-canvas diagram editor and self-hosted drawio alternative that writes editable .drawio files. Text to diagram, then fix nodes, layout and labels in place. Also AI presentations, interior design CAD/BOM, posters and infographics.

827 B
Raw Blame
import { STORAGE_KEYS } from "@/workspaces/diagram/storage"
import { DEFAULT_AI_CONFIG } from "@contracts/ai";
import { getAIConfig as getWorkspaceAIConfig } from "@/ai/storage";
import type { AIConfig } from "@contracts/ai"

/**
 * The Diagram workspace sends its model settings to `/api/chat` alongside an
 * optional deployment access code. The model settings themselves are the
 * shared workspace config; only the access code is Diagram-specific.
 */
export interface DiagramRequestConfig {
    accessCode: string
    ai: AIConfig
}

export function getAIConfig(): DiagramRequestConfig {
    if (typeof window === "undefined") {
        return { accessCode: "", ai: DEFAULT_AI_CONFIG }
    }
    return {
        accessCode: localStorage.getItem(STORAGE_KEYS.accessCode) || "",
        ai: getWorkspaceAIConfig(),
    }
}