langroid 0.33.12__py3-none-any.whl → 0.33.13__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.
@@ -1143,20 +1143,22 @@ class DocChatAgent(ChatAgent):
1143
1143
  id2_rank_semantic = {d.id(): i for i, (d, _) in enumerate(docs_and_scores)}
1144
1144
  id2doc = {d.id(): d for d, _ in docs_and_scores}
1145
1145
  # make sure we get unique docs
1146
- passages = [id2doc[id] for id, _ in id2_rank_semantic.items()]
1146
+ passages = [id2doc[id] for id in id2_rank_semantic.keys()]
1147
1147
 
1148
1148
  id2_rank_bm25 = {}
1149
1149
  if self.config.use_bm25_search:
1150
1150
  # TODO: Add score threshold in config
1151
1151
  docs_scores = self.get_similar_chunks_bm25(query, retrieval_multiple)
1152
+ id2doc.update({d.id(): d for d, _ in docs_scores})
1152
1153
  if self.config.cross_encoder_reranking_model == "":
1153
1154
  # only if we're not re-ranking with a cross-encoder,
1154
1155
  # we collect these ranks for Reciprocal Rank Fusion down below.
1155
1156
  docs_scores = sorted(docs_scores, key=lambda x: x[1], reverse=True)
1156
1157
  id2_rank_bm25 = {d.id(): i for i, (d, _) in enumerate(docs_scores)}
1157
- id2doc.update({d.id(): d for d, _ in docs_scores})
1158
1158
  else:
1159
1159
  passages += [d for (d, _) in docs_scores]
1160
+ # eliminate duplicate ids
1161
+ passages = [id2doc[id] for id in id2doc.keys()]
1160
1162
 
1161
1163
  id2_rank_fuzzy = {}
1162
1164
  if self.config.use_fuzzy_match:
@@ -1174,6 +1176,8 @@ class DocChatAgent(ChatAgent):
1174
1176
  id2doc.update({d.id(): d for d, _ in fuzzy_match_doc_scores})
1175
1177
  else:
1176
1178
  passages += [d for (d, _) in fuzzy_match_doc_scores]
1179
+ # eliminate duplicate ids
1180
+ passages = [id2doc[id] for id in id2doc.keys()]
1177
1181
 
1178
1182
  if (
1179
1183
  self.config.cross_encoder_reranking_model == ""
langroid/mytypes.py CHANGED
@@ -75,6 +75,16 @@ class Document(BaseModel):
75
75
  def id(self) -> str:
76
76
  return self.metadata.id
77
77
 
78
+ def from_string(
79
+ content: str,
80
+ source: str = "context",
81
+ is_chunk: bool = True,
82
+ ) -> "Document":
83
+ return Document(
84
+ content=content,
85
+ metadata=DocMetaData(source=source, is_chunk=is_chunk),
86
+ )
87
+
78
88
  def __str__(self) -> str:
79
89
  return dedent(
80
90
  f"""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langroid
3
- Version: 0.33.12
3
+ Version: 0.33.13
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  Author-email: Prasad Chalasani <pchalasani@gmail.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  langroid/__init__.py,sha256=z_fCOLQJPOw3LLRPBlFB5-2HyCjpPgQa4m4iY5Fvb8Y,1800
2
2
  langroid/exceptions.py,sha256=gp6ku4ZLdXXCUQIwUNVFojJNGTzGnkevi2PLvG7HOhc,2555
3
- langroid/mytypes.py,sha256=ptAFxEAtiwmIfUnGisNotTe8wT9LKBf22lOfPgZoQIY,2368
3
+ langroid/mytypes.py,sha256=vrU4eb5In8fEYwC881T4NByIaGdxiMhmY5dLxGEkyZY,2629
4
4
  langroid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  langroid/agent/__init__.py,sha256=ll0Cubd2DZ-fsCMl7e10hf9ZjFGKzphfBco396IKITY,786
6
6
  langroid/agent/base.py,sha256=oThlrYygKDu1-bKjAfygldJ511gMKT8Z0qCrD52DdDM,77834
@@ -14,7 +14,7 @@ langroid/agent/xml_tool_message.py,sha256=6SshYZJKIfi4mkE-gIoSwjkEYekQ8GwcSiCv7a
14
14
  langroid/agent/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  langroid/agent/callbacks/chainlit.py,sha256=RH8qUXaZE5o2WQz3WJQ1SdFtASGlxWCA6_HYz_3meDQ,20822
16
16
  langroid/agent/special/__init__.py,sha256=gik_Xtm_zV7U9s30Mn8UX3Gyuy4jTjQe9zjiE3HWmEo,1273
17
- langroid/agent/special/doc_chat_agent.py,sha256=zw2MvdCWRPH93d73PKh27KFiQ8sUCFPxAfLDdkxvdZQ,59301
17
+ langroid/agent/special/doc_chat_agent.py,sha256=xXkrFb5ty3NoKfgC0CZqolxmUP1j_sXqywQ_VNxOrOE,59505
18
18
  langroid/agent/special/lance_doc_chat_agent.py,sha256=s8xoRs0gGaFtDYFUSIRchsgDVbS5Q3C2b2mr3V1Fd-Q,10419
19
19
  langroid/agent/special/lance_tools.py,sha256=qS8x4wi8mrqfbYV2ztFzrcxyhHQ0ZWOc-zkYiH7awj0,2105
20
20
  langroid/agent/special/relevance_extractor_agent.py,sha256=zIx8GUdVo1aGW6ASla0NPQjYYIpmriK_TYMijqAx3F8,4796
@@ -121,7 +121,7 @@ langroid/vector_store/lancedb.py,sha256=b3_vWkTjG8mweZ7ZNlUD-NjmQP_rLBZfyKWcxt2v
121
121
  langroid/vector_store/meilisearch.py,sha256=6frB7GFWeWmeKzRfLZIvzRjllniZ1cYj3HmhHQICXLs,11663
122
122
  langroid/vector_store/momento.py,sha256=UNHGT6jXuQtqY9f6MdqGU14bVnS0zHgIJUa30ULpUJo,10474
123
123
  langroid/vector_store/qdrantdb.py,sha256=HRLCt-FG8y4718omwpFaQZnWeYxPj0XCwS4tjokI1sU,18116
124
- langroid-0.33.12.dist-info/METADATA,sha256=tUh6elP7kcHfPS2dUXBE-gZ6vLoBfFzYsmg7nr2oCrg,59016
125
- langroid-0.33.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
126
- langroid-0.33.12.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
127
- langroid-0.33.12.dist-info/RECORD,,
124
+ langroid-0.33.13.dist-info/METADATA,sha256=6D80UFs_rmlz89V6OEStdRBVECC-B8iLtBLTghgRg5w,59016
125
+ langroid-0.33.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
126
+ langroid-0.33.13.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
127
+ langroid-0.33.13.dist-info/RECORD,,