langchain-ocr-lib 0.3.1__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/PKG-INFO +10 -6
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/README.md +9 -5
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/pyproject.toml +1 -1
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/di_config.py +9 -7
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/langfuse_manager/langfuse_manager.py +12 -7
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/settings/langfuse_settings.py +4 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/chains/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/chains/chain.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/converter/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/converter/converter.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/di_binding_keys/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/di_binding_keys/binding_keys.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/chains/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/chains/ocr_chain.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/converter/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/converter/image_converter.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/converter/pdf_converter.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/langfuse_manager/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/llms/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/llms/llm_factory.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/llms/llm_type.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/settings/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/settings/language_settings.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/settings/llm_class_type_settings.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/settings/ollama_chat_settings.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/settings/openai_chat_settings.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/settings/vllm_chat_settings.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/tracers/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/tracers/langfuse_traced_chain.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/language_mapping/language_mapping.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/main.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/prompt_templates/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/prompt_templates/ocr_prompt.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/tracers/__init__.py +0 -0
- {langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/tracers/traced_chain.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: langchain-ocr-lib
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.2
|
4
4
|
Summary: Modular, vision-LLM-powered chain to convert image and PDF documents into clean Markdown.
|
5
5
|
License: MIT
|
6
6
|
Author: Andreas Klos
|
@@ -25,9 +25,13 @@ Requires-Dist: pytest-asyncio (>=0.25.0,<0.26.0)
|
|
25
25
|
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
26
26
|
Description-Content-Type: text/markdown
|
27
27
|
|
28
|
-
#
|
28
|
+
# langchain-ocr-lib
|
29
29
|
|
30
|
-
**
|
30
|
+
**langchain-ocr-lib** is the OCR processing engine behind LangChain-OCR. It provides a modular, vision-LLM-powered Chain to convert image and PDF documents into clean Markdown. Designed for direct CLI usage or integration into larger applications.
|
31
|
+
|
32
|
+
<div align="center">
|
33
|
+
<img src="./images/logo.png" alt="Logo" style="width:30%;">
|
34
|
+
</div>
|
31
35
|
|
32
36
|
## Table of Contents
|
33
37
|
|
@@ -137,7 +141,7 @@ class Converter:
|
|
137
141
|
return self._converter.convert2markdown(filename=filename)
|
138
142
|
|
139
143
|
converter = Converter()
|
140
|
-
markdown = converter.convert("../
|
144
|
+
markdown = converter.convert("../examples/invoice.pdf") # Adjust the file path as needed
|
141
145
|
print(markdown)
|
142
146
|
```
|
143
147
|
|
@@ -174,7 +178,7 @@ class Converter:
|
|
174
178
|
self._converter.convert(filename=filename)
|
175
179
|
|
176
180
|
converter = Converter()
|
177
|
-
converter.convert("../
|
181
|
+
converter.convert("../examples/invoice.pdf") # Adjust the file path as needed
|
178
182
|
```
|
179
183
|
|
180
184
|
### 4.3 Docker
|
@@ -183,6 +187,6 @@ Run OCR via Docker without local Python setup:
|
|
183
187
|
|
184
188
|
```bash
|
185
189
|
docker build -t ocr -f langchain_ocr_lib/Dockerfile .
|
186
|
-
docker run --net=host -it --rm -v ./
|
190
|
+
docker run --net=host -it --rm -v ./examples:/app/examples:ro ocr examples/invoice.png
|
187
191
|
```
|
188
192
|
|
@@ -1,6 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# langchain-ocr-lib
|
2
2
|
|
3
|
-
**
|
3
|
+
**langchain-ocr-lib** is the OCR processing engine behind LangChain-OCR. It provides a modular, vision-LLM-powered Chain to convert image and PDF documents into clean Markdown. Designed for direct CLI usage or integration into larger applications.
|
4
|
+
|
5
|
+
<div align="center">
|
6
|
+
<img src="./images/logo.png" alt="Logo" style="width:30%;">
|
7
|
+
</div>
|
4
8
|
|
5
9
|
## Table of Contents
|
6
10
|
|
@@ -110,7 +114,7 @@ class Converter:
|
|
110
114
|
return self._converter.convert2markdown(filename=filename)
|
111
115
|
|
112
116
|
converter = Converter()
|
113
|
-
markdown = converter.convert("../
|
117
|
+
markdown = converter.convert("../examples/invoice.pdf") # Adjust the file path as needed
|
114
118
|
print(markdown)
|
115
119
|
```
|
116
120
|
|
@@ -147,7 +151,7 @@ class Converter:
|
|
147
151
|
self._converter.convert(filename=filename)
|
148
152
|
|
149
153
|
converter = Converter()
|
150
|
-
converter.convert("../
|
154
|
+
converter.convert("../examples/invoice.pdf") # Adjust the file path as needed
|
151
155
|
```
|
152
156
|
|
153
157
|
### 4.3 Docker
|
@@ -156,5 +160,5 @@ Run OCR via Docker without local Python setup:
|
|
156
160
|
|
157
161
|
```bash
|
158
162
|
docker build -t ocr -f langchain_ocr_lib/Dockerfile .
|
159
|
-
docker run --net=host -it --rm -v ./
|
163
|
+
docker run --net=host -it --rm -v ./examples:/app/examples:ro ocr examples/invoice.png
|
160
164
|
```
|
@@ -7,7 +7,7 @@ langchain-ocr = "langchain_ocr_lib.main:main"
|
|
7
7
|
|
8
8
|
[tool.poetry]
|
9
9
|
name = "langchain-ocr-lib"
|
10
|
-
version = "0.3.
|
10
|
+
version = "0.3.2"
|
11
11
|
description = "Modular, vision-LLM-powered chain to convert image and PDF documents into clean Markdown."
|
12
12
|
authors = ["Andreas Klos <aklos@outlook.de>"]
|
13
13
|
readme = "README.md"
|
@@ -80,17 +80,19 @@ def lib_di_config(binder: Binder):
|
|
80
80
|
managed_prompts={
|
81
81
|
OcrChain.__name__: prompt,
|
82
82
|
},
|
83
|
+
enabled=langfuse_settings.enabled,
|
83
84
|
),
|
84
85
|
)
|
85
86
|
|
86
|
-
binder.bind(OcrChainKey, OcrChain())
|
87
|
+
binder.bind(OcrChainKey if langfuse_settings.enabled else LangfuseTracedChainKey, OcrChain())
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
89
|
+
if langfuse_settings.enabled:
|
90
|
+
binder.bind(
|
91
|
+
LangfuseTracedChainKey,
|
92
|
+
LangfuseTracedChain(
|
93
|
+
settings=langfuse_settings,
|
94
|
+
),
|
95
|
+
)
|
94
96
|
|
95
97
|
binder.bind(PdfConverterKey, Pdf2MarkdownConverter())
|
96
98
|
binder.bind(ImageConverterKey, Image2MarkdownConverter())
|
@@ -32,8 +32,10 @@ class LangfuseManager:
|
|
32
32
|
def __init__(
|
33
33
|
self,
|
34
34
|
managed_prompts: dict[str, str],
|
35
|
+
enabled: bool = True,
|
35
36
|
):
|
36
37
|
self._managed_prompts = managed_prompts
|
38
|
+
self._enabled = enabled
|
37
39
|
|
38
40
|
def get_langfuse_prompt(self, base_prompt_name: str) -> Optional[ChatPromptClient]:
|
39
41
|
"""
|
@@ -56,6 +58,9 @@ class LangfuseManager:
|
|
56
58
|
Exception
|
57
59
|
If an error occurs while retrieving the prompt template from Langfuse.
|
58
60
|
"""
|
61
|
+
if not self._enabled:
|
62
|
+
logger.info("Langfuse is not enabled. Using fallback prompt.")
|
63
|
+
return None
|
59
64
|
try:
|
60
65
|
langfuse_prompt = self._langfuse.get_prompt(base_prompt_name)
|
61
66
|
except NotFoundError:
|
@@ -72,11 +77,7 @@ class LangfuseManager:
|
|
72
77
|
)
|
73
78
|
langfuse_prompt = self._langfuse.get_prompt(base_prompt_name)
|
74
79
|
except Exception as error:
|
75
|
-
logger.error(
|
76
|
-
"Error occured while getting prompt template from langfuse. Error:\n{error}",
|
77
|
-
extra={error: error},
|
78
|
-
)
|
79
|
-
return None
|
80
|
+
logger.error(f"Error occurred while getting prompt template from langfuse. Error:\n{error}")
|
80
81
|
return langfuse_prompt
|
81
82
|
|
82
83
|
def get_base_llm(self, name: str) -> LLM:
|
@@ -94,9 +95,12 @@ class LangfuseManager:
|
|
94
95
|
The base Large Language Model. If the Langfuse prompt is not found,
|
95
96
|
returns the LLM with a fallback configuration.
|
96
97
|
"""
|
98
|
+
if not self._enabled:
|
99
|
+
logger.info("Langfuse is not enabled. Using fallback LLM.")
|
100
|
+
return self._llm
|
97
101
|
langfuse_prompt = self.get_langfuse_prompt(name)
|
98
102
|
if not langfuse_prompt:
|
99
|
-
logger.
|
103
|
+
logger.warning("Could not retrieve prompt template from langfuse. Using fallback LLM.")
|
100
104
|
return self._llm
|
101
105
|
|
102
106
|
return self._llm.with_config({"configurable": langfuse_prompt.config})
|
@@ -121,7 +125,8 @@ class LangfuseManager:
|
|
121
125
|
"""
|
122
126
|
langfuse_prompt = self.get_langfuse_prompt(name)
|
123
127
|
if not langfuse_prompt:
|
124
|
-
|
128
|
+
if self._enabled:
|
129
|
+
logger.warning("Could not retrieve prompt template from langfuse. Using fallback value.")
|
125
130
|
fallback = self._managed_prompts[name]
|
126
131
|
if isinstance(fallback, ChatPromptTemplate):
|
127
132
|
return fallback
|
@@ -27,3 +27,7 @@ class LangfuseSettings(BaseSettings):
|
|
27
27
|
secret_key: str = Field(default="", description="The secret key for Langfuse.")
|
28
28
|
public_key: str = Field(default="", description="The public key for Langfuse.")
|
29
29
|
host: str = Field(default="https://api.langchain.com", description="The host for Langfuse.")
|
30
|
+
enabled: bool = Field(
|
31
|
+
default=True,
|
32
|
+
description="Whether to enable Langfuse. If set to False, Langfuse will not be used.",
|
33
|
+
)
|
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/chains/__init__.py
RENAMED
File without changes
|
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/converter/__init__.py
RENAMED
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/converter/converter.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/chains/__init__.py
RENAMED
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/chains/ocr_chain.py
RENAMED
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/converter/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/llms/__init__.py
RENAMED
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/llms/llm_factory.py
RENAMED
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/llms/llm_type.py
RENAMED
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/settings/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/impl/tracers/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/tracers/__init__.py
RENAMED
File without changes
|
{langchain_ocr_lib-0.3.1 → langchain_ocr_lib-0.3.2}/src/langchain_ocr_lib/tracers/traced_chain.py
RENAMED
File without changes
|