Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions CAPTCHA-automatic-recognition/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1042,15 +1042,15 @@ export default {
contents: [
{
parts: [
{
text: prompt,
},
{
inline_data: {
mime_type: "image/png",
data: base64Image,
},
},
{
text: prompt,
},
],
},
],
Expand All @@ -1062,22 +1062,21 @@ export default {
"Content-Type": "application/json",
},
});

// 提取结果
if (response.data.candidates && response.data.candidates.length > 0) {
const candidate = response.data.candidates[0];
if (
candidate.content &&
candidate.content.parts &&
candidate.content.parts.length > 0
) {
const text = candidate.content.parts[0].text || "";
// 只保留数字、字母和负号
return text.replace(/[^a-zA-Z0-9\-]/g, "");
const parts = response?.data?.candidates?.[0]?.content?.parts;
if (!Array.isArray(parts) || parts.length === 0) {
return "";
}
let fullText = "";
for (const part of parts) {
if (typeof part?.text === "string" && part.text && !part.thought) {
fullText += part.text;
}
}

return "";
if (!fullText) {
return "";
}
const cleanText = fullText.replace(/<think>[\s\S]*?<\/think>/gi, "");
return cleanText.replace(/[^a-zA-Z0-9\-]/g, "");
},

/**
Expand Down