refac/fix: mineru params
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda126-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda126-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-slim-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-slim-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda126-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-slim-images (push) Blocked by required conditions
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run

This commit is contained in:
Timothy Jaeryang Baek 2025-11-05 14:43:25 -05:00
parent cdf90222c7
commit 6c583ef9d3
2 changed files with 29 additions and 18 deletions

View file

@ -212,6 +212,15 @@
await embeddingModelUpdateHandler(); await embeddingModelUpdateHandler();
} }
if (RAGConfig.MINERU_PARAMS) {
try {
JSON.parse(RAGConfig.MINERU_PARAMS);
} catch (e) {
toast.error($i18n.t('Invalid JSON format in MinerU Parameters'));
return;
}
}
const res = await updateRAGConfig(localStorage.token, { const res = await updateRAGConfig(localStorage.token, {
...RAGConfig, ...RAGConfig,
ALLOWED_FILE_EXTENSIONS: RAGConfig.ALLOWED_FILE_EXTENSIONS.split(',') ALLOWED_FILE_EXTENSIONS: RAGConfig.ALLOWED_FILE_EXTENSIONS.split(',')
@ -220,7 +229,13 @@
DOCLING_PICTURE_DESCRIPTION_LOCAL: JSON.parse( DOCLING_PICTURE_DESCRIPTION_LOCAL: JSON.parse(
RAGConfig.DOCLING_PICTURE_DESCRIPTION_LOCAL || '{}' RAGConfig.DOCLING_PICTURE_DESCRIPTION_LOCAL || '{}'
), ),
DOCLING_PICTURE_DESCRIPTION_API: JSON.parse(RAGConfig.DOCLING_PICTURE_DESCRIPTION_API || '{}') DOCLING_PICTURE_DESCRIPTION_API: JSON.parse(
RAGConfig.DOCLING_PICTURE_DESCRIPTION_API || '{}'
),
MINERU_PARAMS:
typeof RAGConfig.MINERU_PARAMS === 'string' && RAGConfig.MINERU_PARAMS.trim() !== ''
? JSON.parse(RAGConfig.MINERU_PARAMS)
: {}
}); });
dispatch('save'); dispatch('save');
}; };
@ -261,6 +276,11 @@
2 2
); );
config.MINERU_PARAMS =
typeof config.MINERU_PARAMS === 'object'
? JSON.stringify(config.MINERU_PARAMS ?? {}, null, 2)
: config.MINERU_PARAMS;
RAGConfig = config; RAGConfig = config;
}); });
</script> </script>
@ -802,8 +822,8 @@
</div> </div>
<!-- Parameters --> <!-- Parameters -->
<div class="flex justify-between w-full mt-2"> <div class="flex flex-col justify-between w-full mt-2">
<div class="self-center text-xs font-medium"> <div class="text-xs font-medium">
<Tooltip <Tooltip
content={$i18n.t( content={$i18n.t(
'Advanced parameters for MinerU parsing (enable_ocr, enable_formula, enable_table, language, model_version, page_ranges)' 'Advanced parameters for MinerU parsing (enable_ocr, enable_formula, enable_table, language, model_version, page_ranges)'
@ -813,22 +833,9 @@
{$i18n.t('Parameters')} {$i18n.t('Parameters')}
</Tooltip> </Tooltip>
</div> </div>
<div class=""> <div class="mt-1.5">
<Textarea <Textarea
value={typeof RAGConfig.MINERU_PARAMS === 'object' && bind:value={RAGConfig.MINERU_PARAMS}
RAGConfig.MINERU_PARAMS !== null &&
Object.keys(RAGConfig.MINERU_PARAMS).length > 0
? JSON.stringify(RAGConfig.MINERU_PARAMS, null, 2)
: ''}
on:input={(e) => {
try {
const value = e.target.value.trim();
RAGConfig.MINERU_PARAMS = value ? JSON.parse(value) : {};
} catch (err) {
// Keep the string value if JSON is invalid (user is still typing)
RAGConfig.MINERU_PARAMS = e.target.value;
}
}}
placeholder={`{\n "enable_ocr": false,\n "enable_formula": true,\n "enable_table": true,\n "language": "en",\n "model_version": "pipeline",\n "page_ranges": ""\n}`} placeholder={`{\n "enable_ocr": false,\n "enable_formula": true,\n "enable_table": true,\n "language": "en",\n "model_version": "pipeline",\n "page_ranges": ""\n}`}
minSize={100} minSize={100}
/> />

View file

@ -11,7 +11,9 @@
export let className = export let className =
'w-full rounded-lg px-3.5 py-2 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-hidden h-full'; 'w-full rounded-lg px-3.5 py-2 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-hidden h-full';
export let onInput = () => {};
export let onBlur = () => {}; export let onBlur = () => {};
let textareaElement; let textareaElement;
// Adjust height on mount and after setting the element. // Adjust height on mount and after setting the element.
@ -58,6 +60,8 @@
{readonly} {readonly}
on:input={(e) => { on:input={(e) => {
resize(); resize();
onInput(e);
}} }}
on:focus={() => { on:focus={() => {
resize(); resize();