feat(backend): adds python code parsing (#1003)

Adds a python code parser and invokes it in processors.py
This commit is contained in:
joelsprunger 2023-08-22 03:05:31 -07:00 committed by GitHub
parent e328ab81b3
commit a626b84b96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -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,
)

View File

@ -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,
}