const path = require('path') const aiModule = require(path.join(__dirname, '../../../../ai/ai.js')) async function executeText2text({ prompt, model, folderPath }) { const p = prompt != null ? String(prompt).trim() : '' const m = model != null ? String(model).trim().toLowerCase() : '' const action = m === 'doubao' ? 'doubao_text2text' : 'text2text' try { const result = await aiModule.run(action, p) if (!result.success) return { success: false, error: result.error || 'text2text 失败' } const data = result.data const text = data?.choices?.[0]?.message?.content ?? data?.choices?.[0]?.text ?? '' return { success: true, value: typeof text === 'string' ? text : String(text) } } catch (e) { return { success: false, error: (e && (e.message || String(e))) || 'text2text 异常' } } } module.exports = { executeText2text }