Update index.js
Browse files487 unmodified lines488489490491491493494495496497498499500501502503504505492493494495496497498499500501502503504505506507508509510511512513514487 unmodified lines res.write('data: [DONE]\n\n'); continue; } console.log("data", data); let linejosn = JSON.parse(data); if (linejosn.response === "token" && model == "grok-latest") { const token = linejosn.token; if (token && token.length > 0) { const responseData = MessageProcessor.createChatResponse(token, model, true); res.write(`data: ${JSON.stringify(responseData)}\n\n`); } } else if (linejosn.response === "modelResponse" && model === 'grok-latest-image') { if (linejosn?.modelResponse?.generatedImageUrls?.length > 0) { imageUrl = linejosn.modelResponse.generatedImageUrls[0]; // 获取第一个URL const dataImage = await handleImageResponse(imageUrl); const responseData = MessageProcessor.createChatResponse(dataImage, model, true); res.write(`data: ${JSON.stringify(responseData)}\n\n`); } switch (model) { case "grok-latest": if (linejosn.response === "token") { const token = linejosn.token; if (token && token.length > 0) { const responseData = MessageProcessor.createChatResponse(token, model, true); res.write(`data: ${JSON.stringify(responseData)}\n\n`); } } break; case "grok-latest-image": if (linejosn.response === "modelResponse") { if (linejosn?.modelResponse?.generatedImageUrls?.length > 0) { let imageUrl = linejosn.modelResponse.generatedImageUrls[0]; // 获取第一个URL const dataImage = await handleImageResponse(imageUrl); const responseData = MessageProcessor.createChatResponse(dataImage, model, true); res.write(`data: ${JSON.stringify(responseData)}\n\n`); } } break; } }
index.js+20-14