diff --git a/backend/parsers/code_python.py b/backend/parsers/code_python.py new file mode 100644 index 000000000..360601b8b --- /dev/null +++ b/backend/parsers/code_python.py @@ -0,0 +1,14 @@ +from langchain.document_loaders import PythonLoader +from models import File + +from .common import process_file + + +async def process_python(file: File, enable_summarization, brain_id, user_openai_api_key): + return await process_file( + file=file, + loader_class=PythonLoader, + enable_summarization=enable_summarization, + brain_id=brain_id, + user_openai_api_key=user_openai_api_key, + ) diff --git a/backend/utils/processors.py b/backend/utils/processors.py index cae09c105..ab3b51a5d 100644 --- a/backend/utils/processors.py +++ b/backend/utils/processors.py @@ -12,6 +12,7 @@ from parsers.pdf import process_pdf from parsers.powerpoint import process_powerpoint from parsers.txt import process_txt from parsers.xlsx import process_xlsx +from parsers.code_python import process_python file_processors = { ".txt": process_txt, @@ -34,6 +35,7 @@ file_processors = { ".xls": process_xlsx, ".epub": process_epub, ".ipynb": process_ipnyb, + ".py": process_python, }