Skip to content

Commit

Permalink
Inline MarkItDown import
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jan 2, 2025
1 parent 5db69f4 commit 1f24dab
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lumen/ai/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import pandas as pd
import param

from markitdown import MarkItDown
from panel.layout import (
Column, FlexBox, Row, Tabs,
)
Expand Down Expand Up @@ -123,9 +122,8 @@ class SourceControls(Viewer):

def __init__(self, **params):
super().__init__(**params)

self._markitdown = MarkItDown()
self.tables_tabs = Tabs(sizing_mode="stretch_width")
self._markitdown = None
self._file_input = FileDropper(
height=100,
multiple=self.param.multiple,
Expand Down Expand Up @@ -278,6 +276,9 @@ def _add_document(
file: io.BytesIO,
document_controls: DocumentControls
):
if self._markitdown is None:
from markitdown import MarkItDown
self._markitdown = MarkItDown()
text = self._markitdown.convert_stream(
file, file_extension=document_controls.extension
).text_content
Expand Down

0 comments on commit 1f24dab

Please sign in to comment.