import { Inject, Provide } from '@midwayjs/decorator';
import { BaseService } from '@cool-midway/core';
import { KnowUnstructuredLoader } from '../loader/unstructured';
import { KnowCheerioLoader } from '../loader/cheerio';

/**
 * 非结构化文档加载器
 */
@Provide()
export class KnowLoaderService extends BaseService {
  @Inject()
  knowUnstructuredLoader: KnowUnstructuredLoader;

  @Inject()
  knowCheerioLoader: KnowCheerioLoader;

  /**
   * 加载文件
   * @param filePath
   */
  async loadFile(filePath: string) {
    return await this.knowUnstructuredLoader.loadFile(filePath);
  }

  /**
   * 加载链接
   * @param link
   * @returns
   */
  async loadLink(link: string) {
    return await this.knowCheerioLoader.loadLink(link);
  }
}
