0.0.8 • Published 2 months ago

@maogo/rag-file v0.0.8

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

调试相关的代码

config:

// config.default.ts
import { MidwayConfig } from '@midwayjs/core';
import { uploadWhiteList } from '@midwayjs/upload';

export default {
  // use for cookie sign key, should change to your own and keep security
  keys: '1710008275436_4273',
  koa: {
    port: 7001,
  },
  upload: {
    mode: 'stream',
    whitelist: uploadWhiteList.concat(['.txt', '.log']),
  },
} as MidwayConfig;

// configuration.ts
import * as maogoUpload from '@maogo/upload';
import * as upload from '@midwayjs/upload';

imports: [
  // ...
  upload,
  maogoUpload,
]
// ...

controller:

import { Controller, Get, Query, Inject, Post, Files, Fields } from '@midwayjs/core';
import { Context } from '@midwayjs/koa';
import { UploadService as MaogoUploadService } from '@maogo/upload';

@Controller('/')
export class HomeController {
  @Inject()
  ctx: Context;

  @Inject()
  maogoUploadService: MaogoUploadService;

  @Get('/text')
  async text(@Query('text') text: string): Promise<any> {
    console.log('----------- 收到请求 ----------');
    const result = await this.maogoUploadService.textSplit(text, {chunkSize: 10, chunkOverlap: 1});
    console.log('text result: ', result);

    return result;
  }

  @Post('/upload')
  async upload(@Files() files, @Fields() fields): Promise<any> {
    console.log({files, fields});
    return await this.maogoUploadService.fileSplitAndUpload(files[0].data, files[0].filename);
  }
}

调用

  • /upload 上传文本文件,form-data,key 为 file,value 选择文件,返回 cosLink 为腾讯云存储的存储地址。
  • /text 直接使用文本,目前还没存储为文件。
0.0.8

2 months ago

0.0.7

2 months ago

0.0.6

2 months ago

0.0.5

2 months ago

0.0.4

2 months ago

0.0.3

2 months ago

0.0.2

2 months ago

0.0.1

2 months ago