diff --git a/components/ui/card.tsx b/components/ui/card.tsx deleted file mode 100644 index 99541f3..0000000 --- a/components/ui/card.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import * as React from "react" - -import { cn } from "@/lib/utils" - -function Card({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) -} - -function CardHeader({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) -} - -function CardTitle({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) -} - -function CardDescription({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) -} - -function CardAction({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) -} - -function CardContent({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) -} - -function CardFooter({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) -} - -export { - Card, - CardHeader, - CardFooter, - CardTitle, - CardAction, - CardDescription, - CardContent, -} diff --git a/hooks/use-diagram-tool-handlers.ts b/hooks/use-diagram-tool-handlers.ts index 0e4c7bb..0636f00 100644 --- a/hooks/use-diagram-tool-handlers.ts +++ b/hooks/use-diagram-tool-handlers.ts @@ -1,4 +1,5 @@ import type { MutableRefObject } from "react" +import type { DiagramOperation } from "@/components/chat/types" import { isMxCellXmlComplete, wrapWithMxFile } from "@/lib/utils" const DEBUG = process.env.NODE_ENV === "development" @@ -29,12 +30,6 @@ type AddToolOutputParams = AddToolOutputSuccess | AddToolOutputError type AddToolOutputFn = (params: AddToolOutputParams) => void -interface DiagramOperation { - operation: "update" | "add" | "delete" - cell_id: string - new_xml?: string -} - interface UseDiagramToolHandlersParams { partialXmlRef: MutableRefObject editDiagramOriginalXmlRef: MutableRefObject> diff --git a/lib/ai-config.ts b/lib/ai-config.ts deleted file mode 100644 index 128d830..0000000 --- a/lib/ai-config.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { STORAGE_KEYS } from "./storage" - -/** - * Get AI configuration from localStorage. - * Returns API keys and settings for custom AI providers. - * Used to override server defaults when user provides their own API key. - */ -export function getAIConfig() { - if (typeof window === "undefined") { - return { - accessCode: "", - aiProvider: "", - aiBaseUrl: "", - aiApiKey: "", - aiModel: "", - } - } - - return { - accessCode: localStorage.getItem(STORAGE_KEYS.accessCode) || "", - aiProvider: localStorage.getItem(STORAGE_KEYS.aiProvider) || "", - aiBaseUrl: localStorage.getItem(STORAGE_KEYS.aiBaseUrl) || "", - aiApiKey: localStorage.getItem(STORAGE_KEYS.aiApiKey) || "", - aiModel: localStorage.getItem(STORAGE_KEYS.aiModel) || "", - } -} diff --git a/lib/ai-providers.ts b/lib/ai-providers.ts index 806493d..918dafe 100644 --- a/lib/ai-providers.ts +++ b/lib/ai-providers.ts @@ -8,22 +8,9 @@ import { createOpenAI, openai } from "@ai-sdk/openai" import { fromNodeProviderChain } from "@aws-sdk/credential-providers" import { createOpenRouter } from "@openrouter/ai-sdk-provider" import { createOllama, ollama } from "ollama-ai-provider-v2" +import type { ProviderName } from "@/lib/types/model-config" -export type ProviderName = - | "bedrock" - | "openai" - | "anthropic" - | "google" - | "azure" - | "ollama" - | "openrouter" - | "deepseek" - | "siliconflow" - | "sglang" - | "gateway" - | "edgeone" - | "doubao" - | "modelscope" +export type { ProviderName } interface ModelConfig { model: any diff --git a/lib/token-counter.ts b/lib/token-counter.ts deleted file mode 100644 index 1f9b006..0000000 --- a/lib/token-counter.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Token counting utilities using js-tiktoken - * - * Uses cl100k_base encoding (GPT-4) which is close to Claude's tokenization. - * This is a pure JavaScript implementation, no WASM required. - */ - -import { encodingForModel } from "js-tiktoken" -import { DEFAULT_SYSTEM_PROMPT, EXTENDED_SYSTEM_PROMPT } from "./system-prompts" - -const encoder = encodingForModel("gpt-4o") - -/** - * Count the number of tokens in a text string - * @param text - The text to count tokens for - * @returns The number of tokens - */ -export function countTextTokens(text: string): number { - return encoder.encode(text).length -} - -/** - * Get token counts for the system prompts - * Useful for debugging and optimizing prompt sizes - * @returns Object with token counts for default and extended prompts - */ -export function getSystemPromptTokenCounts(): { - default: number - extended: number - additions: number -} { - const defaultTokens = countTextTokens(DEFAULT_SYSTEM_PROMPT) - const extendedTokens = countTextTokens(EXTENDED_SYSTEM_PROMPT) - return { - default: defaultTokens, - extended: extendedTokens, - additions: extendedTokens - defaultTokens, - } -} diff --git a/lib/types/model-config.ts b/lib/types/model-config.ts index 9e38368..edb6682 100644 --- a/lib/types/model-config.ts +++ b/lib/types/model-config.ts @@ -6,6 +6,7 @@ export type ProviderName = | "google" | "azure" | "bedrock" + | "ollama" | "openrouter" | "deepseek" | "siliconflow" @@ -76,6 +77,10 @@ export const PROVIDER_INFO: Record< google: { label: "Google" }, azure: { label: "Azure OpenAI" }, bedrock: { label: "Amazon Bedrock" }, + ollama: { + label: "Ollama", + defaultBaseUrl: "http://localhost:11434", + }, openrouter: { label: "OpenRouter" }, deepseek: { label: "DeepSeek" }, siliconflow: { @@ -99,7 +104,7 @@ export const PROVIDER_INFO: Record< } // Suggested models per provider for quick add -export const SUGGESTED_MODELS: Record = { +export const SUGGESTED_MODELS: Partial> = { openai: [ "gpt-5.2-pro", "gpt-5.2-chat-latest", diff --git a/lib/utils.ts b/lib/utils.ts index 4c64399..2c1f8b4 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,6 +1,9 @@ import { type ClassValue, clsx } from "clsx" import * as pako from "pako" import { twMerge } from "tailwind-merge" +import type { DiagramOperation } from "@/components/chat/types" + +export type { DiagramOperation } export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) @@ -473,12 +476,6 @@ export function replaceNodes(currentXML: string, nodes: string): string { // ID-based Diagram Operations // ============================================================================ -export interface DiagramOperation { - operation: "update" | "add" | "delete" - cell_id: string - new_xml?: string -} - export interface OperationError { type: "update" | "add" | "delete" cellId: string diff --git a/package.json b/package.json index 4b580d6..3cf3fad 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,6 @@ "clsx": "^2.1.1", "cmdk": "^1.1.1", "idb": "^8.0.3", - "js-tiktoken": "^1.0.21", "jsonrepair": "^3.13.1", "lucide-react": "^0.562.0", "motion": "^12.23.25",