fix: update terminology from 'multimodal recognition' to 'OCR text recognition'
This commit is contained in:
parent
95d8f03c48
commit
ff2d2bf290
400
worker.js
400
worker.js
@ -213,11 +213,11 @@ async function handleProxyUpload(request) {
|
|||||||
try {
|
try {
|
||||||
const formData = await request.formData();
|
const formData = await request.formData();
|
||||||
const cookie = request.headers.get('x-custom-cookie') || '';
|
const cookie = request.headers.get('x-custom-cookie') || '';
|
||||||
|
|
||||||
// 从cookie中提取token
|
// 从cookie中提取token
|
||||||
const tokenMatch = cookie.match(/token=([^;]+)/);
|
const tokenMatch = cookie.match(/token=([^;]+)/);
|
||||||
const token = tokenMatch ? tokenMatch[1] : '';
|
const token = tokenMatch ? tokenMatch[1] : '';
|
||||||
|
|
||||||
const response = await fetch('https://chat.qwenlm.ai/api/v1/files/', {
|
const response = await fetch('https://chat.qwenlm.ai/api/v1/files/', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -229,7 +229,7 @@ async function handleProxyUpload(request) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
return new Response(JSON.stringify(data), {
|
return new Response(JSON.stringify(data), {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -252,10 +252,10 @@ async function handleProxyUpload(request) {
|
|||||||
// 通用的识别函数
|
// 通用的识别函数
|
||||||
async function recognizeImage(token, imageId, request) {
|
async function recognizeImage(token, imageId, request) {
|
||||||
const cookie = request.headers.get('x-custom-cookie') || '';
|
const cookie = request.headers.get('x-custom-cookie') || '';
|
||||||
|
|
||||||
// 从请求头中获取高级模式状态和自定义prompt
|
// 从请求头中获取高级模式状态和自定义prompt
|
||||||
const advancedMode = request.headers.get('x-advanced-mode') === 'true';
|
const advancedMode = request.headers.get('x-advanced-mode') === 'true';
|
||||||
|
|
||||||
// 解码自定义prompt
|
// 解码自定义prompt
|
||||||
let customPrompt = '';
|
let customPrompt = '';
|
||||||
try {
|
try {
|
||||||
@ -267,27 +267,27 @@ async function recognizeImage(token, imageId, request) {
|
|||||||
console.error('Prompt解码错误:', error);
|
console.error('Prompt解码错误:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultPrompt = '请识别图片中的内容,注意以下要求:\n' +
|
const defaultPrompt =
|
||||||
'对于数学公式和普通文本:\n' +
|
'不要输出任何额外的解释或说明,禁止输出例如:识别内容、以上内容已严格按照要求进行格式化和转换等相关无意义的文字!' + '请识别图片中的内容,注意以下要求:\n' +
|
||||||
'1. 所有数学公式和数学符号都必须使用标准的LaTeX格式\n' +
|
'对于数学公式和普通文本:\n' +
|
||||||
'2. 行内公式使用单个$符号包裹,如:$x^2$\n' +
|
'1. 所有数学公式和数学符号都必须使用标准的LaTeX格式\n' +
|
||||||
'3. 独立公式块使用两个$$符号包裹,如:$$\\sum_{i=1}^n i^2$$\n' +
|
'2. 行内公式使用单个$符号包裹,如:$x^2$\n' +
|
||||||
'4. 普通文本保持原样,不要使用LaTeX格式\n' +
|
'3. 独立公式块使用两个$$符号包裹,如:$$\\sum_{i=1}^n i^2$$\n' +
|
||||||
'5. 保持原文的段落格式和换行\n' +
|
'4. 普通文本保持原样,不要使用LaTeX格式\n' +
|
||||||
'6. 明显的换行使用\\n表示\n' +
|
'5. 保持原文的段落格式和换行\n' +
|
||||||
'7. 确保所有数学符号都被正确包裹在$或$$中\n\n' +
|
'6. 明显的换行使用\\n表示\n' +
|
||||||
'对于验证码图片:\n' +
|
'7. 确保所有数学符号都被正确包裹在$或$$中\n\n' +
|
||||||
'1. 只输出验证码字符,不要加任何额外解释\n' +
|
'对于验证码图片:\n' +
|
||||||
'2. 忽略干扰线和噪点\n' +
|
'1. 只输出验证码字符,不要加任何额外解释\n' +
|
||||||
'3. 注意区分相似字符,如0和O、1和l、2和Z等\n' +
|
'2. 忽略干扰线和噪点\n' +
|
||||||
'4. 验证码通常为4-6位字母数字组合\n\n' +
|
'3. 注意区分相似字符,如0和O、1和l、2和Z等\n' +
|
||||||
'不要输出任何额外的解释或说明';
|
'4. 验证码通常为4-6位字母数字组合\n\n' +
|
||||||
|
'';
|
||||||
const response = await fetch('https://chat.qwenlm.ai/api/chat/completions', {
|
const response = await fetch('https://chat.qwenlm.ai/api/chat/completions', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'User-Agent': 'PostmanRuntime/7.43.0',
|
'User-Agent': 'PostmanRuntime/7.43.0',
|
||||||
'accept': '*/*',
|
'accept': '*/*',
|
||||||
'authorization': `Bearer ${token}`,
|
'authorization': `Bearer ${token}`,
|
||||||
'cookie': cookie,
|
'cookie': cookie,
|
||||||
@ -305,8 +305,8 @@ async function recognizeImage(token, imageId, request) {
|
|||||||
text: advancedMode ? customPrompt : defaultPrompt,
|
text: advancedMode ? customPrompt : defaultPrompt,
|
||||||
chat_type: "t2t"
|
chat_type: "t2t"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'image',
|
type: 'image',
|
||||||
image: imageId,
|
image: imageId,
|
||||||
chat_type: "t2t"
|
chat_type: "t2t"
|
||||||
},
|
},
|
||||||
@ -1070,209 +1070,209 @@ function getHTML() {
|
|||||||
' background: rgba(255, 255, 255, 0.9);',
|
' background: rgba(255, 255, 255, 0.9);',
|
||||||
' backdrop-filter: blur(5px);',
|
' backdrop-filter: blur(5px);',
|
||||||
' z-index: 900;',
|
' z-index: 900;',
|
||||||
' display: flex;',
|
' display: flex;',
|
||||||
' justify-content: center;',
|
' justify-content: center;',
|
||||||
' align-items: center;',
|
' align-items: center;',
|
||||||
|
' }',
|
||||||
|
' .footer-content {',
|
||||||
|
' text-align: center;',
|
||||||
|
' width: 100%;',
|
||||||
' }',
|
' }',
|
||||||
' .footer-content {',
|
|
||||||
' text-align: center;',
|
|
||||||
' width: 100%;',
|
|
||||||
' }',
|
|
||||||
' .powered-by {',
|
' .powered-by {',
|
||||||
' color: #7f8c8d;',
|
' color: #7f8c8d;',
|
||||||
' font-size: 0.9rem;',
|
' font-size: 0.9rem;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .powered-by a {',
|
' .powered-by a {',
|
||||||
' color: #3498db;',
|
' color: #3498db;',
|
||||||
' text-decoration: none;',
|
' text-decoration: none;',
|
||||||
' transition: color 0.3s ease;',
|
' transition: color 0.3s ease;',
|
||||||
' font-weight: 500;',
|
' font-weight: 500;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .powered-by a:hover {',
|
' .powered-by a:hover {',
|
||||||
' color: #2980b9;',
|
' color: #2980b9;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .powered-by {',
|
' .powered-by {',
|
||||||
' color: #7f8c8d;',
|
' color: #7f8c8d;',
|
||||||
' font-size: 0.9rem;',
|
' font-size: 0.9rem;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .powered-by a {',
|
' .powered-by a {',
|
||||||
' color: #3498db;',
|
' color: #3498db;',
|
||||||
' text-decoration: none;',
|
' text-decoration: none;',
|
||||||
' transition: color 0.3s ease;',
|
' transition: color 0.3s ease;',
|
||||||
' font-weight: 500;',
|
' font-weight: 500;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .powered-by a:hover {',
|
' .powered-by a:hover {',
|
||||||
' color: #2980b9;',
|
' color: #2980b9;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' /* 输入控件组样式 */',
|
' /* 输入控件组样式 */',
|
||||||
' .input-controls {',
|
' .input-controls {',
|
||||||
' margin-top: 15px;',
|
' margin-top: 15px;',
|
||||||
' width: 100%;',
|
' width: 100%;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .button-group {',
|
' .button-group {',
|
||||||
' display: flex;',
|
' display: flex;',
|
||||||
' gap: 10px;',
|
' gap: 10px;',
|
||||||
' margin-top: 10px;',
|
' margin-top: 10px;',
|
||||||
' justify-content: center;',
|
' justify-content: center;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' #urlInput {',
|
' #urlInput {',
|
||||||
' width: 100%;',
|
' width: 100%;',
|
||||||
' padding: 10px;',
|
' padding: 10px;',
|
||||||
' border: 1px solid #dcdde1;',
|
' border: 1px solid #dcdde1;',
|
||||||
' border-radius: 8px;',
|
' border-radius: 8px;',
|
||||||
' resize: none;',
|
' resize: none;',
|
||||||
' font-size: 14px;',
|
' font-size: 14px;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .github-link {',
|
' .github-link {',
|
||||||
' position: fixed;',
|
' position: fixed;',
|
||||||
' right: 150px;',
|
' right: 150px;',
|
||||||
' top: 20px;',
|
' top: 20px;',
|
||||||
' background: #333;',
|
' background: #333;',
|
||||||
' color: white;',
|
' color: white;',
|
||||||
' border: none;',
|
' border: none;',
|
||||||
' padding: 10px;',
|
' padding: 10px;',
|
||||||
' border-radius: 50%;',
|
' border-radius: 50%;',
|
||||||
' cursor: pointer;',
|
' cursor: pointer;',
|
||||||
' z-index: 1001;',
|
' z-index: 1001;',
|
||||||
' width: 40px;',
|
' width: 40px;',
|
||||||
' height: 40px;',
|
' height: 40px;',
|
||||||
' display: flex;',
|
' display: flex;',
|
||||||
' align-items: center;',
|
' align-items: center;',
|
||||||
' justify-content: center;',
|
' justify-content: center;',
|
||||||
' transition: background 0.3s ease;',
|
' transition: background 0.3s ease;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .github-link:hover {',
|
' .github-link:hover {',
|
||||||
' background: #24292e;',
|
' background: #24292e;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .github-icon {',
|
' .github-icon {',
|
||||||
' width: 24px;',
|
' width: 24px;',
|
||||||
' height: 24px;',
|
' height: 24px;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .cookie-input-container {',
|
' .cookie-input-container {',
|
||||||
' margin-bottom: 15px;',
|
' margin-bottom: 15px;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' #cookieInput {',
|
' #cookieInput {',
|
||||||
' width: 100%;',
|
' width: 100%;',
|
||||||
' padding: 12px;',
|
' padding: 12px;',
|
||||||
' border: 2px solid #e9ecef;',
|
' border: 2px solid #e9ecef;',
|
||||||
' border-radius: 8px;',
|
' border-radius: 8px;',
|
||||||
' font-size: 0.95rem;',
|
' font-size: 0.95rem;',
|
||||||
' resize: vertical;',
|
' resize: vertical;',
|
||||||
' min-height: 120px;',
|
' min-height: 120px;',
|
||||||
' font-family: monospace;',
|
' font-family: monospace;',
|
||||||
' line-height: 1.4;',
|
' line-height: 1.4;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' #cookieInput:focus {',
|
' #cookieInput:focus {',
|
||||||
' outline: none;',
|
' outline: none;',
|
||||||
' border-color: #3498db;',
|
' border-color: #3498db;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .cookie-info {',
|
' .cookie-info {',
|
||||||
' background: #f8f9fa;',
|
' background: #f8f9fa;',
|
||||||
' padding: 12px;',
|
' padding: 12px;',
|
||||||
' border-radius: 8px;',
|
' border-radius: 8px;',
|
||||||
' margin-bottom: 15px;',
|
' margin-bottom: 15px;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .cookie-info p {',
|
' .cookie-info p {',
|
||||||
' margin: 0;',
|
' margin: 0;',
|
||||||
' color: #2c3e50;',
|
' color: #2c3e50;',
|
||||||
' font-size: 0.9rem;',
|
' font-size: 0.9rem;',
|
||||||
' margin-bottom: 8px;', // 添加底部间距
|
' margin-bottom: 8px;', // 添加底部间距
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .cookie-info p:last-child {',
|
' .cookie-info p:last-child {',
|
||||||
' margin-bottom: 0;', // 最后一个p元素不需要底部间距
|
' margin-bottom: 0;', // 最后一个p元素不需要底部间距
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .token-expiry {',
|
' .token-expiry {',
|
||||||
' color: #7f8c8d;',
|
' color: #7f8c8d;',
|
||||||
' font-size: 0.85rem;',
|
' font-size: 0.85rem;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .token-expiry.expired {',
|
' .token-expiry.expired {',
|
||||||
' color: #e74c3c;',
|
' color: #e74c3c;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' #currentTokenDisplay {',
|
' #currentTokenDisplay {',
|
||||||
' color: #3498db;',
|
' color: #3498db;',
|
||||||
' font-family: monospace;',
|
' font-family: monospace;',
|
||||||
' word-break: break-all;',
|
' word-break: break-all;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
// 添加获取cookie按钮样式
|
// 添加获取cookie按钮样式
|
||||||
' .get-cookie-link {',
|
' .get-cookie-link {',
|
||||||
' position: fixed;',
|
' position: fixed;',
|
||||||
' left: 150px;', // 放在github图标左边
|
' left: 150px;', // 放在github图标左边
|
||||||
' top: 22px;',
|
' top: 22px;',
|
||||||
' background: #2ecc71;', // 使用不同的颜色区分
|
' background: #2ecc71;', // 使用不同的颜色区分
|
||||||
' color: white;',
|
' color: white;',
|
||||||
' border: none;',
|
' border: none;',
|
||||||
' padding: 8px 15px;',
|
' padding: 8px 15px;',
|
||||||
' border-radius: 5px;',
|
' border-radius: 5px;',
|
||||||
' cursor: pointer;',
|
' cursor: pointer;',
|
||||||
' z-index: 1001;',
|
' z-index: 1001;',
|
||||||
' text-decoration: none;',
|
' text-decoration: none;',
|
||||||
' font-size: 14px;',
|
' font-size: 14px;',
|
||||||
' transition: background 0.3s ease;',
|
' transition: background 0.3s ease;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .get-cookie-link:hover {',
|
' .get-cookie-link:hover {',
|
||||||
' background: #27ae60;',
|
' background: #27ae60;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .advanced-mode-toggle {',
|
' .advanced-mode-toggle {',
|
||||||
' display: flex;',
|
' display: flex;',
|
||||||
' align-items: center;',
|
' align-items: center;',
|
||||||
' margin-bottom: 15px;',
|
' margin-bottom: 15px;',
|
||||||
' padding: 10px;',
|
' padding: 10px;',
|
||||||
' background: #f8f9fa;',
|
' background: #f8f9fa;',
|
||||||
' border-radius: 8px;',
|
' border-radius: 8px;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .advanced-mode-toggle input[type="checkbox"] {',
|
' .advanced-mode-toggle input[type="checkbox"] {',
|
||||||
' margin-right: 10px;',
|
' margin-right: 10px;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .prompt-container {',
|
' .prompt-container {',
|
||||||
' display: none;', // 默认隐藏
|
' display: none;', // 默认隐藏
|
||||||
' margin-bottom: 15px;',
|
' margin-bottom: 15px;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' .prompt-container.show {',
|
' .prompt-container.show {',
|
||||||
' display: block;',
|
' display: block;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' #promptInput {',
|
' #promptInput {',
|
||||||
' width: 100%;',
|
' width: 100%;',
|
||||||
' padding: 12px;',
|
' padding: 12px;',
|
||||||
' border: 2px solid #e9ecef;',
|
' border: 2px solid #e9ecef;',
|
||||||
' border-radius: 8px;',
|
' border-radius: 8px;',
|
||||||
' font-size: 0.95rem;',
|
' font-size: 0.95rem;',
|
||||||
' resize: vertical;',
|
' resize: vertical;',
|
||||||
' min-height: 120px;',
|
' min-height: 120px;',
|
||||||
' font-family: monospace;',
|
' font-family: monospace;',
|
||||||
' line-height: 1.4;',
|
' line-height: 1.4;',
|
||||||
' }',
|
' }',
|
||||||
|
|
||||||
' #promptInput:focus {',
|
' #promptInput:focus {',
|
||||||
' outline: none;',
|
' outline: none;',
|
||||||
' border-color: #3498db;',
|
' border-color: #3498db;',
|
||||||
' }',
|
' }',
|
||||||
'</style>',
|
'</style>',
|
||||||
'</head>',
|
'</head>',
|
||||||
'<body>',
|
'<body>',
|
||||||
@ -1510,7 +1510,7 @@ function getHTML() {
|
|||||||
' historyManager.displayHistory(currentToken);',
|
' historyManager.displayHistory(currentToken);',
|
||||||
' });',
|
' });',
|
||||||
' tokenList.appendChild(div);',
|
' tokenList.appendChild(div);',
|
||||||
' });',
|
' });',
|
||||||
' const tokenInput = document.getElementById(\'tokenInput\');',
|
' const tokenInput = document.getElementById(\'tokenInput\');',
|
||||||
' if (tokenInput) {',
|
' if (tokenInput) {',
|
||||||
' tokenInput.value = tokens.join(",");',
|
' tokenInput.value = tokens.join(",");',
|
||||||
@ -1849,12 +1849,12 @@ function getHTML() {
|
|||||||
' await navigator.clipboard.writeText(result);',
|
' await navigator.clipboard.writeText(result);',
|
||||||
' btn.textContent = \'已复制\';',
|
' btn.textContent = \'已复制\';',
|
||||||
' btn.classList.add(\'copied\');',
|
' btn.classList.add(\'copied\');',
|
||||||
|
|
||||||
' setTimeout(() => {',
|
' setTimeout(() => {',
|
||||||
' btn.textContent = \'复制结果\';',
|
' btn.textContent = \'复制结果\';',
|
||||||
' btn.classList.remove(\'copied\');',
|
' btn.classList.remove(\'copied\');',
|
||||||
' }, 2000);',
|
' }, 2000);',
|
||||||
|
|
||||||
' return true;',
|
' return true;',
|
||||||
' } catch (err) {',
|
' } catch (err) {',
|
||||||
' console.error(\'复制失败:\', err);',
|
' console.error(\'复制失败:\', err);',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user