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
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * 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> {
 | 
			
		||||
    console.time('Indexing total time')
 | 
			
		||||
    indexingStep.set(IndexingStepType.ReadingFiles)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
import type { TAbstractFile } from 'obsidian'
 | 
			
		||||
import type { IndexedDocument } from './globals'
 | 
			
		||||
import type LocatorPlugin from './main'
 | 
			
		||||
import { removeAnchors } from './tools/notes'
 | 
			
		||||
import type { IndexedDocument } from './globals'
 | 
			
		||||
import {
 | 
			
		||||
  isFileCanvas,
 | 
			
		||||
  isFileFromDataloom,
 | 
			
		||||
| 
						 | 
				
			
			@ -44,17 +44,14 @@ export class NotesIndexer {
 | 
			
		|||
  public isContentIndexable(path: string): boolean {
 | 
			
		||||
    const settings = this.plugin.settings
 | 
			
		||||
    const hasTextExtractor = !!this.plugin.getTextExtractor()
 | 
			
		||||
    const hasAIImageAnalyzer = !!this.plugin.getAIImageAnalyzer()
 | 
			
		||||
    const canIndexPDF = hasTextExtractor && settings.PDFIndexing
 | 
			
		||||
    const canIndexImages = hasTextExtractor && settings.imagesIndexing
 | 
			
		||||
    const canIndexImagesAI = hasAIImageAnalyzer && settings.aiImageIndexing
 | 
			
		||||
    return (
 | 
			
		||||
      this.isFilePlaintext(path) ||
 | 
			
		||||
      isFileCanvas(path) ||
 | 
			
		||||
      isFileFromDataloom(path) ||
 | 
			
		||||
      (canIndexPDF && isFilePDF(path)) ||
 | 
			
		||||
      (canIndexImages && isFileImage(path)) ||
 | 
			
		||||
      (canIndexImagesAI && isFileImage(path))
 | 
			
		||||
      (canIndexImages && 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 LocatorPlugin from '../main'
 | 
			
		||||
import { getNonExistingNotes } from '../tools/notes'
 | 
			
		||||
import {
 | 
			
		||||
  countError,
 | 
			
		||||
  extractHeadingsFromCache,
 | 
			
		||||
| 
						 | 
				
			
			@ -14,9 +17,6 @@ import {
 | 
			
		|||
  removeDiacritics,
 | 
			
		||||
  stripMarkdownCharacters,
 | 
			
		||||
} from '../tools/utils'
 | 
			
		||||
import type { CanvasData } from 'obsidian/canvas'
 | 
			
		||||
import type LocatorPlugin from '../main'
 | 
			
		||||
import { getNonExistingNotes } from '../tools/notes'
 | 
			
		||||
 | 
			
		||||
export class DocumentsRepository {
 | 
			
		||||
  /**
 | 
			
		||||
| 
						 | 
				
			
			@ -96,7 +96,6 @@ export class DocumentsRepository {
 | 
			
		|||
    let content: string | null = null
 | 
			
		||||
 | 
			
		||||
    const extractor = this.plugin.getTextExtractor()
 | 
			
		||||
    const aiImageAnalyzer = this.plugin.getAIImageAnalyzer()
 | 
			
		||||
 | 
			
		||||
    // ** Plain text **
 | 
			
		||||
    // Just read the file content
 | 
			
		||||
| 
						 | 
				
			
			@ -151,10 +150,8 @@ export class DocumentsRepository {
 | 
			
		|||
    // ** Image **
 | 
			
		||||
    else if (
 | 
			
		||||
      isFileImage(path) &&
 | 
			
		||||
      ((this.plugin.settings.imagesIndexing &&
 | 
			
		||||
        extractor?.canFileBeExtracted(path)) ||
 | 
			
		||||
        (this.plugin.settings.aiImageIndexing &&
 | 
			
		||||
          aiImageAnalyzer?.canBeAnalyzed(file)))
 | 
			
		||||
      (this.plugin.settings.imagesIndexing &&
 | 
			
		||||
        extractor?.canFileBeExtracted(path))
 | 
			
		||||
    ) {
 | 
			
		||||
      if (
 | 
			
		||||
        this.plugin.settings.imagesIndexing &&
 | 
			
		||||
| 
						 | 
				
			
			@ -162,13 +159,6 @@ export class DocumentsRepository {
 | 
			
		|||
      ) {
 | 
			
		||||
        content = await extractor.extractText(file)
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (
 | 
			
		||||
        this.plugin.settings.aiImageIndexing &&
 | 
			
		||||
        aiImageAnalyzer?.canBeAnalyzed(file)
 | 
			
		||||
      ) {
 | 
			
		||||
        content = (await aiImageAnalyzer.analyzeImage(file)) + (content ?? '')
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    // ** PDF **
 | 
			
		||||
    else if (
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -94,7 +94,6 @@ export function getDefaultSettings(app: App): LocatorSettings {
 | 
			
		|||
    PDFIndexing: false,
 | 
			
		||||
    officeIndexing: false,
 | 
			
		||||
    imagesIndexing: false,
 | 
			
		||||
    aiImageIndexing: false,
 | 
			
		||||
    unsupportedFilesIndexing: 'default',
 | 
			
		||||
    splitCamelCase: false,
 | 
			
		||||
    openInNewPane: false,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,6 @@ export function injectSettingsIndexing(
 | 
			
		|||
  containerEl: HTMLElement
 | 
			
		||||
) {
 | 
			
		||||
  const textExtractor = plugin.getTextExtractor()
 | 
			
		||||
  const aiImageAnalyzer = plugin.getAIImageAnalyzer()
 | 
			
		||||
  const database = plugin.database
 | 
			
		||||
 | 
			
		||||
  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.
 | 
			
		||||
            <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.`
 | 
			
		||||
        }
 | 
			
		||||
        ${
 | 
			
		||||
          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)
 | 
			
		||||
 | 
			
		||||
  // 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
 | 
			
		||||
  new Setting(containerEl)
 | 
			
		||||
    .setName('Index paths of unsupported files')
 | 
			
		||||
| 
						 | 
				
			
			@ -115,7 +92,7 @@ export function injectSettingsIndexing(
 | 
			
		|||
    )
 | 
			
		||||
    .addDropdown(dropdown => {
 | 
			
		||||
      dropdown
 | 
			
		||||
        .addOptions({ yes: 'Yes', no: 'No', default: 'Obsidian setting' })
 | 
			
		||||
        .addOptions({ yes: 'Yes', no: 'No', default: 'Obsidian default' })
 | 
			
		||||
        .setValue(settings.unsupportedFilesIndexing)
 | 
			
		||||
        .onChange(async v => {
 | 
			
		||||
          await clearCacheDebounced()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,9 +49,7 @@ export interface LocatorSettings extends WeightingSettings {
 | 
			
		|||
  imagesIndexing: boolean
 | 
			
		||||
  /** Enable Office documents indexing */
 | 
			
		||||
  officeIndexing: boolean
 | 
			
		||||
  /** Enable image ai indexing */
 | 
			
		||||
  aiImageIndexing: boolean
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
  /** Enable indexing of unknown files */
 | 
			
		||||
  unsupportedFilesIndexing: 'yes' | 'no' | 'default'
 | 
			
		||||
  /** Activate the small 🔍 button on Obsidian's ribbon */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user