Removed ai image analyzer
This commit is contained in:
		
							parent
							
								
									5d50f9cb82
								
							
						
					
					
						commit
						b460f1bee5
					
				| 
						 | 
					@ -223,14 +223,6 @@ export default class LocatorPlugin extends Plugin {
 | 
				
			||||||
    return (this.app as any).plugins?.plugins?.['text-extractor']?.api
 | 
					    return (this.app as any).plugins?.plugins?.['text-extractor']?.api
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					 | 
				
			||||||
   * Plugin dependency - Ai Image Analyzer
 | 
					 | 
				
			||||||
   * @returns
 | 
					 | 
				
			||||||
   */
 | 
					 | 
				
			||||||
  public getAIImageAnalyzer(): AIImageAnalyzerAPI | undefined {
 | 
					 | 
				
			||||||
    return (this.app as any).plugins?.plugins?.['ai-image-analyzer']?.api
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  private async populateIndex(): Promise<void> {
 | 
					  private async populateIndex(): Promise<void> {
 | 
				
			||||||
    console.time('Indexing total time')
 | 
					    console.time('Indexing total time')
 | 
				
			||||||
    indexingStep.set(IndexingStepType.ReadingFiles)
 | 
					    indexingStep.set(IndexingStepType.ReadingFiles)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
import type { TAbstractFile } from 'obsidian'
 | 
					import type { TAbstractFile } from 'obsidian'
 | 
				
			||||||
 | 
					import type { IndexedDocument } from './globals'
 | 
				
			||||||
import type LocatorPlugin from './main'
 | 
					import type LocatorPlugin from './main'
 | 
				
			||||||
import { removeAnchors } from './tools/notes'
 | 
					import { removeAnchors } from './tools/notes'
 | 
				
			||||||
import type { IndexedDocument } from './globals'
 | 
					 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  isFileCanvas,
 | 
					  isFileCanvas,
 | 
				
			||||||
  isFileFromDataloom,
 | 
					  isFileFromDataloom,
 | 
				
			||||||
| 
						 | 
					@ -44,17 +44,14 @@ export class NotesIndexer {
 | 
				
			||||||
  public isContentIndexable(path: string): boolean {
 | 
					  public isContentIndexable(path: string): boolean {
 | 
				
			||||||
    const settings = this.plugin.settings
 | 
					    const settings = this.plugin.settings
 | 
				
			||||||
    const hasTextExtractor = !!this.plugin.getTextExtractor()
 | 
					    const hasTextExtractor = !!this.plugin.getTextExtractor()
 | 
				
			||||||
    const hasAIImageAnalyzer = !!this.plugin.getAIImageAnalyzer()
 | 
					 | 
				
			||||||
    const canIndexPDF = hasTextExtractor && settings.PDFIndexing
 | 
					    const canIndexPDF = hasTextExtractor && settings.PDFIndexing
 | 
				
			||||||
    const canIndexImages = hasTextExtractor && settings.imagesIndexing
 | 
					    const canIndexImages = hasTextExtractor && settings.imagesIndexing
 | 
				
			||||||
    const canIndexImagesAI = hasAIImageAnalyzer && settings.aiImageIndexing
 | 
					 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
      this.isFilePlaintext(path) ||
 | 
					      this.isFilePlaintext(path) ||
 | 
				
			||||||
      isFileCanvas(path) ||
 | 
					      isFileCanvas(path) ||
 | 
				
			||||||
      isFileFromDataloom(path) ||
 | 
					      isFileFromDataloom(path) ||
 | 
				
			||||||
      (canIndexPDF && isFilePDF(path)) ||
 | 
					      (canIndexPDF && isFilePDF(path)) ||
 | 
				
			||||||
      (canIndexImages && isFileImage(path)) ||
 | 
					      (canIndexImages && isFileImage(path))
 | 
				
			||||||
      (canIndexImagesAI && isFileImage(path))
 | 
					 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,8 @@
 | 
				
			||||||
import { normalizePath, Notice, TFile } from 'obsidian'
 | 
					import { normalizePath, TFile } from 'obsidian'
 | 
				
			||||||
 | 
					import type { CanvasData } from 'obsidian/canvas'
 | 
				
			||||||
import type { IndexedDocument } from '../globals'
 | 
					import type { IndexedDocument } from '../globals'
 | 
				
			||||||
 | 
					import type LocatorPlugin from '../main'
 | 
				
			||||||
 | 
					import { getNonExistingNotes } from '../tools/notes'
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  countError,
 | 
					  countError,
 | 
				
			||||||
  extractHeadingsFromCache,
 | 
					  extractHeadingsFromCache,
 | 
				
			||||||
| 
						 | 
					@ -14,9 +17,6 @@ import {
 | 
				
			||||||
  removeDiacritics,
 | 
					  removeDiacritics,
 | 
				
			||||||
  stripMarkdownCharacters,
 | 
					  stripMarkdownCharacters,
 | 
				
			||||||
} from '../tools/utils'
 | 
					} from '../tools/utils'
 | 
				
			||||||
import type { CanvasData } from 'obsidian/canvas'
 | 
					 | 
				
			||||||
import type LocatorPlugin from '../main'
 | 
					 | 
				
			||||||
import { getNonExistingNotes } from '../tools/notes'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class DocumentsRepository {
 | 
					export class DocumentsRepository {
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
| 
						 | 
					@ -96,7 +96,6 @@ export class DocumentsRepository {
 | 
				
			||||||
    let content: string | null = null
 | 
					    let content: string | null = null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const extractor = this.plugin.getTextExtractor()
 | 
					    const extractor = this.plugin.getTextExtractor()
 | 
				
			||||||
    const aiImageAnalyzer = this.plugin.getAIImageAnalyzer()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // ** Plain text **
 | 
					    // ** Plain text **
 | 
				
			||||||
    // Just read the file content
 | 
					    // Just read the file content
 | 
				
			||||||
| 
						 | 
					@ -151,10 +150,8 @@ export class DocumentsRepository {
 | 
				
			||||||
    // ** Image **
 | 
					    // ** Image **
 | 
				
			||||||
    else if (
 | 
					    else if (
 | 
				
			||||||
      isFileImage(path) &&
 | 
					      isFileImage(path) &&
 | 
				
			||||||
      ((this.plugin.settings.imagesIndexing &&
 | 
					      (this.plugin.settings.imagesIndexing &&
 | 
				
			||||||
        extractor?.canFileBeExtracted(path)) ||
 | 
					        extractor?.canFileBeExtracted(path))
 | 
				
			||||||
        (this.plugin.settings.aiImageIndexing &&
 | 
					 | 
				
			||||||
          aiImageAnalyzer?.canBeAnalyzed(file)))
 | 
					 | 
				
			||||||
    ) {
 | 
					    ) {
 | 
				
			||||||
      if (
 | 
					      if (
 | 
				
			||||||
        this.plugin.settings.imagesIndexing &&
 | 
					        this.plugin.settings.imagesIndexing &&
 | 
				
			||||||
| 
						 | 
					@ -162,13 +159,6 @@ export class DocumentsRepository {
 | 
				
			||||||
      ) {
 | 
					      ) {
 | 
				
			||||||
        content = await extractor.extractText(file)
 | 
					        content = await extractor.extractText(file)
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (
 | 
					 | 
				
			||||||
        this.plugin.settings.aiImageIndexing &&
 | 
					 | 
				
			||||||
        aiImageAnalyzer?.canBeAnalyzed(file)
 | 
					 | 
				
			||||||
      ) {
 | 
					 | 
				
			||||||
        content = (await aiImageAnalyzer.analyzeImage(file)) + (content ?? '')
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // ** PDF **
 | 
					    // ** PDF **
 | 
				
			||||||
    else if (
 | 
					    else if (
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,7 +94,6 @@ export function getDefaultSettings(app: App): LocatorSettings {
 | 
				
			||||||
    PDFIndexing: false,
 | 
					    PDFIndexing: false,
 | 
				
			||||||
    officeIndexing: false,
 | 
					    officeIndexing: false,
 | 
				
			||||||
    imagesIndexing: false,
 | 
					    imagesIndexing: false,
 | 
				
			||||||
    aiImageIndexing: false,
 | 
					 | 
				
			||||||
    unsupportedFilesIndexing: 'default',
 | 
					    unsupportedFilesIndexing: 'default',
 | 
				
			||||||
    splitCamelCase: false,
 | 
					    splitCamelCase: false,
 | 
				
			||||||
    openInNewPane: false,
 | 
					    openInNewPane: false,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,6 @@ export function injectSettingsIndexing(
 | 
				
			||||||
  containerEl: HTMLElement
 | 
					  containerEl: HTMLElement
 | 
				
			||||||
) {
 | 
					) {
 | 
				
			||||||
  const textExtractor = plugin.getTextExtractor()
 | 
					  const textExtractor = plugin.getTextExtractor()
 | 
				
			||||||
  const aiImageAnalyzer = plugin.getAIImageAnalyzer()
 | 
					 | 
				
			||||||
  const database = plugin.database
 | 
					  const database = plugin.database
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const clearCacheDebounced = debounce(async () => {
 | 
					  const clearCacheDebounced = debounce(async () => {
 | 
				
			||||||
| 
						 | 
					@ -28,11 +27,6 @@ export function injectSettingsIndexing(
 | 
				
			||||||
            ? `👍 You have installed <a href="https://github.com/scambier/obsidian-text-extractor">Text Extractor</a>, Locator can use it to index PDFs and images contents.
 | 
					            ? `👍 You have installed <a href="https://github.com/scambier/obsidian-text-extractor">Text Extractor</a>, Locator can use it to index PDFs and images contents.
 | 
				
			||||||
            <br />Text extraction only works on desktop, but the cache can be synchronized with your mobile device.`
 | 
					            <br />Text extraction only works on desktop, but the cache can be synchronized with your mobile device.`
 | 
				
			||||||
            : `⚠️ Locator requires <a href="https://github.com/scambier/obsidian-text-extractor">Text Extractor</a> to index PDFs and images.`
 | 
					            : `⚠️ Locator requires <a href="https://github.com/scambier/obsidian-text-extractor">Text Extractor</a> to index PDFs and images.`
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        ${
 | 
					 | 
				
			||||||
          aiImageAnalyzer
 | 
					 | 
				
			||||||
            ? `<br/>👍 You have installed <a href="https://github.com/Swaggeroo/obsidian-ai-image-analyzer">AI Image Analyzer</a>, Locator can use it to index images contents with ai.`
 | 
					 | 
				
			||||||
            : `<br/>⚠️ Locator requires <a href="https://github.com/Swaggeroo/obsidian-ai-image-analyzer">AI Image Analyzer</a> to index images with ai.`
 | 
					 | 
				
			||||||
        }`)
 | 
					        }`)
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -87,23 +81,6 @@ export function injectSettingsIndexing(
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
    .setDisabled(!textExtractor)
 | 
					    .setDisabled(!textExtractor)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // AI Images Indexing
 | 
					 | 
				
			||||||
  const aiIndexImagesDesc = new DocumentFragment()
 | 
					 | 
				
			||||||
  aiIndexImagesDesc.createSpan({}, span => {
 | 
					 | 
				
			||||||
    span.innerHTML = `Locator will use AI Image Analyzer to index the content of your images with ai.`
 | 
					 | 
				
			||||||
  })
 | 
					 | 
				
			||||||
  new Setting(containerEl)
 | 
					 | 
				
			||||||
    .setName(`Images AI indexing ${aiImageAnalyzer ? '' : '⚠️ Disabled'}`)
 | 
					 | 
				
			||||||
    .setDesc(aiIndexImagesDesc)
 | 
					 | 
				
			||||||
    .addToggle(toggle =>
 | 
					 | 
				
			||||||
      toggle.setValue(settings.aiImageIndexing).onChange(async v => {
 | 
					 | 
				
			||||||
        await database.clearCache()
 | 
					 | 
				
			||||||
        settings.aiImageIndexing = v
 | 
					 | 
				
			||||||
        await saveSettings(plugin)
 | 
					 | 
				
			||||||
      })
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
    .setDisabled(!aiImageAnalyzer)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Index filenames of unsupported files
 | 
					  // Index filenames of unsupported files
 | 
				
			||||||
  new Setting(containerEl)
 | 
					  new Setting(containerEl)
 | 
				
			||||||
    .setName('Index paths of unsupported files')
 | 
					    .setName('Index paths of unsupported files')
 | 
				
			||||||
| 
						 | 
					@ -115,7 +92,7 @@ export function injectSettingsIndexing(
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
    .addDropdown(dropdown => {
 | 
					    .addDropdown(dropdown => {
 | 
				
			||||||
      dropdown
 | 
					      dropdown
 | 
				
			||||||
        .addOptions({ yes: 'Yes', no: 'No', default: 'Obsidian setting' })
 | 
					        .addOptions({ yes: 'Yes', no: 'No', default: 'Obsidian default' })
 | 
				
			||||||
        .setValue(settings.unsupportedFilesIndexing)
 | 
					        .setValue(settings.unsupportedFilesIndexing)
 | 
				
			||||||
        .onChange(async v => {
 | 
					        .onChange(async v => {
 | 
				
			||||||
          await clearCacheDebounced()
 | 
					          await clearCacheDebounced()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,9 +49,7 @@ export interface LocatorSettings extends WeightingSettings {
 | 
				
			||||||
  imagesIndexing: boolean
 | 
					  imagesIndexing: boolean
 | 
				
			||||||
  /** Enable Office documents indexing */
 | 
					  /** Enable Office documents indexing */
 | 
				
			||||||
  officeIndexing: boolean
 | 
					  officeIndexing: boolean
 | 
				
			||||||
  /** Enable image ai indexing */
 | 
					  
 | 
				
			||||||
  aiImageIndexing: boolean
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /** Enable indexing of unknown files */
 | 
					  /** Enable indexing of unknown files */
 | 
				
			||||||
  unsupportedFilesIndexing: 'yes' | 'no' | 'default'
 | 
					  unsupportedFilesIndexing: 'yes' | 'no' | 'default'
 | 
				
			||||||
  /** Activate the small 🔍 button on Obsidian's ribbon */
 | 
					  /** Activate the small 🔍 button on Obsidian's ribbon */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user