Boom. It works.

modified:   Dockerfile
	modified:   app.py
This commit is contained in:
Russell Ballestrini 2024-12-08 17:43:00 -05:00
parent aab74dff66
commit c63cfe0de6
2 changed files with 28 additions and 5 deletions

View file

@ -31,6 +31,11 @@ COPY . .
RUN pip install --no-cache-dir -r requirements.lock
RUN playwright install --with-deps && \
python -c "from unstructured.nlp.tokenize import download_nltk_packages; download_nltk_packages()" && \
python -c "import nltk;nltk.download('punkt_tab'); nltk.download('averaged_perceptron_tagger_eng')" && \
python -c "from unstructured.partition.model_init import initialize; initialize()"
EXPOSE 8001
CMD ["python", "app.py"]

28
app.py
View file

@ -35,19 +35,17 @@ from langchain_openai import ChatOpenAI
from llama_index.core.schema import Document as LlamaDocument
from llama_parse import LlamaParse as _LlamaParse
from llama_parse.utils import Language, ResultType
#from megaparse_sdk.schema.languages import Language as MP_Language
from pydantic import BaseModel, Field, ValidationError, validator
from unstructured.partition.auto import partition
# Load environment variables
load_dotenv()
# ---------------------- Langauges --------------------------
from enum import Enum
# ---------------------- Langs --------------------------
class Language(str, Enum):
BAZA = "abq"
@ -136,6 +134,26 @@ class Language(str, Enum):
MP_Language = Language
class FileExtension(str, Enum):
"""Supported file extension enumeration."""
PDF = ".pdf"
DOCX = ".docx"
DOC = ".doc"
TXT = ".txt"
OTF = ".odt"
EPUB = ".epub"
HTML = ".html"
XML = ".xml"
CSV = ".csv"
XLSX = ".xlsx"
XLS = ".xls"
PPTX = ".pptx"
PPT = ".ppt"
JSON = ".json"
MD = ".md"
MARKDOWN = ".markdown"
# --------------------- Exception Classes ---------------------
class HTTPModelNotSupported(HTTPException):