mirror of
https://github.com/jnsahaj/tweakcn.git
synced 2026-08-28 23:02:07 +08:00
d21c8e3d40
Uploaded images were inlined as full-resolution base64 in the message metadata, and the entire chat history is posted on every turn. Two 4MB uploads exceeded the 4.5MB request body cap, so the platform rejected the request before the route ran (FUNCTION_PAYLOAD_TOO_LARGE). - Downscale and re-encode raster uploads client-side (1536px longest edge, WebP with a JPEG fallback, ~300KB target). UI screenshots land around 12KB with imperceptible color drift, so token extraction is unaffected. - Trim images from the oldest messages when the serialized request body would still exceed the budget, rather than failing the request outright. - Raise MAX_IMAGE_FILES from 2 to 5 now that the payload allows it, and wrap the multi-image message preview row so the thumbnails stay legible. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
82 lines
1.8 KiB
TypeScript
82 lines
1.8 KiB
TypeScript
export const AI_PROMPT_CHARACTER_LIMIT = 1000;
|
|
|
|
export const DEBOUNCE_DELAY = 50;
|
|
|
|
export const AI_REQUEST_FREE_TIER_LIMIT = 5;
|
|
|
|
export const MAX_IMAGE_FILES = 5;
|
|
export const MAX_IMAGE_FILE_SIZE = 4 * 1024 * 1024; // 4MB
|
|
export const MAX_SVG_FILE_SIZE = 1 * 1024 * 1024; // 1MB
|
|
|
|
// Uploaded images are inlined as base64 in every chat request, so they are downscaled and
|
|
// re-encoded before being attached to keep the payload under the serverless body limit.
|
|
export const MAX_IMAGE_DIMENSION = 1536; // px, longest edge
|
|
export const TARGET_IMAGE_BYTES = 300 * 1024; // encoded bytes, ~400KB once base64'd
|
|
|
|
// Serverless functions reject request bodies larger than 4.5MB before they ever run, so the
|
|
// chat history is kept comfortably below that.
|
|
export const MAX_CHAT_REQUEST_BYTES = 3.5 * 1024 * 1024;
|
|
|
|
export const MAX_FREE_THEMES = 10;
|
|
|
|
export const COMMUNITY_THEMES_PAGE_SIZE = 20;
|
|
|
|
export const COMMUNITY_THEME_TAGS = [
|
|
"colorful",
|
|
"minimal",
|
|
"professional",
|
|
"playful",
|
|
"warm",
|
|
"cool",
|
|
"high-contrast",
|
|
"pastel",
|
|
"earthy",
|
|
"neon",
|
|
"retro",
|
|
"futuristic",
|
|
"nature",
|
|
"monochrome",
|
|
"vibrant",
|
|
"elegant",
|
|
"bold",
|
|
"soft",
|
|
"gradient",
|
|
"flat",
|
|
"glassmorphism",
|
|
"neumorphism",
|
|
"brutalist",
|
|
"corporate",
|
|
"startup",
|
|
"dashboard",
|
|
"e-commerce",
|
|
"portfolio",
|
|
"blog",
|
|
"saas",
|
|
"landing-page",
|
|
"ocean",
|
|
"sunset",
|
|
"forest",
|
|
"candy",
|
|
"midnight",
|
|
"nordic",
|
|
"tropical",
|
|
"autumn",
|
|
"winter",
|
|
"spring",
|
|
"cyberpunk",
|
|
"vintage",
|
|
"art-deco",
|
|
"industrial",
|
|
"zen",
|
|
"accessible",
|
|
"romantic",
|
|
"geometric",
|
|
] as const;
|
|
|
|
export const MAX_TAGS_PER_THEME = 5;
|
|
|
|
// OAuth 2.0 Token Expiry
|
|
export const OAUTH_ACCESS_TOKEN_EXPIRY_SECONDS = 60 * 60; // 1 hour
|
|
export const OAUTH_REFRESH_TOKEN_EXPIRY_SECONDS = 60 * 60 * 24 * 30; // 30 days
|
|
export const OAUTH_AUTHORIZATION_CODE_EXPIRY_SECONDS = 60 * 10; // 10 minutes
|