langroid 0.1.263__py3-none-any.whl → 0.1.265__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/agent/task.py +14 -6
- langroid/cachedb/redis_cachedb.py +8 -4
- langroid/utils/system.py +10 -0
- langroid/vector_store/lancedb.py +32 -23
- {langroid-0.1.263.dist-info → langroid-0.1.265.dist-info}/METADATA +1 -4
- {langroid-0.1.263.dist-info → langroid-0.1.265.dist-info}/RECORD +9 -9
- pyproject.toml +3 -6
- {langroid-0.1.263.dist-info → langroid-0.1.265.dist-info}/LICENSE +0 -0
- {langroid-0.1.263.dist-info → langroid-0.1.265.dist-info}/WHEEL +0 -0
langroid/agent/task.py
CHANGED
@@ -106,7 +106,7 @@ class Task:
|
|
106
106
|
"""
|
107
107
|
|
108
108
|
# class variable called `cache` that is a RedisCache object
|
109
|
-
|
109
|
+
_cache: RedisCache | None = None
|
110
110
|
|
111
111
|
def __init__(
|
112
112
|
self,
|
@@ -332,6 +332,12 @@ class Task:
|
|
332
332
|
config=self.config,
|
333
333
|
)
|
334
334
|
|
335
|
+
@classmethod
|
336
|
+
def cache(cls) -> RedisCache:
|
337
|
+
if cls._cache is None:
|
338
|
+
cls._cache = RedisCache(RedisCacheConfig(fake=False))
|
339
|
+
return cls._cache
|
340
|
+
|
335
341
|
def __repr__(self) -> str:
|
336
342
|
return f"{self.name}"
|
337
343
|
|
@@ -350,7 +356,7 @@ class Task:
|
|
350
356
|
E.g. key = "kill", value = "1"
|
351
357
|
"""
|
352
358
|
try:
|
353
|
-
self.cache.store(f"{self.session_id}:{key}", value)
|
359
|
+
self.cache().store(f"{self.session_id}:{key}", value)
|
354
360
|
except Exception as e:
|
355
361
|
logging.error(f"Error in Task._cache_session_store: {e}")
|
356
362
|
|
@@ -360,7 +366,7 @@ class Task:
|
|
360
366
|
"""
|
361
367
|
session_id_key = f"{self.session_id}:{key}"
|
362
368
|
try:
|
363
|
-
cached_val = self.cache.retrieve(session_id_key)
|
369
|
+
cached_val = self.cache().retrieve(session_id_key)
|
364
370
|
except Exception as e:
|
365
371
|
logging.error(f"Error in Task._cache_session_lookup: {e}")
|
366
372
|
return None
|
@@ -384,7 +390,7 @@ class Task:
|
|
384
390
|
Kill the session with the given session_id.
|
385
391
|
"""
|
386
392
|
session_id_kill_key = f"{session_id}:kill"
|
387
|
-
cls.cache.store(session_id_kill_key, "1")
|
393
|
+
cls.cache().store(session_id_kill_key, "1")
|
388
394
|
|
389
395
|
def kill(self) -> None:
|
390
396
|
"""
|
@@ -567,13 +573,15 @@ class Task:
|
|
567
573
|
Runs asynchronously.
|
568
574
|
|
569
575
|
Args:
|
570
|
-
msg (str|ChatDocument): initial message to process; if None,
|
576
|
+
msg (str|ChatDocument): initial *user-role* message to process; if None,
|
571
577
|
the LLM will respond to its initial `self.task_messages`
|
572
578
|
which set up and kick off the overall task.
|
573
579
|
The agent tries to achieve this goal by looping
|
574
580
|
over `self.step()` until the task is considered
|
575
581
|
done; this can involve a series of messages produced by Agent,
|
576
|
-
LLM or Human (User).
|
582
|
+
LLM or Human (User). Note that `msg`, if passed, is treated as
|
583
|
+
message with role `user`; a "system" role message should not be
|
584
|
+
passed here.
|
577
585
|
turns (int): number of turns to run the task for;
|
578
586
|
default is -1, which means run until task is done.
|
579
587
|
caller (Task|None): the calling task, if any
|
@@ -23,6 +23,8 @@ class RedisCacheConfig(CacheDBConfig):
|
|
23
23
|
class RedisCache(CacheDB):
|
24
24
|
"""Redis implementation of the CacheDB."""
|
25
25
|
|
26
|
+
_warned_password: bool = False
|
27
|
+
|
26
28
|
def __init__(self, config: RedisCacheConfig):
|
27
29
|
"""
|
28
30
|
Initialize a RedisCache with the given config.
|
@@ -40,10 +42,12 @@ class RedisCache(CacheDB):
|
|
40
42
|
redis_host = os.getenv("REDIS_HOST")
|
41
43
|
redis_port = os.getenv("REDIS_PORT")
|
42
44
|
if None in [redis_password, redis_host, redis_port]:
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
if not RedisCache._warned_password:
|
46
|
+
logger.warning(
|
47
|
+
"""REDIS_PASSWORD, REDIS_HOST, REDIS_PORT not set in .env file,
|
48
|
+
using fake redis client"""
|
49
|
+
)
|
50
|
+
RedisCache._warned_password = True
|
47
51
|
self.pool = fakeredis.FakeStrictRedis() # type: ignore
|
48
52
|
else:
|
49
53
|
self.pool = redis.ConnectionPool( # type: ignore
|
langroid/utils/system.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import getpass
|
2
2
|
import hashlib
|
3
3
|
import importlib
|
4
|
+
import importlib.metadata
|
4
5
|
import inspect
|
5
6
|
import logging
|
6
7
|
import shutil
|
@@ -18,6 +19,15 @@ DELETION_ALLOWED_PATHS = [
|
|
18
19
|
]
|
19
20
|
|
20
21
|
|
22
|
+
def pydantic_major_version() -> int:
|
23
|
+
try:
|
24
|
+
pydantic_version = importlib.metadata.version("pydantic")
|
25
|
+
major_version = int(pydantic_version.split(".")[0])
|
26
|
+
return major_version
|
27
|
+
except importlib.metadata.PackageNotFoundError:
|
28
|
+
return -1
|
29
|
+
|
30
|
+
|
21
31
|
class LazyLoad:
|
22
32
|
"""Lazy loading of modules or classes."""
|
23
33
|
|
langroid/vector_store/lancedb.py
CHANGED
@@ -38,6 +38,7 @@ from langroid.utils.pydantic_utils import (
|
|
38
38
|
flatten_pydantic_model,
|
39
39
|
nested_dict_from_flat,
|
40
40
|
)
|
41
|
+
from langroid.utils.system import pydantic_major_version
|
41
42
|
from langroid.vector_store.base import VectorStore, VectorStoreConfig
|
42
43
|
|
43
44
|
try:
|
@@ -121,17 +122,21 @@ class LanceDB(VectorStore):
|
|
121
122
|
else self.unflattened_schema
|
122
123
|
)
|
123
124
|
except (AttributeError, TypeError) as e:
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
125
|
+
pydantic_version = pydantic_major_version()
|
126
|
+
if pydantic_version > 1:
|
127
|
+
raise ValueError(
|
128
|
+
f"""
|
129
|
+
{e}
|
130
|
+
====
|
131
|
+
You are using Pydantic v{pydantic_version},
|
132
|
+
which is not yet compatible with Langroid's LanceDB integration.
|
133
|
+
To use Lancedb with Langroid, please install the
|
134
|
+
latest pydantic 1.x instead of pydantic v2, e.g.
|
135
|
+
pip install "pydantic<2.0.0"
|
136
|
+
"""
|
137
|
+
)
|
138
|
+
else:
|
139
|
+
raise e
|
135
140
|
|
136
141
|
def clear_empty_collections(self) -> int:
|
137
142
|
coll_names = self.list_collections()
|
@@ -264,18 +269,22 @@ class LanceDB(VectorStore):
|
|
264
269
|
self.client.create_table(
|
265
270
|
collection_name, schema=self.schema, mode="overwrite"
|
266
271
|
)
|
267
|
-
except TypeError as e:
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
272
|
+
except (AttributeError, TypeError) as e:
|
273
|
+
pydantic_version = pydantic_major_version()
|
274
|
+
if pydantic_version > 1:
|
275
|
+
raise ValueError(
|
276
|
+
f"""
|
277
|
+
{e}
|
278
|
+
====
|
279
|
+
You are using Pydantic v{pydantic_version},
|
280
|
+
which is not yet compatible with Langroid's LanceDB integration.
|
281
|
+
To use Lancedb with Langroid, please install the
|
282
|
+
latest pydantic 1.x instead of pydantic v2, e.g.
|
283
|
+
pip install "pydantic<2.0.0"
|
284
|
+
"""
|
285
|
+
)
|
286
|
+
else:
|
287
|
+
raise e
|
279
288
|
|
280
289
|
if settings.debug:
|
281
290
|
level = logger.getEffectiveLevel()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: langroid
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.265
|
4
4
|
Summary: Harness LLMs with Multi-Agent Programming
|
5
5
|
License: MIT
|
6
6
|
Author: Prasad Chalasani
|
@@ -19,7 +19,6 @@ Provides-Extra: docx
|
|
19
19
|
Provides-Extra: hf-embeddings
|
20
20
|
Provides-Extra: hf-transformers
|
21
21
|
Provides-Extra: lancedb
|
22
|
-
Provides-Extra: langroid-pydantic-v1
|
23
22
|
Provides-Extra: litellm
|
24
23
|
Provides-Extra: meilisearch
|
25
24
|
Provides-Extra: metaphor
|
@@ -53,10 +52,8 @@ Requires-Dist: halo (>=0.0.31,<0.0.32)
|
|
53
52
|
Requires-Dist: huggingface-hub (>=0.21.2,<0.22.0) ; extra == "hf-transformers" or extra == "all" or extra == "transformers"
|
54
53
|
Requires-Dist: jinja2 (>=3.1.2,<4.0.0)
|
55
54
|
Requires-Dist: lancedb (>=0.8.2,<0.9.0) ; extra == "vecdbs" or extra == "lancedb"
|
56
|
-
Requires-Dist: langroid_pydantic_v1 (>=0.1.0,<0.2.0) ; extra == "langroid-pydantic-v1" or extra == "lancedb"
|
57
55
|
Requires-Dist: litellm (>=1.30.1,<2.0.0) ; extra == "all" or extra == "litellm"
|
58
56
|
Requires-Dist: lxml (>=4.9.3,<5.0.0)
|
59
|
-
Requires-Dist: meilisearch (>=0.28.3,<0.29.0) ; extra == "meilisearch"
|
60
57
|
Requires-Dist: meilisearch-python-sdk (>=2.2.3,<3.0.0) ; extra == "meilisearch"
|
61
58
|
Requires-Dist: metaphor-python (>=0.1.23,<0.2.0) ; extra == "all" or extra == "metaphor"
|
62
59
|
Requires-Dist: momento (>=1.10.2,<2.0.0) ; extra == "momento"
|
@@ -32,7 +32,7 @@ langroid/agent/special/sql/utils/populate_metadata.py,sha256=1J22UsyEPKzwK0XlJZt
|
|
32
32
|
langroid/agent/special/sql/utils/system_message.py,sha256=qKLHkvQWRQodTtPLPxr1GSLUYUFASZU8x-ybV67cB68,1885
|
33
33
|
langroid/agent/special/sql/utils/tools.py,sha256=vFYysk6Vi7HJjII8B4RitA3pt_z3gkSglDNdhNVMiFc,1332
|
34
34
|
langroid/agent/special/table_chat_agent.py,sha256=d9v2wsblaRx7oMnKhLV7uO_ujvk9gh59pSGvBXyeyNc,9659
|
35
|
-
langroid/agent/task.py,sha256=
|
35
|
+
langroid/agent/task.py,sha256=AA8MKWVeZ6VeI3uAVhXzMgZWULGRtYoNXQ6HeAzS4oU,61011
|
36
36
|
langroid/agent/tool_message.py,sha256=wIyZnUcZpxkiRPvM9O3MO3b5BBAdLEEan9kqPbvtApc,9743
|
37
37
|
langroid/agent/tools/__init__.py,sha256=8Pc9BlGCB5FQ2IDGKS_WPpHCoWp5jblMU8EHJwwikAY,303
|
38
38
|
langroid/agent/tools/duckduckgo_search_tool.py,sha256=NhsCaGZkdv28nja7yveAhSK_w6l_Ftym8agbrdzqgfo,1935
|
@@ -48,7 +48,7 @@ langroid/agent_config.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
48
48
|
langroid/cachedb/__init__.py,sha256=icAT2s7Vhf-ZGUeqpDQGNU6ob6o0aFEyjwcxxUGRFjg,225
|
49
49
|
langroid/cachedb/base.py,sha256=ztVjB1DtN6pLCujCWnR6xruHxwVj3XkYniRTYAKKqk0,1354
|
50
50
|
langroid/cachedb/momento_cachedb.py,sha256=YEOJ62hEcV6iIeMr5aGgRYgWQqFYaej9gEDEcY0sm7M,3172
|
51
|
-
langroid/cachedb/redis_cachedb.py,sha256=
|
51
|
+
langroid/cachedb/redis_cachedb.py,sha256=h12NxUeaCcQB06NQwmjm_NU-hc5HQw0fGg3f_MHAzcE,5140
|
52
52
|
langroid/embedding_models/__init__.py,sha256=lsu8qxCjfGujXGueJWU-VI3LMZYGjLSYgqUKDd4F3Qo,715
|
53
53
|
langroid/embedding_models/base.py,sha256=MSjaTkFcfoMGY6SHPOqAsbZbKctj8-1N6zgaFYmOFTg,1830
|
54
54
|
langroid/embedding_models/clustering.py,sha256=tZWElUqXl9Etqla0FAa7og96iDKgjqWjucZR_Egtp-A,6684
|
@@ -115,19 +115,19 @@ langroid/utils/output/printing.py,sha256=yzPJZN-8_jyOJmI9N_oLwEDfjMwVgk3IDiwnZ4e
|
|
115
115
|
langroid/utils/output/status.py,sha256=rzbE7mDJcgNNvdtylCseQcPGCGghtJvVq3lB-OPJ49E,1049
|
116
116
|
langroid/utils/pandas_utils.py,sha256=UctS986Jtl_MvU5rA7-GfrjEHXP7MNu8ePhepv0bTn0,755
|
117
117
|
langroid/utils/pydantic_utils.py,sha256=FKC8VKXH2uBEpFjnnMgIcEsQn6hs31ftea8zv5pMK9g,21740
|
118
|
-
langroid/utils/system.py,sha256=
|
118
|
+
langroid/utils/system.py,sha256=ClIQOpJOeCgfi9n5c-bOS62B2cuqrZFGkWPRbjCpSqk,5208
|
119
119
|
langroid/utils/web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
120
120
|
langroid/utils/web/login.py,sha256=1iz9eUAHa87vpKIkzwkmFa00avwFWivDSAr7QUhK7U0,2528
|
121
121
|
langroid/vector_store/__init__.py,sha256=6xBjb_z4QtUy4vz4RuFbcbSwmHrggHL8-q0DwCf3PMM,972
|
122
122
|
langroid/vector_store/base.py,sha256=1bzFEDJcbKIaZnTPhBjnQ260c6QYs5SpZwGMtwt0-6Y,13481
|
123
123
|
langroid/vector_store/chromadb.py,sha256=bZ5HjwgKgfJj1PUHsatYsrHv-v0dpOfMR2l0tJ2H0_A,7890
|
124
|
-
langroid/vector_store/lancedb.py,sha256=
|
124
|
+
langroid/vector_store/lancedb.py,sha256=9x7e_5zo7nLhMbhjYby2ZpBJ-vyawcC0_XAuatfHJf8,20517
|
125
125
|
langroid/vector_store/meilisearch.py,sha256=6frB7GFWeWmeKzRfLZIvzRjllniZ1cYj3HmhHQICXLs,11663
|
126
126
|
langroid/vector_store/momento.py,sha256=QaPzUnTwlswoawGB-paLtUPyLRvckFXLfLDfvbTzjNQ,10505
|
127
127
|
langroid/vector_store/qdrant_cloud.py,sha256=3im4Mip0QXLkR6wiqVsjV1QvhSElfxdFSuDKddBDQ-4,188
|
128
128
|
langroid/vector_store/qdrantdb.py,sha256=wYOuu5c2vIKn9ZgvTXcAiZXMpV8AOXEWFAzI8S8UP-0,16828
|
129
|
-
pyproject.toml,sha256=
|
130
|
-
langroid-0.1.
|
131
|
-
langroid-0.1.
|
132
|
-
langroid-0.1.
|
133
|
-
langroid-0.1.
|
129
|
+
pyproject.toml,sha256=zJRntm67SKuTYmuGM9SuBHq3t8_YCES7QJZrUnOBhEs,6966
|
130
|
+
langroid-0.1.265.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
|
131
|
+
langroid-0.1.265.dist-info/METADATA,sha256=k8pBX7RAwBzJqfOxHE0HOezRNV1HGgxhRFEu9r9BpWQ,52514
|
132
|
+
langroid-0.1.265.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
133
|
+
langroid-0.1.265.dist-info/RECORD,,
|
pyproject.toml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "langroid"
|
3
|
-
version = "0.1.
|
3
|
+
version = "0.1.265"
|
4
4
|
description = "Harness LLMs with Multi-Agent Programming"
|
5
5
|
authors = ["Prasad Chalasani <pchalasani@gmail.com>"]
|
6
6
|
readme = "README.md"
|
@@ -20,7 +20,6 @@ sentence-transformers = {version="2.2.2", optional=true}
|
|
20
20
|
torch = {version="2.0.0", optional=true}
|
21
21
|
psycopg2 = {version="^2.9.7", optional=true}
|
22
22
|
pymysql = {version = "^1.1.0", optional = true}
|
23
|
-
meilisearch = {version="^0.28.3", optional=true}
|
24
23
|
meilisearch-python-sdk = {version="^2.2.3", optional=true}
|
25
24
|
litellm = {version = "^1.30.1", optional = true}
|
26
25
|
metaphor-python = {version = "^0.1.23", optional = true}
|
@@ -30,7 +29,6 @@ neo4j = {version = "^5.14.1", optional = true}
|
|
30
29
|
huggingface-hub = {version="^0.21.2", optional=true}
|
31
30
|
transformers = {version="^4.40.1", optional=true}
|
32
31
|
lancedb = {version="^0.8.2", optional=true}
|
33
|
-
langroid_pydantic_v1 = {version="^0.1.0", optional=true}
|
34
32
|
tantivy = {version="^0.21.0", optional=true}
|
35
33
|
pypdf = {version="^3.12.2", optional=true}
|
36
34
|
pymupdf = {version="^1.23.3", optional=true}
|
@@ -115,8 +113,7 @@ all = [
|
|
115
113
|
"chainlit", "python-socketio",
|
116
114
|
]
|
117
115
|
# more granular groupings
|
118
|
-
|
119
|
-
lancedb = ["lancedb", "tantivy", "pyarrow", "langroid_pydantic_v1"]
|
116
|
+
lancedb = ["lancedb", "tantivy", "pyarrow"]
|
120
117
|
pdf-parsers = ["pdfplumber", "pypdf", "pymupdf", "pdf2image", "pytesseract"]
|
121
118
|
docx = ["python-docx"]
|
122
119
|
scrapy = ["scrapy"]
|
@@ -136,7 +133,7 @@ mkdocs = [
|
|
136
133
|
"mkdocs-gen-files", "mkdocs-literate-nav",
|
137
134
|
"mkdocs-section-index", "mkdocs-jupyter", "mkdocs-rss-plugin"
|
138
135
|
]
|
139
|
-
meilisearch = ["meilisearch
|
136
|
+
meilisearch = ["meilisearch-python-sdk"]
|
140
137
|
momento = ["momento"]
|
141
138
|
|
142
139
|
|
File without changes
|
File without changes
|