langroid 0.1.238__tar.gz → 0.1.240__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.
- {langroid-0.1.238 → langroid-0.1.240}/PKG-INFO +5 -3
- {langroid-0.1.238 → langroid-0.1.240}/langroid/vector_store/qdrantdb.py +109 -18
- {langroid-0.1.238 → langroid-0.1.240}/pyproject.toml +4 -3
- {langroid-0.1.238 → langroid-0.1.240}/LICENSE +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/README.md +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/base.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/batch.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/chat_agent.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/chat_document.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/helpers.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/junk +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/neo4j/utils/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/neo4j/utils/system_message.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/task.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/tool_message.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/tools/extract_tool.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/tools/generator_tool.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/tools/run_python_code.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/agent_config.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/cachedb/base.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/cachedb/momento_cachedb.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/embedding_models/base.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/embedding_models/clustering.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/embedding_models/models.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/embedding_models/protoc/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/embedding_models/protoc/embeddings.proto +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/embedding_models/remote_embeds.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/base.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/config.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/openai_assistants.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/openai_gpt.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/utils.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/mytypes.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/code-parsing.md +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/config.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/image_text.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/parse_json.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/parser.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/search.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/spider.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/url_loader_cookies.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/urls.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/utils.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/parsing/web_search.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/prompts/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/prompts/dialog.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/prompts/templates.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/prompts/transforms.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/configuration.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/constants.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/docker.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/globals.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/llms/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/llms/strings.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/logging.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/output/printing.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/output/status.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/system.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/web/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/utils/web/login.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/vector_store/base.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/vector_store/lancedb.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/vector_store/momento.py +0 -0
- {langroid-0.1.238 → langroid-0.1.240}/langroid/vector_store/qdrant_cloud.py +0 -0
@@ -1,13 +1,14 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: langroid
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.240
|
4
4
|
Summary: Harness LLMs with Multi-Agent Programming
|
5
5
|
License: MIT
|
6
6
|
Author: Prasad Chalasani
|
7
7
|
Author-email: pchalasani@gmail.com
|
8
|
-
Requires-Python: >=3.
|
8
|
+
Requires-Python: >=3.10,<3.12
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
11
12
|
Classifier: Programming Language :: Python :: 3.11
|
12
13
|
Provides-Extra: chainlit
|
13
14
|
Provides-Extra: chromadb
|
@@ -98,8 +99,9 @@ Requires-Dist: sqlalchemy (>=2.0.19,<3.0.0)
|
|
98
99
|
Requires-Dist: tantivy (>=0.21.0,<0.22.0)
|
99
100
|
Requires-Dist: thefuzz (>=0.20.0,<0.21.0)
|
100
101
|
Requires-Dist: tiktoken (>=0.5.1,<0.6.0)
|
101
|
-
Requires-Dist: torch (==2.0.0) ; extra == "hf-embeddings"
|
102
|
+
Requires-Dist: torch (==2.0.0) ; extra == "hf-embeddings" or extra == "transformers"
|
102
103
|
Requires-Dist: trafilatura (>=1.5.0,<2.0.0)
|
104
|
+
Requires-Dist: transformers (>=4.40.1,<5.0.0) ; extra == "transformers"
|
103
105
|
Requires-Dist: typer (>=0.9.0,<0.10.0)
|
104
106
|
Requires-Dist: types-pillow (>=10.2.0.20240406,<11.0.0.0)
|
105
107
|
Requires-Dist: types-pyyaml (>=6.0.12.20240311,<7.0.0.0)
|
@@ -3,7 +3,7 @@ import json
|
|
3
3
|
import logging
|
4
4
|
import os
|
5
5
|
import uuid
|
6
|
-
from typing import List, Optional, Sequence, Tuple, TypeVar
|
6
|
+
from typing import Dict, List, Optional, Sequence, Tuple, TypeVar
|
7
7
|
|
8
8
|
from dotenv import load_dotenv
|
9
9
|
from qdrant_client import QdrantClient
|
@@ -13,7 +13,12 @@ from qdrant_client.http.models import (
|
|
13
13
|
CollectionStatus,
|
14
14
|
Distance,
|
15
15
|
Filter,
|
16
|
-
|
16
|
+
NamedSparseVector,
|
17
|
+
NamedVector,
|
18
|
+
SearchRequest,
|
19
|
+
SparseIndexParams,
|
20
|
+
SparseVector,
|
21
|
+
SparseVectorParams,
|
17
22
|
VectorParams,
|
18
23
|
)
|
19
24
|
|
@@ -22,7 +27,7 @@ from langroid.embedding_models.base import (
|
|
22
27
|
EmbeddingModelsConfig,
|
23
28
|
)
|
24
29
|
from langroid.embedding_models.models import OpenAIEmbeddingsConfig
|
25
|
-
from langroid.mytypes import Document, EmbeddingFunction
|
30
|
+
from langroid.mytypes import Document, EmbeddingFunction, Embeddings
|
26
31
|
from langroid.utils.configuration import settings
|
27
32
|
from langroid.vector_store.base import VectorStore, VectorStoreConfig
|
28
33
|
|
@@ -62,15 +67,36 @@ class QdrantDBConfig(VectorStoreConfig):
|
|
62
67
|
storage_path: str = ".qdrant/data"
|
63
68
|
embedding: EmbeddingModelsConfig = OpenAIEmbeddingsConfig()
|
64
69
|
distance: str = Distance.COSINE
|
70
|
+
use_sparse_embeddings: bool = False
|
71
|
+
sparse_embedding_model: str = ""
|
72
|
+
sparse_limit: int = 3
|
65
73
|
|
66
74
|
|
67
75
|
class QdrantDB(VectorStore):
|
68
76
|
def __init__(self, config: QdrantDBConfig = QdrantDBConfig()):
|
69
77
|
super().__init__(config)
|
70
|
-
self.config = config
|
78
|
+
self.config: QdrantDBConfig = config
|
71
79
|
emb_model = EmbeddingModel.create(config.embedding)
|
72
80
|
self.embedding_fn: EmbeddingFunction = emb_model.embedding_fn()
|
73
81
|
self.embedding_dim = emb_model.embedding_dims
|
82
|
+
if self.config.use_sparse_embeddings:
|
83
|
+
try:
|
84
|
+
from transformers import AutoModelForMaskedLM, AutoTokenizer
|
85
|
+
except ImportError:
|
86
|
+
raise ImportError(
|
87
|
+
"""
|
88
|
+
To use sparse embeddings,
|
89
|
+
you must install langroid with the [transformers] extra, e.g.:
|
90
|
+
pip install "langroid[transformers]"
|
91
|
+
"""
|
92
|
+
)
|
93
|
+
|
94
|
+
self.sparse_tokenizer = AutoTokenizer.from_pretrained(
|
95
|
+
self.config.sparse_embedding_model
|
96
|
+
)
|
97
|
+
self.sparse_model = AutoModelForMaskedLM.from_pretrained(
|
98
|
+
self.config.sparse_embedding_model
|
99
|
+
)
|
74
100
|
self.host = config.host
|
75
101
|
self.port = config.port
|
76
102
|
load_dotenv()
|
@@ -205,12 +231,22 @@ class QdrantDB(VectorStore):
|
|
205
231
|
else:
|
206
232
|
logger.warning("Recreating fresh collection")
|
207
233
|
self.client.delete_collection(collection_name=collection_name)
|
208
|
-
|
209
|
-
|
210
|
-
|
234
|
+
|
235
|
+
vectors_config = {
|
236
|
+
"": VectorParams(
|
211
237
|
size=self.embedding_dim,
|
212
238
|
distance=Distance.COSINE,
|
213
|
-
)
|
239
|
+
)
|
240
|
+
}
|
241
|
+
sparse_vectors_config = None
|
242
|
+
if self.config.use_sparse_embeddings:
|
243
|
+
sparse_vectors_config = {
|
244
|
+
"text-sparse": SparseVectorParams(index=SparseIndexParams())
|
245
|
+
}
|
246
|
+
self.client.create_collection(
|
247
|
+
collection_name=collection_name,
|
248
|
+
vectors_config=vectors_config,
|
249
|
+
sparse_vectors_config=sparse_vectors_config,
|
214
250
|
)
|
215
251
|
collection_info = self.client.get_collection(collection_name=collection_name)
|
216
252
|
assert collection_info.status == CollectionStatus.GREEN
|
@@ -221,6 +257,32 @@ class QdrantDB(VectorStore):
|
|
221
257
|
logger.info(collection_info)
|
222
258
|
logger.setLevel(level)
|
223
259
|
|
260
|
+
def get_sparse_embeddings(self, inputs: List[str]) -> List[SparseVector]:
|
261
|
+
if not self.config.use_sparse_embeddings:
|
262
|
+
return []
|
263
|
+
import torch
|
264
|
+
|
265
|
+
tokens = self.sparse_tokenizer(
|
266
|
+
inputs, return_tensors="pt", truncation=True, padding=True
|
267
|
+
)
|
268
|
+
output = self.sparse_model(**tokens)
|
269
|
+
vectors = torch.max(
|
270
|
+
torch.log(torch.relu(output.logits) + torch.tensor(1.0))
|
271
|
+
* tokens.attention_mask.unsqueeze(-1),
|
272
|
+
dim=1,
|
273
|
+
)[0].squeeze(dim=1)
|
274
|
+
sparse_embeddings = []
|
275
|
+
for vec in vectors:
|
276
|
+
cols = vec.nonzero().squeeze().cpu().tolist()
|
277
|
+
weights = vec[cols].cpu().tolist()
|
278
|
+
sparse_embeddings.append(
|
279
|
+
SparseVector(
|
280
|
+
indices=cols,
|
281
|
+
values=weights,
|
282
|
+
)
|
283
|
+
)
|
284
|
+
return sparse_embeddings
|
285
|
+
|
224
286
|
def add_documents(self, documents: Sequence[Document]) -> None:
|
225
287
|
# Add id to metadata if not already present
|
226
288
|
super().maybe_add_ids(documents)
|
@@ -232,6 +294,9 @@ class QdrantDB(VectorStore):
|
|
232
294
|
return
|
233
295
|
document_dicts = [doc.dict() for doc in documents]
|
234
296
|
embedding_vecs = self.embedding_fn([doc.content for doc in documents])
|
297
|
+
sparse_embedding_vecs = self.get_sparse_embeddings(
|
298
|
+
[doc.content for doc in documents]
|
299
|
+
)
|
235
300
|
if self.config.collection_name is None:
|
236
301
|
raise ValueError("No collection name set, cannot ingest docs")
|
237
302
|
if self.config.collection_name not in colls:
|
@@ -241,11 +306,16 @@ class QdrantDB(VectorStore):
|
|
241
306
|
# else we get an API error
|
242
307
|
b = self.config.batch_size
|
243
308
|
for i in range(0, len(ids), b):
|
309
|
+
vectors: Dict[str, Embeddings | List[SparseVector]] = {
|
310
|
+
"": embedding_vecs[i : i + b]
|
311
|
+
}
|
312
|
+
if self.config.use_sparse_embeddings:
|
313
|
+
vectors["text-sparse"] = sparse_embedding_vecs[i : i + b]
|
244
314
|
self.client.upsert(
|
245
315
|
collection_name=self.config.collection_name,
|
246
316
|
points=Batch(
|
247
317
|
ids=ids[i : i + b],
|
248
|
-
vectors=
|
318
|
+
vectors=vectors,
|
249
319
|
payloads=document_dicts[i : i + b],
|
250
320
|
),
|
251
321
|
)
|
@@ -332,18 +402,39 @@ class QdrantDB(VectorStore):
|
|
332
402
|
filter = Filter()
|
333
403
|
else:
|
334
404
|
filter = Filter.parse_obj(json.loads(where))
|
405
|
+
requests = [
|
406
|
+
SearchRequest(
|
407
|
+
vector=NamedVector(
|
408
|
+
name="",
|
409
|
+
vector=embedding,
|
410
|
+
),
|
411
|
+
limit=k,
|
412
|
+
with_payload=True,
|
413
|
+
filter=filter,
|
414
|
+
)
|
415
|
+
]
|
416
|
+
if self.config.use_sparse_embeddings:
|
417
|
+
sparse_embedding = self.get_sparse_embeddings([text])[0]
|
418
|
+
requests.append(
|
419
|
+
SearchRequest(
|
420
|
+
vector=NamedSparseVector(
|
421
|
+
name="text-sparse",
|
422
|
+
vector=sparse_embedding,
|
423
|
+
),
|
424
|
+
limit=self.config.sparse_limit,
|
425
|
+
with_payload=True,
|
426
|
+
filter=filter,
|
427
|
+
)
|
428
|
+
)
|
335
429
|
if self.config.collection_name is None:
|
336
430
|
raise ValueError("No collection name set, cannot search")
|
337
|
-
|
338
|
-
collection_name=self.config.collection_name,
|
339
|
-
query_vector=embedding,
|
340
|
-
query_filter=filter,
|
341
|
-
limit=k,
|
342
|
-
search_params=SearchParams(
|
343
|
-
hnsw_ef=128,
|
344
|
-
exact=False, # use Apx NN, not exact NN
|
345
|
-
),
|
431
|
+
search_result_lists: List[List[ScoredPoint]] = self.client.search_batch(
|
432
|
+
collection_name=self.config.collection_name, requests=requests
|
346
433
|
)
|
434
|
+
|
435
|
+
search_result = [
|
436
|
+
match for result in search_result_lists for match in result
|
437
|
+
] # 2D list -> 1D list
|
347
438
|
scores = [match.score for match in search_result if match is not None]
|
348
439
|
docs = [
|
349
440
|
Document(**(match.payload)) # type: ignore
|
@@ -1,13 +1,13 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "langroid"
|
3
|
-
version = "0.1.
|
3
|
+
version = "0.1.240"
|
4
4
|
description = "Harness LLMs with Multi-Agent Programming"
|
5
5
|
authors = ["Prasad Chalasani <pchalasani@gmail.com>"]
|
6
6
|
readme = "README.md"
|
7
7
|
license = "MIT"
|
8
8
|
|
9
9
|
[tool.poetry.dependencies]
|
10
|
-
python = ">=3.
|
10
|
+
python = ">=3.10,<3.12"
|
11
11
|
mkdocs = {version="^1.4.2", optional=true}
|
12
12
|
mkdocs-material = {version="^9.1.5", optional=true}
|
13
13
|
mkdocstrings = {extras = ["python"], version = "^0.21.2", optional=true}
|
@@ -99,12 +99,13 @@ types-pillow = "^10.2.0.20240406"
|
|
99
99
|
groq = "^0.5.0"
|
100
100
|
nest-asyncio = "^1.6.0"
|
101
101
|
python-magic = "^0.4.27"
|
102
|
+
transformers = {version="^4.40.1", optional=true}
|
102
103
|
|
103
104
|
[tool.poetry.extras]
|
104
105
|
# install these using `poetry install -E [...]` where [...] is one of the extras below
|
105
106
|
# or install multiple extras using, e.g., `poetry install -E "litellm mysql"
|
106
107
|
hf-embeddings = ["sentence-transformers", "torch"]
|
107
|
-
transformers = ["transformers", "huggingface-hub"]
|
108
|
+
transformers = ["transformers", "huggingface-hub", "torch"]
|
108
109
|
unstructured = ["unstructured"]
|
109
110
|
postgres = ["psycopg2", "pytest-postgresql"]
|
110
111
|
mysql = ["pymysql", "pytest-mysql"]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/lance_rag/query_planner_agent.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.1.238 → langroid-0.1.240}/langroid/agent/special/sql/utils/description_extractors.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.1.238 → langroid-0.1.240}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.1.238 → langroid-0.1.240}/langroid/language_models/prompt_formatter/llama2_formatter.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|