langchain-ocr-lib 0.3.3__py3-none-any.whl → 0.4.0__py3-none-any.whl

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.
@@ -13,11 +13,13 @@ from langchain_ocr_lib.di_binding_keys.binding_keys import (
13
13
  )
14
14
  from langchain_ollama import ChatOllama
15
15
  from langchain_openai import ChatOpenAI
16
+ from langchain_together import ChatTogether
16
17
  from langfuse import Langfuse
17
18
  from functools import partial
18
19
 
19
20
  from langchain_ocr_lib.impl.chains.ocr_chain import OcrChain
20
21
  from langchain_ocr_lib.impl.settings.ollama_chat_settings import OllamaSettings
22
+ from langchain_ocr_lib.impl.settings.together_ai_chat_settings import TogetherAISettings
21
23
  from langchain_ocr_lib.impl.settings.vllm_chat_settings import VllmSettings
22
24
  from langchain_ocr_lib.impl.settings.openai_chat_settings import OpenAISettings
23
25
  from langchain_ocr_lib.impl.settings.llm_class_type_settings import LlmClassTypeSettings
@@ -52,18 +54,22 @@ def lib_di_config(binder: Binder):
52
54
  if llm_class_type_settings.llm_type == "ollama":
53
55
  settings = OllamaSettings()
54
56
  model_name = settings.model
55
- partial_llm_provider = partial(llm_provider,settings, ChatOllama)
57
+ partial_llm_provider = partial(llm_provider, settings, ChatOllama)
56
58
  elif llm_class_type_settings.llm_type == "openai":
57
59
  settings = OpenAISettings()
58
60
  model_name = settings.model_name
59
- partial_llm_provider = partial(llm_provider,settings, ChatOpenAI)
61
+ partial_llm_provider = partial(llm_provider, settings, ChatOpenAI)
60
62
  elif llm_class_type_settings.llm_type == "vllm":
61
63
  settings = VllmSettings()
62
64
  model_name = settings.model_name
63
- partial_llm_provider = partial(llm_provider,settings, ChatOpenAI)
65
+ partial_llm_provider = partial(llm_provider, settings, ChatOpenAI)
66
+ elif llm_class_type_settings.llm_type == "together-ai":
67
+ settings = TogetherAISettings()
68
+ model_name = settings.model_name
69
+ partial_llm_provider = partial(llm_provider, settings, ChatTogether)
64
70
  else:
65
71
  raise NotImplementedError("Configured LLM is not implemented")
66
-
72
+
67
73
  binder.bind_to_provider(LargeLanguageModelKey, partial_llm_provider)
68
74
 
69
75
  prompt = ocr_prompt_template_builder(language=language_settings.language, model_name=model_name)
@@ -43,7 +43,7 @@ def get_configurable_fields_from(settings: BaseSettings) -> dict[str, Configurab
43
43
  settings_of_interest = settings.model_fields[field_name]
44
44
  if settings_of_interest.title is not None:
45
45
  _fields[field_name] = ConfigurableField(id=field_name, name=settings_of_interest.title)
46
-
46
+
47
47
  return _fields
48
48
 
49
49
 
@@ -10,3 +10,4 @@ class LLMType(StrEnum):
10
10
  OLLAMA = "ollama"
11
11
  OPENAI = "openai"
12
12
  VLLM = "vllm"
13
+ TOGETHER_AI = "together-ai"
@@ -35,7 +35,9 @@ class OpenAISettings(BaseSettings):
35
35
  title="LLM Model",
36
36
  )
37
37
  api_key: str = Field(default="", description="The API key for authentication")
38
- top_p: float = Field(default=1.0, description="Total probability mass of tokens to consider at each step", title="Top P")
38
+ top_p: float = Field(
39
+ default=1.0, description="Total probability mass of tokens to consider at each step", title="Top P"
40
+ )
39
41
  temperature: float = Field(default=0, description="What sampling temperature to use", title="Temperature")
40
42
  base_url: str = Field(
41
43
  default="https://api.openai.com/v1",
@@ -0,0 +1,45 @@
1
+ """Module contains settings regarding the Together AI API."""
2
+
3
+ from pydantic import Field
4
+ from pydantic_settings import BaseSettings
5
+
6
+
7
+ class TogetherAISettings(BaseSettings):
8
+ """
9
+ Contains settings regarding the Together AI API.
10
+
11
+ Attributes
12
+ ----------
13
+ model_name : str
14
+ The Together AI model identifier.
15
+ together_api_key : str
16
+ The API key for authentication.
17
+ top_p : float
18
+ Total probability mass of tokens to consider at each step.
19
+ temperature : float
20
+ What sampling temperature to use.
21
+ together_api_base : str
22
+ The base URL for the Together AI API endpoint.
23
+ """
24
+
25
+ class Config:
26
+ """Config class for reading fields from environment variables."""
27
+
28
+ env_prefix = "TOGETHER_"
29
+ case_sensitive = False
30
+
31
+ model_name: str = Field(
32
+ default="",
33
+ description="The Together AI model identifier",
34
+ title="Together AI Model",
35
+ )
36
+ together_api_key: str = Field(default="", description="The API key for authentication")
37
+ top_p: float = Field(
38
+ default=1.0, description="Total probability mass of tokens to consider at each step", title="Top P"
39
+ )
40
+ temperature: float = Field(default=0, description="What sampling temperature to use", title="Temperature")
41
+ together_api_base: str = Field(
42
+ default="https://api.together.xyz/v1/",
43
+ env="API_BASE",
44
+ description="The base URL for the Together AI API endpoint",
45
+ )
@@ -35,7 +35,9 @@ class VllmSettings(BaseSettings):
35
35
  title="LLM Model",
36
36
  )
37
37
  api_key: str = Field(default="", description="The API key for authentication")
38
- top_p: float = Field(default=1.0, description="Total probability mass of tokens to consider at each step", title="Top P")
38
+ top_p: float = Field(
39
+ default=1.0, description="Total probability mass of tokens to consider at each step", title="Top P"
40
+ )
39
41
  temperature: float = Field(default=0, description="What sampling temperature to use", title="Temperature")
40
42
  base_url: str = Field(
41
43
  default="http://localhost:8000/v1",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langchain-ocr-lib
3
- Version: 0.3.3
3
+ Version: 0.4.0
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
@@ -16,6 +16,7 @@ Requires-Dist: inject (>=5.2.1,<6.0.0)
16
16
  Requires-Dist: langchain-community (>=0.3.19,<0.4.0)
17
17
  Requires-Dist: langchain-ollama (>=0.2.0,<0.3.0)
18
18
  Requires-Dist: langchain-openai (>=0.3.8,<0.4.0)
19
+ Requires-Dist: langchain-together (>=0.3.0,<0.4.0)
19
20
  Requires-Dist: langfuse (>=2.59.7,<3.0.0)
20
21
  Requires-Dist: openai (>=1.42.0,<2.0.0)
21
22
  Requires-Dist: pdf2image (>=1.17.0,<2.0.0)
@@ -5,7 +5,7 @@ langchain_ocr_lib/converter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
5
5
  langchain_ocr_lib/converter/converter.py,sha256=oDUNzVWD743RgqIal7T4OVv-Z1RKE9uQYzAIPpgY3o8,1280
6
6
  langchain_ocr_lib/di_binding_keys/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  langchain_ocr_lib/di_binding_keys/binding_keys.py,sha256=jE8rwNcLaI0NflIMkK0vu0LVy5o4y0pYgdjbpDNTGyk,338
8
- langchain_ocr_lib/di_config.py,sha256=MQT1U5TvoTRS8TDWsldPB994XepkJQ4k9XRd6HG4Yps,3935
8
+ langchain_ocr_lib/di_config.py,sha256=AhSZoYeaX6-sjfnM5J3N3ECAitQV5KFBvU0vAAu6dbQ,4285
9
9
  langchain_ocr_lib/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  langchain_ocr_lib/impl/chains/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  langchain_ocr_lib/impl/chains/ocr_chain.py,sha256=stE8RLE1ieRHf6XHreKCRfhNfXzw9fNLTake7xQBGL8,2673
@@ -15,15 +15,16 @@ langchain_ocr_lib/impl/converter/pdf_converter.py,sha256=pTHPojuNLCSWJp4FzXBHshX
15
15
  langchain_ocr_lib/impl/langfuse_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  langchain_ocr_lib/impl/langfuse_manager/langfuse_manager.py,sha256=6kvPfYObLmbYZAvtYNx7g9xz5wYz0PxohEzyctpGRto,5353
17
17
  langchain_ocr_lib/impl/llms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- langchain_ocr_lib/impl/llms/llm_factory.py,sha256=GSXBF5MKqo5zRdGEQE1pKI471dgUOYBRz7vCb_qg-pA,2204
19
- langchain_ocr_lib/impl/llms/llm_type.py,sha256=_LKtdVuTRYX6gupkxJtEtIwrbtiMvZmG8WOxfzlm42M,286
18
+ langchain_ocr_lib/impl/llms/llm_factory.py,sha256=pYPwUowm8r42BwOn4W1j4-cEpL9LCCkZU_pJ4xQhshU,2200
19
+ langchain_ocr_lib/impl/llms/llm_type.py,sha256=tNyvUbgIMW7t2-lMEVo-4GyB2hk5Jw9kOaUbVtAK2LA,318
20
20
  langchain_ocr_lib/impl/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  langchain_ocr_lib/impl/settings/langfuse_settings.py,sha256=QT4_VwYj0msFbgL3qIQ-oer3Lt0qny0FFAyfssGu-q0,962
22
22
  langchain_ocr_lib/impl/settings/language_settings.py,sha256=tdAC1t5wGu1MoH1jhjkDnxnX4Ui7giwxt7Qm8_LPkP8,627
23
23
  langchain_ocr_lib/impl/settings/llm_class_type_settings.py,sha256=4KC6zxby13wn38rB8055J8LNVTsmUfrOiyLtLuToHaM,598
24
24
  langchain_ocr_lib/impl/settings/ollama_chat_settings.py,sha256=YQkgD7CfOjHN5wkpJakO0GfM7-D2GqoJLP1gB2932ms,1525
25
- langchain_ocr_lib/impl/settings/openai_chat_settings.py,sha256=W1vPclnXfIDYRfZVMkdGX7ufbbF-cAQiWiKCmjrORO4,1393
26
- langchain_ocr_lib/impl/settings/vllm_chat_settings.py,sha256=h4TFUt4iMZpZSI7qRNe9EB2n_nSjbSjDxSG6R5D3Ah8,1343
25
+ langchain_ocr_lib/impl/settings/openai_chat_settings.py,sha256=5OnHo8a2iRsEvohn09Lf30MNFgS1GWVvOa5kyUusHCQ,1407
26
+ langchain_ocr_lib/impl/settings/together_ai_chat_settings.py,sha256=Jr2dHPpa1VTKwbrCLrjxkHCkWv1-iY1w0DQoklD9SB8,1470
27
+ langchain_ocr_lib/impl/settings/vllm_chat_settings.py,sha256=ZnijdQBSxHh6cGcU5uYth9LHpYYQyIF0XPbsTMh1Fxk,1357
27
28
  langchain_ocr_lib/impl/tracers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
29
  langchain_ocr_lib/impl/tracers/langfuse_traced_chain.py,sha256=syjwNt8HfVmaWXZ-ElFYsc-KwpnKQz2LE3K5jV7c3GE,1599
29
30
  langchain_ocr_lib/language_mapping/language_mapping.py,sha256=VY7WkkZauoHNxkvgUYbig0rDmlKqDkz24cXMd6A7txM,700
@@ -32,7 +33,7 @@ langchain_ocr_lib/prompt_templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQe
32
33
  langchain_ocr_lib/prompt_templates/ocr_prompt.py,sha256=3Be1AL-HJkxPnAP0DNH1MqvAxFWTCeM5UOKP63xkHsY,3543
33
34
  langchain_ocr_lib/tracers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
35
  langchain_ocr_lib/tracers/traced_chain.py,sha256=uxRkdLNn_G6dAsti_gUuF7muhIj10xrOUL7HUga40oc,3056
35
- langchain_ocr_lib-0.3.3.dist-info/METADATA,sha256=97Ikd1_6Boq7RmZbcBZxjK_Cbns7K2XaLlxIVVFCMS4,6440
36
- langchain_ocr_lib-0.3.3.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
37
- langchain_ocr_lib-0.3.3.dist-info/entry_points.txt,sha256=l4mIs0tnIgbJYuVveZySQKVBnqNMHS-8ZZtLwz8ag5k,61
38
- langchain_ocr_lib-0.3.3.dist-info/RECORD,,
36
+ langchain_ocr_lib-0.4.0.dist-info/METADATA,sha256=x5QI_KtLLjUwDbY1FO3olk1wT6K7uufa3sVCOcTYXRQ,6491
37
+ langchain_ocr_lib-0.4.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
38
+ langchain_ocr_lib-0.4.0.dist-info/entry_points.txt,sha256=l4mIs0tnIgbJYuVveZySQKVBnqNMHS-8ZZtLwz8ag5k,61
39
+ langchain_ocr_lib-0.4.0.dist-info/RECORD,,