{"repo": "christelles152/rankbase", "files": {"apps/aega-art/src/services/deepseek.ts": {"cdff7bef9fb7f1ceaab234046020eabef40669c0": {"t": 1785746034.9138436, "n": 2752, "h": "b32e269c0fee2450", "c": "import { config } from '@rankbase/core/config';\nimport { fetchWithTimeout } from '@rankbase/core/lib/fetchWithTimeout';\nimport { logger } from '@rankbase/core/lib/logger';\nimport fs from 'fs';\nimport { expandPromptWithGemini } from '@rankbase/core/services/gemini';\n\n// Load secrets\nconst secrets = JSON.parse(fs.readFileSync('/home/chris/.openclaw/secrets/image-gen.json', 'utf8'));\nconst DEEPSEEK_KEY = secrets.deepseek_key;\n\n/**\n * DeepSeek text helpers for prompt expansion.\n *\n * Expands short prompts into detailed 60-100 word generation prompts.\n * DeepSeek V3 is uncensored and will handle adult content properly.\n * If DeepSeek fails, we fall back to Gemini 2.5 Flash (SFW framing).\n * If both fail, we return the original short prompt.\n */\nconst MODEL = 'deepseek-chat';\n\nconst EXPANSION_SYSTEM = [\n 'You are a creative director for an adult AI image generation platform.',\n 'Expand the given short prompt into a rich, detailed 60-100 word prompt for image generation.',\n 'Add specific details about pose, lighting, composition, style, mood, color palette, and artistic technique.',\n 'Be specific and evocative.',\n 'Output ONLY the expanded prompt, nothing else.'\n].join(' ');\n\nexport async function expandPromptWithDeepSeek(shortPrompt: string): Promise {\n if (!DEEPSEEK_KEY) {\n logger.info('DEEPSEEK_KEY unset, trying Gemini fallback');\n return await expandPromptWithGemini(shortPrompt);\n }\n\n const url = 'https://api.deepseek.com/chat/completions';\n try {\n const res = await fetchWithTimeout(url, {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${DEEPSEEK_KEY}`,\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n model: MODEL,\n messages: [\n { role: 'system', content: EXPANSION_SYSTEM },\n { role: 'user', content: shortPrompt }\n ],\n temperature: 0.9,\n max_tokens: 400,\n }),\n timeoutMs: config.PROVIDER_TIMEOUT_MS,\n });\n\n if (!res.ok) {\n const body = await res.text().catch(() => '');\n logger.warn({ status: res.status, body: body.slice(0, 200) }, 'deepseek expand failed');\n // Fallback to Gemini\n return await expandPromptWithGemini(shortPrompt);\n }\n\n const json = (await res.json()) as {\n choices?: Array<{ message?: { content?: string } }>;\n };\n const text = json.choices?.[0]?.message?.content?.trim();\n if (!text) {\n logger.warn('deepseek expand returned empty text, trying Gemini fallback');\n return await expandPromptWithGemini(shortPrompt);\n }\n return text;\n } catch (err) {\n logger.warn({ err }, 'deepseek expand threw, trying Gemini fallback');\n return await expandPromptWithGemini(shortPrompt);\n }\n}"}, "4a4ce322dd46adb506dcfa1fc56e3179defbe35d": {"t": 1785759063.994422, "n": 2752, "h": "b32e269c0fee2450", "c": "import { config } from '@rankbase/core/config';\nimport { fetchWithTimeout } from '@rankbase/core/lib/fetchWithTimeout';\nimport { logger } from '@rankbase/core/lib/logger';\nimport fs from 'fs';\nimport { expandPromptWithGemini } from '@rankbase/core/services/gemini';\n\n// Load secrets\nconst secrets = JSON.parse(fs.readFileSync('/home/chris/.openclaw/secrets/image-gen.json', 'utf8'));\nconst DEEPSEEK_KEY = secrets.deepseek_key;\n\n/**\n * DeepSeek text helpers for prompt expansion.\n *\n * Expands short prompts into detailed 60-100 word generation prompts.\n * DeepSeek V3 is uncensored and will handle adult content properly.\n * If DeepSeek fails, we fall back to Gemini 2.5 Flash (SFW framing).\n * If both fail, we return the original short prompt.\n */\nconst MODEL = 'deepseek-chat';\n\nconst EXPANSION_SYSTEM = [\n 'You are a creative director for an adult AI image generation platform.',\n 'Expand the given short prompt into a rich, detailed 60-100 word prompt for image generation.',\n 'Add specific details about pose, lighting, composition, style, mood, color palette, and artistic technique.',\n 'Be specific and evocative.',\n 'Output ONLY the expanded prompt, nothing else.'\n].join(' ');\n\nexport async function expandPromptWithDeepSeek(shortPrompt: string): Promise {\n if (!DEEPSEEK_KEY) {\n logger.info('DEEPSEEK_KEY unset, trying Gemini fallback');\n return await expandPromptWithGemini(shortPrompt);\n }\n\n const url = 'https://api.deepseek.com/chat/completions';\n try {\n const res = await fetchWithTimeout(url, {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${DEEPSEEK_KEY}`,\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n model: MODEL,\n messages: [\n { role: 'system', content: EXPANSION_SYSTEM },\n { role: 'user', content: shortPrompt }\n ],\n temperature: 0.9,\n max_tokens: 400,\n }),\n timeoutMs: config.PROVIDER_TIMEOUT_MS,\n });\n\n if (!res.ok) {\n const body = await res.text().catch(() => '');\n logger.warn({ status: res.status, body: body.slice(0, 200) }, 'deepseek expand failed');\n // Fallback to Gemini\n return await expandPromptWithGemini(shortPrompt);\n }\n\n const json = (await res.json()) as {\n choices?: Array<{ message?: { content?: string } }>;\n };\n const text = json.choices?.[0]?.message?.content?.trim();\n if (!text) {\n logger.warn('deepseek expand returned empty text, trying Gemini fallback');\n return await expandPromptWithGemini(shortPrompt);\n }\n return text;\n } catch (err) {\n logger.warn({ err }, 'deepseek expand threw, trying Gemini fallback');\n return await expandPromptWithGemini(shortPrompt);\n }\n}"}, "61eb89867c24789a87585fce72aefacd29507ebf": {"t": 1785759066.5930917, "n": 2694, "h": "df9113ff63810bcd", "c": "import { config } from '../config';\nimport { fetchWithTimeout } from '../lib/fetchWithTimeout';\nimport { logger } from '../lib/logger';\nimport fs from 'fs';\nimport { expandPromptWithGemini } from './gemini';\n\n// Load secrets\nconst secrets = JSON.parse(fs.readFileSync('/home/chris/.openclaw/secrets/image-gen.json', 'utf8'));\nconst DEEPSEEK_KEY = secrets.deepseek_key;\n\n/**\n * DeepSeek text helpers for prompt expansion.\n *\n * Expands short prompts into detailed 60-100 word generation prompts.\n * DeepSeek V3 is uncensored and will handle adult content properly.\n * If DeepSeek fails, we fall back to Gemini 2.5 Flash (SFW framing).\n * If both fail, we return the original short prompt.\n */\nconst MODEL = 'deepseek-chat';\n\nconst EXPANSION_SYSTEM = [\n 'You are a creative director for an adult AI image generation platform.',\n 'Expand the given short prompt into a rich, detailed 60-100 word prompt for image generation.',\n 'Add specific details about pose, lighting, composition, style, mood, color palette, and artistic technique.',\n 'Be specific and evocative.',\n 'Output ONLY the expanded prompt, nothing else.'\n].join(' ');\n\nexport async function expandPromptWithDeepSeek(shortPrompt: string): Promise {\n if (!DEEPSEEK_KEY) {\n logger.info('DEEPSEEK_KEY unset, trying Gemini fallback');\n return await expandPromptWithGemini(shortPrompt);\n }\n\n const url = 'https://api.deepseek.com/chat/completions';\n try {\n const res = await fetchWithTimeout(url, {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${DEEPSEEK_KEY}`,\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n model: MODEL,\n messages: [\n { role: 'system', content: EXPANSION_SYSTEM },\n { role: 'user', content: shortPrompt }\n ],\n temperature: 0.9,\n max_tokens: 400,\n }),\n timeoutMs: config.PROVIDER_TIMEOUT_MS,\n });\n\n if (!res.ok) {\n const body = await res.text().catch(() => '');\n logger.warn({ status: res.status, body: body.slice(0, 200) }, 'deepseek expand failed');\n // Fallback to Gemini\n return await expandPromptWithGemini(shortPrompt);\n }\n\n const json = (await res.json()) as {\n choices?: Array<{ message?: { content?: string } }>;\n };\n const text = json.choices?.[0]?.message?.content?.trim();\n if (!text) {\n logger.warn('deepseek expand returned empty text, trying Gemini fallback');\n return await expandPromptWithGemini(shortPrompt);\n }\n return text;\n } catch (err) {\n logger.warn({ err }, 'deepseek expand threw, trying Gemini fallback');\n return await expandPromptWithGemini(shortPrompt);\n }\n}"}}}}