#477 Use Text Extractor as a fallback to AI Image Analyzer
This commit is contained in:
@@ -218,7 +218,7 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
public getChsSegmenter(): any | undefined {
|
public getChsSegmenter(): any | undefined {
|
||||||
return (this.app as any).plugins.plugins['cm-chs-patch']
|
return (this.app as any).plugins?.plugins?.['cm-chs-patch']
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -149,25 +149,21 @@ export class DocumentsRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ** Image **
|
// ** Image **
|
||||||
else if (
|
else if (isFileImage(path)) {
|
||||||
isFileImage(path) &&
|
// AI Image Analyzer
|
||||||
((this.plugin.settings.imagesIndexing &&
|
|
||||||
extractor?.canFileBeExtracted(path)) ||
|
|
||||||
(this.plugin.settings.aiImageIndexing &&
|
|
||||||
aiImageAnalyzer?.canBeAnalyzed(file)))
|
|
||||||
) {
|
|
||||||
if (
|
|
||||||
this.plugin.settings.imagesIndexing &&
|
|
||||||
extractor?.canFileBeExtracted(path)
|
|
||||||
) {
|
|
||||||
content = await extractor.extractText(file)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.plugin.settings.aiImageIndexing &&
|
this.plugin.settings.aiImageIndexing &&
|
||||||
aiImageAnalyzer?.canBeAnalyzed(file)
|
aiImageAnalyzer?.canBeAnalyzed(file)
|
||||||
) {
|
) {
|
||||||
content = (await aiImageAnalyzer.analyzeImage(file)) + (content ?? '')
|
content = await aiImageAnalyzer.analyzeImage(file)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Text Extractor
|
||||||
|
else if (
|
||||||
|
this.plugin.settings.imagesIndexing &&
|
||||||
|
extractor?.canFileBeExtracted(path)
|
||||||
|
) {
|
||||||
|
content = await extractor.extractText(file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ** PDF **
|
// ** PDF **
|
||||||
@@ -256,6 +252,4 @@ export class DocumentsRepository {
|
|||||||
: '',
|
: '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ export function injectSettingsIndexing(
|
|||||||
// AI Images Indexing
|
// AI Images Indexing
|
||||||
const aiIndexImagesDesc = new DocumentFragment()
|
const aiIndexImagesDesc = new DocumentFragment()
|
||||||
aiIndexImagesDesc.createSpan({}, span => {
|
aiIndexImagesDesc.createSpan({}, span => {
|
||||||
span.innerHTML = `Omnisearch will use AI Image Analyzer to index the content of your images with ai.`
|
span.innerHTML = `Omnisearch will use AI Image Analyzer to index the content of your images with ai.<br/>
|
||||||
|
⚠️ <span style="color: var(--text-accent)">If both AI Image Analyzer and Text Extractor are enabled, Text Extractor will only be used as a fallback.</span>`
|
||||||
})
|
})
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName(`Images AI indexing ${aiImageAnalyzer ? '' : '⚠️ Disabled'}`)
|
.setName(`Images AI indexing ${aiImageAnalyzer ? '' : '⚠️ Disabled'}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user