langroid 0.59.10__py3-none-any.whl → 0.59.12__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.
@@ -14,6 +14,7 @@ pip install "langroid[hf-embeddings]"
14
14
 
15
15
  """
16
16
 
17
+ import asyncio
17
18
  import importlib
18
19
  import logging
19
20
  from collections import OrderedDict
@@ -858,7 +859,9 @@ class DocChatAgent(ChatAgent):
858
859
  return self.summarize_docs()
859
860
  else:
860
861
  self.callbacks.show_start_response(entity="llm")
861
- response = self.answer_from_docs(query_str)
862
+ # Offload blocking retrieval/LLM work to default thread pool so
863
+ # asyncio batch runners can make progress concurrently.
864
+ response = await asyncio.to_thread(self.answer_from_docs, query_str)
862
865
  self._render_llm_response(response, citation_only=True)
863
866
  return ChatDocument(
864
867
  content=response.content,
@@ -135,21 +135,32 @@ def top_level_json_field(s: str, f: str) -> Any:
135
135
  Returns:
136
136
  str: The value of the field f in the top-level JSON object, if any.
137
137
  Otherwise, return an empty string.
138
- """
139
138
 
140
- jsons = extract_top_level_json(s)
141
- if len(jsons) == 0:
142
- return ""
143
- for j in jsons:
144
- json_data = json.loads(j)
145
- if isinstance(json_data, dict):
146
- if f in json_data:
147
- return json_data[f]
148
- elif isinstance(json_data, list):
149
- # Some responses wrap candidate JSON objects in a list; scan them.
150
- for item in json_data:
151
- if isinstance(item, dict) and f in item:
152
- return item[f]
139
+ Note:
140
+ This function is designed to never crash. If any exception occurs during
141
+ JSON parsing or field extraction, it gracefully returns an empty string.
142
+ """
143
+ try:
144
+ jsons = extract_top_level_json(s)
145
+ if len(jsons) == 0:
146
+ return ""
147
+ for j in jsons:
148
+ try:
149
+ json_data = json.loads(j)
150
+ if isinstance(json_data, dict):
151
+ if f in json_data:
152
+ return json_data[f]
153
+ elif isinstance(json_data, list):
154
+ # Some responses wrap candidate JSON objects in a list; scan them.
155
+ for item in json_data:
156
+ if isinstance(item, dict) and f in item:
157
+ return item[f]
158
+ except (json.JSONDecodeError, TypeError, KeyError):
159
+ # If this specific JSON fails to parse, continue to next candidate
160
+ continue
161
+ except Exception:
162
+ # Catch any unexpected errors to ensure we never crash
163
+ pass
153
164
 
154
165
  return ""
155
166
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langroid
3
- Version: 0.59.10
3
+ Version: 0.59.12
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  Author-email: Prasad Chalasani <pchalasani@gmail.com>
6
6
  License: MIT
@@ -15,7 +15,7 @@ langroid/agent/xml_tool_message.py,sha256=b5zyYuQS8bduVNoe-jOjy7iLB5VOMvbGfD_A5Z
15
15
  langroid/agent/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  langroid/agent/callbacks/chainlit.py,sha256=nRCTkYDgTiBPP8Cg2ct8dLUBDevLMO4w0jv0GfQQq2U,20960
17
17
  langroid/agent/special/__init__.py,sha256=gik_Xtm_zV7U9s30Mn8UX3Gyuy4jTjQe9zjiE3HWmEo,1273
18
- langroid/agent/special/doc_chat_agent.py,sha256=tUr4qex3OjqF32zeyvTOnNgUP1wdpe5hoZ8bH1IisJQ,68962
18
+ langroid/agent/special/doc_chat_agent.py,sha256=O59btjW3o8pIl6VhLiJ5b9MsajRSq6fDtlxenpKfus8,69146
19
19
  langroid/agent/special/doc_chat_task.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  langroid/agent/special/lance_doc_chat_agent.py,sha256=6pIqi2DF-MvYYN3-blsdUgulYnOBTl7I21T7wPAt1zM,10413
21
21
  langroid/agent/special/lance_tools.py,sha256=3j7Hsyf3-H9ccTXjyNOcnMnpJ7r1lXnqDLSMQgFa7ZI,2114
@@ -94,7 +94,7 @@ langroid/parsing/document_parser.py,sha256=cUcp4JKS_LpsjX7OqnGBhHorDHx7FG5pvKGjR
94
94
  langroid/parsing/file_attachment.py,sha256=f-MBRCI58XsCqJDH2HwTWwTQxLbYsDrOLgjrM1kw3XE,7350
95
95
  langroid/parsing/md_parser.py,sha256=8LX9RDRWV1dZSYa-uBD8-whC_L6UYco-AQUxIuviqEk,21656
96
96
  langroid/parsing/para_sentence_split.py,sha256=AJBzZojP3zpB-_IMiiHismhqcvkrVBQ3ZINoQyx_bE4,2000
97
- langroid/parsing/parse_json.py,sha256=W_8dMD1SFohcQjbOBvRR1NrdO-F6xdhNVDmUX1nNdsY,5052
97
+ langroid/parsing/parse_json.py,sha256=NxECxPndhIpyVdSYFEe7QpoIQktMPrFjo1i5P139dNA,5608
98
98
  langroid/parsing/parser.py,sha256=IcwmVLlAae5LiKZ9OFhrnVOoHxcnsV7feFSHQiFfoi4,16112
99
99
  langroid/parsing/pdf_utils.py,sha256=QogxU_B1N3WSLyZ9PEcJDaJoZShKs7CPQRVyF1V2DiE,3143
100
100
  langroid/parsing/repo_loader.py,sha256=oB0TNifWCaqvlj7C0U76C4NZT7b94BbGkVX_-mrcH_4,30220
@@ -139,7 +139,7 @@ langroid/vector_store/pineconedb.py,sha256=7V0Bkt4ZrOR3V90tdXvdFmyNGuww7SFdyPq7-
139
139
  langroid/vector_store/postgres.py,sha256=TY_VshimwFZglYgKYm7Qn1F-dCSL8GsXRTgmh7VTe9c,16110
140
140
  langroid/vector_store/qdrantdb.py,sha256=mqxMOrcLAQpl0opuL8vXhdIt6ppv2zYyAvddHZoEW0Y,19184
141
141
  langroid/vector_store/weaviatedb.py,sha256=BS95bxVKNYfQc9VPb85a1HlcgnXfAkgMzjydnjCgRHc,11853
142
- langroid-0.59.10.dist-info/METADATA,sha256=LnA1YOq6VYfYsfnBONaSbzMPti5M_2IySKSNSBbdOIA,66518
143
- langroid-0.59.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
144
- langroid-0.59.10.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
145
- langroid-0.59.10.dist-info/RECORD,,
142
+ langroid-0.59.12.dist-info/METADATA,sha256=ESfzLcUoh0cCmabOtjQ5rOdCJOjbI9ZZmHZuhtpT4w8,66518
143
+ langroid-0.59.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
144
+ langroid-0.59.12.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
145
+ langroid-0.59.12.dist-info/RECORD,,