Skip to content

Commit 3c8f870

Browse files
jordanrfraziercoderabbitai[bot]autofix-ci[bot]ogabrielluiz
authored andcommitted
ref: improve docling template updates and error message (langflow-ai#8837)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
1 parent c78ca8f commit 3c8f870

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

src/backend/base/langflow/base/data/docling_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ def extract_docling_documents(data_inputs: Data | list[Data] | DataFrame, doc_ke
2626

2727
if isinstance(data_inputs, Data):
2828
if doc_key not in data_inputs.data:
29-
msg = f"{doc_key} field not available in the input Data"
29+
msg = (
30+
f"'{doc_key}' field not available in the input Data. "
31+
"Check that your input is a DoclingDocument. "
32+
"You can use the Docling component to convert your input to a DoclingDocument."
33+
)
3034
raise TypeError(msg)
3135
documents = [data_inputs.data[doc_key]]
3236
else:

src/backend/base/langflow/components/docling/export_docling_document.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Any
2+
13
from docling_core.types.doc import ImageRefMode
24

35
from langflow.base.data.docling_utils import extract_docling_documents
@@ -27,6 +29,7 @@ class ExportDoclingDocumentComponent(Component):
2729
options=["Markdown", "HTML", "Plaintext", "DocTags"],
2830
info="Select the export format to convert the input.",
2931
value="Markdown",
32+
real_time_refresh=True,
3033
),
3134
DropdownInput(
3235
name="image_mode",
@@ -66,6 +69,22 @@ class ExportDoclingDocumentComponent(Component):
6669
Output(display_name="DataFrame", name="dataframe", method="as_dataframe"),
6770
]
6871

72+
def update_build_config(self, build_config: dict, field_value: Any, field_name: str | None = None) -> dict:
73+
if field_name == "export_format" and field_value == "Markdown":
74+
build_config["md_image_placeholder"]["show"] = True
75+
build_config["md_page_break_placeholder"]["show"] = True
76+
build_config["image_mode"]["show"] = True
77+
elif field_name == "export_format" and field_value == "HTML":
78+
build_config["md_image_placeholder"]["show"] = False
79+
build_config["md_page_break_placeholder"]["show"] = False
80+
build_config["image_mode"]["show"] = True
81+
elif field_name == "export_format" and field_value in {"Plaintext", "DocTags"}:
82+
build_config["md_image_placeholder"]["show"] = False
83+
build_config["md_page_break_placeholder"]["show"] = False
84+
build_config["image_mode"]["show"] = False
85+
86+
return build_config
87+
6988
def export_document(self) -> list[Data]:
7089
documents = extract_docling_documents(self.data_inputs, self.doc_key)
7190

src/backend/base/langflow/services/auth/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ async def api_key_security(
6060
result = await get_user_by_username(db, settings_service.auth_settings.SUPERUSER)
6161
logger.warning(AUTO_LOGIN_WARNING)
6262
return UserRead.model_validate(result, from_attributes=True)
63-
else:
64-
raise HTTPException(
65-
status_code=status.HTTP_403_FORBIDDEN,
66-
detail=AUTO_LOGIN_ERROR,
67-
)
63+
raise HTTPException(
64+
status_code=status.HTTP_403_FORBIDDEN,
65+
detail=AUTO_LOGIN_ERROR,
66+
)
6867
result = await check_key(db, query_param or header_param)
6968

7069
elif not query_param and not header_param:

0 commit comments

Comments
 (0)