mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-07-25 17:35:25 +02:00
Update qwen.js
This commit is contained in:
parent
d116e90126
commit
21ad69693f
1 changed files with 19 additions and 2 deletions
|
@ -85,7 +85,24 @@ export class Qwen {
|
|||
if (typeof res === 'string') {
|
||||
res = res.replace(/<thinking>/g, '<think>').replace(/<\/thinking>/g, '</think>');
|
||||
}
|
||||
log(JSON.stringify(messages), res);
|
||||
|
||||
if (imageData) { // If imageData was part of this sendRequest call
|
||||
// `messages` here includes system prompt and image data
|
||||
let visionPromptText = "";
|
||||
if (messages.length > 0) {
|
||||
const lastTurn = messages[messages.length - 1];
|
||||
if (lastTurn.role === 'user' && Array.isArray(lastTurn.content)) {
|
||||
const textPart = lastTurn.content.find(part => part.text);
|
||||
if (textPart) visionPromptText = textPart.text;
|
||||
} else if (lastTurn.role === 'user' && typeof lastTurn.content === 'string'){
|
||||
visionPromptText = lastTurn.content;
|
||||
}
|
||||
}
|
||||
logVision(messages, imageData, res, visionPromptText);
|
||||
} else {
|
||||
// messages already includes system prompt if no imageData
|
||||
log(JSON.stringify(messages), res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -117,4 +134,4 @@ export class Qwen {
|
|||
throw new Error('Max retries reached, request failed.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue