langroid 0.52.3__py3-none-any.whl → 0.52.5__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.
- langroid/cachedb/__init__.py +0 -9
- langroid/language_models/openai_gpt.py +2 -15
- langroid/parsing/pdf_utils.py +6 -3
- langroid/utils/configuration.py +1 -1
- {langroid-0.52.3.dist-info → langroid-0.52.5.dist-info}/METADATA +3 -6
- {langroid-0.52.3.dist-info → langroid-0.52.5.dist-info}/RECORD +8 -9
- langroid/cachedb/momento_cachedb.py +0 -108
- {langroid-0.52.3.dist-info → langroid-0.52.5.dist-info}/WHEEL +0 -0
- {langroid-0.52.3.dist-info → langroid-0.52.5.dist-info}/licenses/LICENSE +0 -0
langroid/cachedb/__init__.py
CHANGED
@@ -627,20 +627,7 @@ class OpenAIGPT(LanguageModel):
|
|
627
627
|
|
628
628
|
self.cache: CacheDB | None = None
|
629
629
|
use_cache = self.config.cache_config is not None
|
630
|
-
if settings.cache_type
|
631
|
-
from langroid.cachedb.momento_cachedb import (
|
632
|
-
MomentoCache,
|
633
|
-
MomentoCacheConfig,
|
634
|
-
)
|
635
|
-
|
636
|
-
if config.cache_config is None or not isinstance(
|
637
|
-
config.cache_config,
|
638
|
-
MomentoCacheConfig,
|
639
|
-
):
|
640
|
-
# switch to fresh momento config if needed
|
641
|
-
config.cache_config = MomentoCacheConfig()
|
642
|
-
self.cache = MomentoCache(config.cache_config)
|
643
|
-
elif "redis" in settings.cache_type and use_cache:
|
630
|
+
if "redis" in settings.cache_type and use_cache:
|
644
631
|
if config.cache_config is None or not isinstance(
|
645
632
|
config.cache_config,
|
646
633
|
RedisCacheConfig,
|
@@ -656,7 +643,7 @@ class OpenAIGPT(LanguageModel):
|
|
656
643
|
elif settings.cache_type != "none" and use_cache:
|
657
644
|
raise ValueError(
|
658
645
|
f"Invalid cache type {settings.cache_type}. "
|
659
|
-
"Valid types are
|
646
|
+
"Valid types are redis, fakeredis, none"
|
660
647
|
)
|
661
648
|
|
662
649
|
self.config._validate_litellm()
|
langroid/parsing/pdf_utils.py
CHANGED
@@ -17,12 +17,12 @@ if fitz is None:
|
|
17
17
|
|
18
18
|
|
19
19
|
def pdf_split_pages(
|
20
|
-
input_pdf: Union[BytesIO, BinaryIO],
|
20
|
+
input_pdf: Union[BytesIO, BinaryIO, str],
|
21
21
|
) -> Tuple[List[Path], TemporaryDirectory[Any]]:
|
22
22
|
"""Splits a PDF into individual pages in a temporary directory.
|
23
23
|
|
24
24
|
Args:
|
25
|
-
input_pdf: Input PDF file in bytes or
|
25
|
+
input_pdf: Input PDF file in bytes, binary mode, or a file path
|
26
26
|
max_workers: Maximum number of concurrent workers for parallel processing
|
27
27
|
|
28
28
|
Returns:
|
@@ -36,7 +36,10 @@ def pdf_split_pages(
|
|
36
36
|
tmp_dir.cleanup() # Clean up temp files when done
|
37
37
|
"""
|
38
38
|
tmp_dir = tempfile.TemporaryDirectory()
|
39
|
-
|
39
|
+
if isinstance(input_pdf, str):
|
40
|
+
doc = fitz.open(input_pdf)
|
41
|
+
else:
|
42
|
+
doc = fitz.open(stream=input_pdf, filetype="pdf")
|
40
43
|
paths = []
|
41
44
|
|
42
45
|
for page_num in range(len(doc)):
|
langroid/utils/configuration.py
CHANGED
@@ -17,7 +17,7 @@ class Settings(BaseSettings):
|
|
17
17
|
progress: bool = False # show progress spinners/bars?
|
18
18
|
stream: bool = True # stream output?
|
19
19
|
cache: bool = True # use cache?
|
20
|
-
cache_type: Literal["redis", "fakeredis", "
|
20
|
+
cache_type: Literal["redis", "fakeredis", "none"] = "redis" # cache type
|
21
21
|
chat_model: str = "" # language model name, e.g. litellm/ollama/llama2
|
22
22
|
quiet: bool = False # quiet mode (i.e. suppress all output)?
|
23
23
|
notebook: bool = False # running in a notebook?
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: langroid
|
3
|
-
Version: 0.52.
|
3
|
+
Version: 0.52.5
|
4
4
|
Summary: Harness LLMs with Multi-Agent Programming
|
5
5
|
Author-email: Prasad Chalasani <pchalasani@gmail.com>
|
6
6
|
License: MIT
|
@@ -151,8 +151,6 @@ Provides-Extra: meilisearch
|
|
151
151
|
Requires-Dist: meilisearch-python-sdk<3.0.0,>=2.2.3; extra == 'meilisearch'
|
152
152
|
Provides-Extra: metaphor
|
153
153
|
Requires-Dist: metaphor-python<0.2.0,>=0.1.23; extra == 'metaphor'
|
154
|
-
Provides-Extra: momento
|
155
|
-
Requires-Dist: momento<1.21.0,>=1.10.2; extra == 'momento'
|
156
154
|
Provides-Extra: mysql
|
157
155
|
Requires-Dist: pymysql<2.0.0,>=1.1.0; extra == 'mysql'
|
158
156
|
Provides-Extra: neo4j
|
@@ -617,9 +615,8 @@ section above)
|
|
617
615
|
providers ([local/open](https://langroid.github.io/langroid/tutorials/local-llm-setup/) or [remote/commercial](https://langroid.github.io/langroid/tutorials/non-openai-llms/)) via proxy libraries and local model servers
|
618
616
|
such as [ollama](https://github.com/ollama), [oobabooga](https://github.com/oobabooga/text-generation-webui),
|
619
617
|
[LiteLLM](https://docs.litellm.ai/docs/providers) that in effect mimic the OpenAI API. See the [supported LLMs](https://langroid.github.io/langroid/tutorials/supported-models/).
|
620
|
-
- **Caching of LLM responses:** Langroid supports [Redis](https://redis.com/try-free/)
|
621
|
-
|
622
|
-
- **Vector-stores**: [LanceDB](https://github.com/lancedb/lancedb), [Qdrant](https://qdrant.tech/), [Chroma](https://www.trychroma.com/) are currently supported.
|
618
|
+
- **Caching of LLM responses:** Langroid supports [Redis](https://redis.com/try-free/) to cache LLM responses.
|
619
|
+
- **Vector-stores**: [Qdrant](https://qdrant.tech/), [Chroma](https://www.trychroma.com/), LanceDB, Pinecone, PostgresDB (PGVector), Weaviate are currently supported.
|
623
620
|
Vector stores allow for Retrieval-Augmented-Generation (RAG).
|
624
621
|
- **Grounding and source-citation:** Access to external documents via vector-stores
|
625
622
|
allows for grounding and source-citation.
|
@@ -54,9 +54,8 @@ langroid/agent/tools/retrieval_tool.py,sha256=zcAV20PP_6VzSd-UE-IJcabaBseFL_QNz5
|
|
54
54
|
langroid/agent/tools/rewind_tool.py,sha256=XAXL3BpNhCmBGYq_qi_sZfHJuIw7NY2jp4wnojJ7WRs,5606
|
55
55
|
langroid/agent/tools/segment_extract_tool.py,sha256=__srZ_VGYLVOdPrITUM8S0HpmX4q7r5FHWMDdHdEv8w,1440
|
56
56
|
langroid/agent/tools/tavily_search_tool.py,sha256=soI-j0HdgVQLf09wRQScaEK4b5RpAX9C4cwOivRFWWI,1903
|
57
|
-
langroid/cachedb/__init__.py,sha256=
|
57
|
+
langroid/cachedb/__init__.py,sha256=G2KyNnk3Qkhv7OKyxTOnpsxfDycx3NY0O_wXkJlalNY,96
|
58
58
|
langroid/cachedb/base.py,sha256=ztVjB1DtN6pLCujCWnR6xruHxwVj3XkYniRTYAKKqk0,1354
|
59
|
-
langroid/cachedb/momento_cachedb.py,sha256=YEOJ62hEcV6iIeMr5aGgRYgWQqFYaej9gEDEcY0sm7M,3172
|
60
59
|
langroid/cachedb/redis_cachedb.py,sha256=7kgnbf4b5CKsCrlL97mHWKvdvlLt8zgn7lc528jEpiE,5141
|
61
60
|
langroid/embedding_models/__init__.py,sha256=KyYxR3jDFUCfYjSuCL86qjAmrq6mXXjOT4lFNOKVj6Y,955
|
62
61
|
langroid/embedding_models/base.py,sha256=Ml7oA6PzQm0wZmIYn3fhF7dvZCi-amviWUwOeBegH3A,2562
|
@@ -73,7 +72,7 @@ langroid/language_models/base.py,sha256=pfN3t-BktKmN_4K8pwmpjC9OdcHxsytM5s5TmsJ-
|
|
73
72
|
langroid/language_models/config.py,sha256=9Q8wk5a7RQr8LGMT_0WkpjY8S4ywK06SalVRjXlfCiI,378
|
74
73
|
langroid/language_models/mock_lm.py,sha256=5BgHKDVRWFbUwDT_PFgTZXz9-k8wJSA2e3PZmyDgQ1k,4022
|
75
74
|
langroid/language_models/model_info.py,sha256=vOaTi-XFKnz-BvHUvgjnt0XfOtl21Apev3Zy7Rhckbw,14458
|
76
|
-
langroid/language_models/openai_gpt.py,sha256=
|
75
|
+
langroid/language_models/openai_gpt.py,sha256=Hw4llY9Dbox7L0sVP06q10ayoem8FOfXSfbLm3u55v4,85317
|
77
76
|
langroid/language_models/utils.py,sha256=hC5p61P_Qlrowkm5wMap1A1b5ZUCwK_XhPIzAQk1T1s,5483
|
78
77
|
langroid/language_models/prompt_formatter/__init__.py,sha256=2-5cdE24XoFDhifOLl8yiscohil1ogbP1ECkYdBlBsk,372
|
79
78
|
langroid/language_models/prompt_formatter/base.py,sha256=eDS1sgRNZVnoajwV_ZIha6cba5Dt8xjgzdRbPITwx3Q,1221
|
@@ -88,7 +87,7 @@ langroid/parsing/md_parser.py,sha256=JUgsUpCaeAuBndmtDaJR9HMZaje1gmtXtaLXJHst3i8
|
|
88
87
|
langroid/parsing/para_sentence_split.py,sha256=AJBzZojP3zpB-_IMiiHismhqcvkrVBQ3ZINoQyx_bE4,2000
|
89
88
|
langroid/parsing/parse_json.py,sha256=aADo38bAHQhC8on4aWZZzVzSDy-dK35vRLZsFI2ewh8,4756
|
90
89
|
langroid/parsing/parser.py,sha256=uaAITarcGI2504zcP_dLhp3LjNdh9A6R_yS-o_VcaH8,15599
|
91
|
-
langroid/parsing/pdf_utils.py,sha256=
|
90
|
+
langroid/parsing/pdf_utils.py,sha256=9HnwhbZvpBUhW8WjY9OpGPKaIt3oe_a1AuqhWKqNQ6s,1616
|
92
91
|
langroid/parsing/repo_loader.py,sha256=NpysuyzRHvgL3F4BB_wGo5sCUnZ3FOlVCJmZ7CaUdbs,30202
|
93
92
|
langroid/parsing/routing.py,sha256=-FcnlqldzL4ZoxuDwXjQPNHgBe9F9-F4R6q7b_z9CvI,1232
|
94
93
|
langroid/parsing/search.py,sha256=0NJ5-Rou_BbrHAD7O9b20bKjZJnbadjObvGm4Zq8Kis,9818
|
@@ -105,7 +104,7 @@ langroid/prompts/templates.py,sha256=VV84HVf_amOx6xdWQyIsN9i5dNfrbl8rsfFp6hyfOss
|
|
105
104
|
langroid/pydantic_v1/__init__.py,sha256=HxPGVERapVueRUORgSpj2JX_vTZxVlVbWvhpQlpjygE,283
|
106
105
|
langroid/pydantic_v1/main.py,sha256=p_k7kDY9eDrsA5dxNNqXusKLgx7mS_icGnS7fu4goqY,147
|
107
106
|
langroid/utils/__init__.py,sha256=Sruos2tB4G7Tn0vlblvYlX9PEGR0plI2uE0PJ4d_EC4,353
|
108
|
-
langroid/utils/configuration.py,sha256=
|
107
|
+
langroid/utils/configuration.py,sha256=ZkHHkEeWuS-o3_S4g0SE0wz-UK_of23NOWve1kpQiNY,4801
|
109
108
|
langroid/utils/constants.py,sha256=CK09kda9bNDEhnwClq7ZTWZOh38guJlfcZ5hKUS1Ijo,1075
|
110
109
|
langroid/utils/git_utils.py,sha256=WnflJ3R3owhlD0LNdSJakcKhExcEehE1UW5jYVQl8JY,7955
|
111
110
|
langroid/utils/globals.py,sha256=Az9dOFqR6n9CoTYSqa2kLikQWS0oCQ9DFQIQAnG-2q8,1355
|
@@ -130,7 +129,7 @@ langroid/vector_store/pineconedb.py,sha256=otxXZNaBKb9f_H75HTaU3lMHiaR2NUp5MqwLZ
|
|
130
129
|
langroid/vector_store/postgres.py,sha256=wHPtIi2qM4fhO4pMQr95pz1ZCe7dTb2hxl4VYspGZoA,16104
|
131
130
|
langroid/vector_store/qdrantdb.py,sha256=O6dSBoDZ0jzfeVBd7LLvsXu083xs2fxXtPa9gGX3JX4,18443
|
132
131
|
langroid/vector_store/weaviatedb.py,sha256=Yn8pg139gOy3zkaPfoTbMXEEBCiLiYa1MU5d_3UA1K4,11847
|
133
|
-
langroid-0.52.
|
134
|
-
langroid-0.52.
|
135
|
-
langroid-0.52.
|
136
|
-
langroid-0.52.
|
132
|
+
langroid-0.52.5.dist-info/METADATA,sha256=zlyRvxolWKDmmw88ARFvXeIT9dkfROqJBAVV4v2saBY,63519
|
133
|
+
langroid-0.52.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
134
|
+
langroid-0.52.5.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
|
135
|
+
langroid-0.52.5.dist-info/RECORD,,
|
@@ -1,108 +0,0 @@
|
|
1
|
-
import json
|
2
|
-
import logging
|
3
|
-
import os
|
4
|
-
from datetime import timedelta
|
5
|
-
from typing import Any, Dict, List
|
6
|
-
|
7
|
-
from langroid.cachedb.base import CacheDBConfig
|
8
|
-
from langroid.exceptions import LangroidImportError
|
9
|
-
|
10
|
-
try:
|
11
|
-
import momento
|
12
|
-
from momento.responses import CacheGet
|
13
|
-
except ImportError:
|
14
|
-
raise LangroidImportError(package="momento", extra="momento")
|
15
|
-
|
16
|
-
from dotenv import load_dotenv
|
17
|
-
|
18
|
-
from langroid.cachedb.base import CacheDB
|
19
|
-
|
20
|
-
logger = logging.getLogger(__name__)
|
21
|
-
|
22
|
-
|
23
|
-
class MomentoCacheConfig(CacheDBConfig):
|
24
|
-
"""Configuration model for Momento Cache."""
|
25
|
-
|
26
|
-
ttl: int = 60 * 60 * 24 * 7 # 1 week
|
27
|
-
cachename: str = "langroid_momento_cache"
|
28
|
-
|
29
|
-
|
30
|
-
class MomentoCache(CacheDB):
|
31
|
-
"""Momento implementation of the CacheDB."""
|
32
|
-
|
33
|
-
def __init__(self, config: MomentoCacheConfig):
|
34
|
-
"""
|
35
|
-
Initialize a MomentoCache with the given config.
|
36
|
-
|
37
|
-
Args:
|
38
|
-
config (MomentoCacheConfig): The configuration to use.
|
39
|
-
"""
|
40
|
-
self.config = config
|
41
|
-
load_dotenv()
|
42
|
-
|
43
|
-
momento_token = os.getenv("MOMENTO_AUTH_TOKEN")
|
44
|
-
if momento_token is None:
|
45
|
-
raise ValueError("""MOMENTO_AUTH_TOKEN not set in .env file""")
|
46
|
-
else:
|
47
|
-
self.client = momento.CacheClient(
|
48
|
-
configuration=momento.Configurations.Laptop.v1(),
|
49
|
-
credential_provider=momento.CredentialProvider.from_environment_variable(
|
50
|
-
"MOMENTO_AUTH_TOKEN"
|
51
|
-
),
|
52
|
-
default_ttl=timedelta(seconds=self.config.ttl),
|
53
|
-
)
|
54
|
-
self.client.create_cache(self.config.cachename)
|
55
|
-
|
56
|
-
def clear(self) -> None:
|
57
|
-
"""Clear keys from current db."""
|
58
|
-
self.client.flush_cache(self.config.cachename)
|
59
|
-
|
60
|
-
def store(self, key: str, value: Any) -> None:
|
61
|
-
"""
|
62
|
-
Store a value associated with a key.
|
63
|
-
|
64
|
-
Args:
|
65
|
-
key (str): The key under which to store the value.
|
66
|
-
value (Any): The value to store.
|
67
|
-
"""
|
68
|
-
self.client.set(self.config.cachename, key, json.dumps(value))
|
69
|
-
|
70
|
-
def retrieve(self, key: str) -> Dict[str, Any] | str | None:
|
71
|
-
"""
|
72
|
-
Retrieve the value associated with a key.
|
73
|
-
|
74
|
-
Args:
|
75
|
-
key (str): The key to retrieve the value for.
|
76
|
-
|
77
|
-
Returns:
|
78
|
-
dict: The value associated with the key.
|
79
|
-
"""
|
80
|
-
value = self.client.get(self.config.cachename, key)
|
81
|
-
if isinstance(value, CacheGet.Hit):
|
82
|
-
return json.loads(value.value_string) # type: ignore
|
83
|
-
else:
|
84
|
-
return None
|
85
|
-
|
86
|
-
def delete_keys(self, keys: List[str]) -> None:
|
87
|
-
"""
|
88
|
-
Delete the keys from the cache.
|
89
|
-
|
90
|
-
Args:
|
91
|
-
keys (List[str]): The keys to delete.
|
92
|
-
"""
|
93
|
-
for key in keys:
|
94
|
-
self.client.delete(self.config.cachename, key)
|
95
|
-
|
96
|
-
def delete_keys_pattern(self, pattern: str) -> None:
|
97
|
-
"""
|
98
|
-
Delete the keys from the cache with the given pattern.
|
99
|
-
|
100
|
-
Args:
|
101
|
-
prefix (str): The pattern to match.
|
102
|
-
"""
|
103
|
-
raise NotImplementedError(
|
104
|
-
"""
|
105
|
-
MomentoCache does not support delete_keys_pattern.
|
106
|
-
Please use RedisCache instead.
|
107
|
-
"""
|
108
|
-
)
|
File without changes
|
File without changes
|