mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 22:32:27 +08:00
feat: add minimal style mode toggle for faster diagram generation (#260)
* feat: add minimal style mode toggle for faster diagram generation - Add Minimal/Styled toggle switch in chat input UI - When enabled, removes color/style instructions from system prompt - Faster generation with plain black/white diagrams - Improves XML auto-fix: handle foreign tags, extra closing tags, trailing garbage - Fix isMxCellXmlComplete to strip Anthropic function-calling wrappers - Add debug logging for truncation detection diagnosis * fix: prevent false XML parse errors during streaming - Escape unescaped & characters in convertToLegalXml() before DOMParser validation - Only log console.error for final output, not during streaming updates - Prevents Next.js dev mode error overlay from showing for expected streaming states
This commit is contained in:
@@ -202,6 +202,9 @@ async function handleChatRequest(req: Request): Promise<Response> {
|
||||
modelId: req.headers.get("x-ai-model"),
|
||||
}
|
||||
|
||||
// Read minimal style preference from header
|
||||
const minimalStyle = req.headers.get("x-minimal-style") === "true"
|
||||
|
||||
// Get AI model with optional client overrides
|
||||
const { model, providerOptions, headers, modelId } =
|
||||
getAIModel(clientOverrides)
|
||||
@@ -213,7 +216,7 @@ async function handleChatRequest(req: Request): Promise<Response> {
|
||||
)
|
||||
|
||||
// Get the appropriate system prompt based on model (extended for Opus/Haiku 4.5)
|
||||
const systemMessage = getSystemPrompt(modelId)
|
||||
const systemMessage = getSystemPrompt(modelId, minimalStyle)
|
||||
|
||||
// Extract file parts (images) from the last message
|
||||
const fileParts =
|
||||
|
||||
Reference in New Issue
Block a user