Daniel Marques commited on
Commit
f2fde57
1 Parent(s): 03a8594

feat: add dele folder

Browse files
Files changed (2) hide show
  1. constants.py +1 -0
  2. main.py +15 -6
constants.py CHANGED
@@ -41,6 +41,7 @@ N_BATCH = 1024
41
  # N_BATCH = 512
42
 
43
 
 
44
  # https://python.langchain.com/en/latest/_modules/langchain/document_loaders/excel.html#UnstructuredExcelLoader
45
  DOCUMENT_MAP = {
46
  ".txt": TextLoader,
 
41
  # N_BATCH = 512
42
 
43
 
44
+
45
  # https://python.langchain.com/en/latest/_modules/langchain/document_loaders/excel.html#UnstructuredExcelLoader
46
  DOCUMENT_MAP = {
47
  ".txt": TextLoader,
main.py CHANGED
@@ -3,15 +3,12 @@ from fastapi.staticfiles import StaticFiles
3
 
4
 
5
  from pydantic import BaseModel
6
- import pickle
7
- import uvicorn
8
-
9
- import logging
10
  import os
11
  import shutil
12
  import subprocess
 
13
 
14
- import torch
15
  from langchain.chains import RetrievalQA
16
  from langchain.embeddings import HuggingFaceInstructEmbeddings
17
  from langchain.prompts import PromptTemplate
@@ -188,7 +185,19 @@ async def create_upload_file(file: UploadFile):
188
 
189
  # check the content type (MIME type)
190
  content_type = file.content_type
191
- if content_type not in ["image/jpeg", "image/png", "image/gif"]:
 
 
 
 
 
 
 
 
 
 
 
 
192
  raise HTTPException(status_code=400, detail="Invalid file type")
193
 
194
  # do something with the valid file
 
3
 
4
 
5
  from pydantic import BaseModel
 
 
 
 
6
  import os
7
  import shutil
8
  import subprocess
9
+ import shutil
10
 
11
+ # import torch
12
  from langchain.chains import RetrievalQA
13
  from langchain.embeddings import HuggingFaceInstructEmbeddings
14
  from langchain.prompts import PromptTemplate
 
185
 
186
  # check the content type (MIME type)
187
  content_type = file.content_type
188
+
189
+ if content_type not in [
190
+ "text/plain",
191
+ "text/markdown",
192
+ "text/x-markdown",
193
+ "text/csv",
194
+ "application/msword",
195
+ "application/pdf",
196
+ "application/vnd.ms-excel",
197
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
198
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
199
+ "text/x-python",
200
+ "application/x-python-code"]:
201
  raise HTTPException(status_code=400, detail="Invalid file type")
202
 
203
  # do something with the valid file