langroid 0.22.4__py3-none-any.whl → 0.22.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/agent/base.py CHANGED
@@ -142,7 +142,7 @@ class Agent(ABC):
142
142
  self.llm_tools_handled: Set[str] = set()
143
143
  self.llm_tools_usable: Set[str] = set()
144
144
  self.llm_tools_known: Set[str] = set() # all known tools, handled/used or not
145
- self.interactive: bool | None = None
145
+ self.interactive: bool = True # may be modified by Task wrapper
146
146
  self.token_stats_str = ""
147
147
  self.default_human_response: Optional[str] = None
148
148
  self._indent = ""
@@ -645,10 +645,11 @@ class Agent(ABC):
645
645
  need_human_response = (
646
646
  isinstance(msg, ChatDocument) and msg.metadata.recipient == Entity.USER
647
647
  )
648
+ default_user_msg = (
649
+ (self.default_human_response or "null") if need_human_response else ""
650
+ )
648
651
 
649
- interactive = self.interactive or settings.interactive
650
-
651
- if not interactive and not need_human_response:
652
+ if not self.interactive and not need_human_response:
652
653
  return None
653
654
  elif self.default_human_response is not None:
654
655
  user_msg = self.default_human_response
@@ -669,6 +670,8 @@ class Agent(ABC):
669
670
  tool_ids = []
670
671
  if msg is not None and isinstance(msg, ChatDocument):
671
672
  tool_ids = msg.metadata.tool_ids
673
+
674
+ user_msg = user_msg.strip() or default_user_msg.strip()
672
675
  # only return non-None result if user_msg not empty
673
676
  if not user_msg:
674
677
  return None
langroid/agent/task.py CHANGED
@@ -1023,9 +1023,11 @@ class Task:
1023
1023
  found_response = False
1024
1024
  # (responder, result) from a responder who explicitly said NO_ANSWER
1025
1025
  no_answer_response: None | Tuple[Responder, ChatDocument] = None
1026
+ n_non_responders = 0
1026
1027
  for r in responders:
1027
1028
  self.is_pass_thru = False
1028
1029
  if not self._can_respond(r):
1030
+ n_non_responders += 1
1029
1031
  # create dummy msg for logging
1030
1032
  log_doc = ChatDocument(
1031
1033
  content="[CANNOT RESPOND]",
@@ -1038,6 +1040,9 @@ class Task:
1038
1040
  # no need to register this dummy msg in ObjectRegistry
1039
1041
  ChatDocument.delete_id(log_doc.id())
1040
1042
  self.log_message(r, log_doc)
1043
+ if n_non_responders == len(responders):
1044
+ # don't stay in this "non-response" loop forever
1045
+ break
1041
1046
  continue
1042
1047
  self.human_tried = r == Entity.USER
1043
1048
  result = self.response(r, turns)
langroid/parsing/utils.py CHANGED
@@ -31,6 +31,10 @@ def download_nltk_resource(resource: str) -> None:
31
31
  nltk.download(resource, quiet=True)
32
32
 
33
33
 
34
+ # Download punkt_tab resource at module import
35
+ download_nltk_resource("punkt_tab")
36
+ download_nltk_resource("gutenberg")
37
+
34
38
  T = TypeVar("T")
35
39
 
36
40
 
@@ -46,7 +50,6 @@ def batched(iterable: Iterable[T], n: int) -> Iterable[Sequence[T]]:
46
50
 
47
51
  def generate_random_sentences(k: int) -> str:
48
52
  # Load the sample text
49
- download_nltk_resource("gutenberg")
50
53
 
51
54
  from nltk.corpus import gutenberg
52
55
 
@@ -17,8 +17,6 @@ class Settings(BaseSettings):
17
17
  stream: bool = True # stream output?
18
18
  cache: bool = True # use cache?
19
19
  cache_type: Literal["redis", "fakeredis", "momento", "none"] = "redis" # cache type
20
- interactive: bool = True # interactive mode?
21
- gpt3_5: bool = True # use GPT-3.5?
22
20
  chat_model: str = "" # language model name, e.g. litellm/ollama/llama2
23
21
  quiet: bool = False # quiet mode (i.e. suppress all output)?
24
22
  notebook: bool = False # running in a notebook?
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langroid
3
- Version: 0.22.4
3
+ Version: 0.22.5
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  License: MIT
6
6
  Author: Prasad Chalasani
@@ -68,7 +68,7 @@ Requires-Dist: metaphor-python (>=0.1.23,<0.2.0) ; extra == "all" or extra == "m
68
68
  Requires-Dist: momento (>=1.10.2,<1.21) ; extra == "momento"
69
69
  Requires-Dist: neo4j (>=5.14.1,<6.0.0) ; extra == "all" or extra == "neo4j"
70
70
  Requires-Dist: nest-asyncio (>=1.6.0,<2.0.0)
71
- Requires-Dist: nltk (>=3.8.1,<4.0.0)
71
+ Requires-Dist: nltk (>=3.8.2,<4.0.0)
72
72
  Requires-Dist: onnxruntime (>=1.16.1,<2.0.0)
73
73
  Requires-Dist: openai (>=1.45.0,<2.0.0)
74
74
  Requires-Dist: pandas (>=2.0.3,<3.0.0)
@@ -1,6 +1,6 @@
1
1
  langroid/__init__.py,sha256=z_fCOLQJPOw3LLRPBlFB5-2HyCjpPgQa4m4iY5Fvb8Y,1800
2
2
  langroid/agent/__init__.py,sha256=ll0Cubd2DZ-fsCMl7e10hf9ZjFGKzphfBco396IKITY,786
3
- langroid/agent/base.py,sha256=IatVtrdstxMcreeVSndNoChFKxrJIEkYRpNruBxRQ7M,67112
3
+ langroid/agent/base.py,sha256=-lMv0XHO7ya1P6IW_xb439Mx8WhFEPgt1AmcMe200ds,67268
4
4
  langroid/agent/batch.py,sha256=QZdlt1563hx4l3AXrCaGovE-PNG93M3DsvQAbDzdiS8,13705
5
5
  langroid/agent/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  langroid/agent/callbacks/chainlit.py,sha256=JJXI3UGTyTDg2FFath4rqY1GyUo_0pbVBt8CZpvdtn4,23289
@@ -38,7 +38,7 @@ langroid/agent/special/sql/utils/system_message.py,sha256=qKLHkvQWRQodTtPLPxr1GS
38
38
  langroid/agent/special/sql/utils/tools.py,sha256=vFYysk6Vi7HJjII8B4RitA3pt_z3gkSglDNdhNVMiFc,1332
39
39
  langroid/agent/special/table_chat_agent.py,sha256=d9v2wsblaRx7oMnKhLV7uO_ujvk9gh59pSGvBXyeyNc,9659
40
40
  langroid/agent/structured_message.py,sha256=y7pud1EgRNeTFZlJmBkLmwME3yQJ_IYik-Xds9kdZbY,282
41
- langroid/agent/task.py,sha256=0ewueaJBXvOvlSAHipL21xqgcpiGySDHr-A_Ov0WyQ8,86659
41
+ langroid/agent/task.py,sha256=BdLNWFQqA9X-9ZtUIC2NwmRrPAX7GB0mAC0aXDzK0Uk,86877
42
42
  langroid/agent/tool_message.py,sha256=bjBSk1N1IgqqYGmOy6O97zPFMSaUdEK7r8ZjOaJwoeE,11335
43
43
  langroid/agent/tools/__init__.py,sha256=IMgCte-_ZIvCkozGQmvMqxIw7_nKLKzD78ccJL1bnQU,804
44
44
  langroid/agent/tools/duckduckgo_search_tool.py,sha256=NhsCaGZkdv28nja7yveAhSK_w6l_Ftym8agbrdzqgfo,1935
@@ -100,7 +100,7 @@ langroid/parsing/table_loader.py,sha256=qNM4obT_0Y4tjrxNBCNUYjKQ9oETCZ7FbolKBTcz
100
100
  langroid/parsing/url_loader.py,sha256=Na2TBlKuQkloZzkE2d7xl6mh9olS3CbpgCsJbJ-xhIA,4472
101
101
  langroid/parsing/url_loader_cookies.py,sha256=Lg4sNpRz9MByWq2mde6T0hKv68VZSV3mtMjNEHuFeSU,2327
102
102
  langroid/parsing/urls.py,sha256=XjpaV5onG7gKQ5iQeFTzHSw5P08Aqw0g-rMUu61lR6s,7988
103
- langroid/parsing/utils.py,sha256=pbSAbfwA28EBNESpQRJee_Kp1b44qze-2_2b9qJOKfM,12646
103
+ langroid/parsing/utils.py,sha256=kb9DlHaG1iQB-6JagH1C26SdCNNf8U-2XaXia4_dWCw,12726
104
104
  langroid/parsing/web_search.py,sha256=wGycU86N3nsZ78E9iS-BIm5NWueDgoknojABE0_1LRA,4886
105
105
  langroid/prompts/__init__.py,sha256=RW11vK6jiLPuaUh4GpeFvstti73gkm8_rDMtrbo2YsU,142
106
106
  langroid/prompts/chat-gpt4-system-prompt.md,sha256=Q3uLCJTPQvmUkZN2XDnkBC7M2K3X0F3C3GIQBaFvYvw,5329
@@ -115,7 +115,7 @@ langroid/utils/.chainlit/translations/en-US.json,sha256=DAFz2HjOFFfboCStrUfKFg2B
115
115
  langroid/utils/__init__.py,sha256=Sruos2tB4G7Tn0vlblvYlX9PEGR0plI2uE0PJ4d_EC4,353
116
116
  langroid/utils/algorithms/__init__.py,sha256=WylYoZymA0fnzpB4vrsH_0n7WsoLhmuZq8qxsOCjUpM,41
117
117
  langroid/utils/algorithms/graph.py,sha256=JbdpPnUOhw4-D6O7ou101JLA3xPCD0Lr3qaPoFCaRfo,2866
118
- langroid/utils/configuration.py,sha256=LgjHGB0qgKKTwBaVt84APiqvJbz6pLwylUvHWYmzyP0,3303
118
+ langroid/utils/configuration.py,sha256=V3RS8OP7AC0_bDKczxfortD0F5H3cnsZL0ulKBxuoHU,3213
119
119
  langroid/utils/constants.py,sha256=vKIdkAJwyPT-bRA5MDPiOl7-EppBRmewRBIOcdXi4I4,959
120
120
  langroid/utils/docker.py,sha256=kJQOLTgM0x9j9pgIIqp0dZNZCTvoUDhp6i8tYBq1Jr0,1105
121
121
  langroid/utils/git_utils.py,sha256=WnflJ3R3owhlD0LNdSJakcKhExcEehE1UW5jYVQl8JY,7955
@@ -142,8 +142,8 @@ langroid/vector_store/meilisearch.py,sha256=6frB7GFWeWmeKzRfLZIvzRjllniZ1cYj3Hmh
142
142
  langroid/vector_store/momento.py,sha256=qR-zBF1RKVHQZPZQYW_7g-XpTwr46p8HJuYPCkfJbM4,10534
143
143
  langroid/vector_store/qdrant_cloud.py,sha256=3im4Mip0QXLkR6wiqVsjV1QvhSElfxdFSuDKddBDQ-4,188
144
144
  langroid/vector_store/qdrantdb.py,sha256=v88lqFkepADvlN6lByUj9I4NEKa9X9lWH16uTPPbYrE,17457
145
- pyproject.toml,sha256=OKFg1VTiVXkPi5MgYHzp5RLR0wltiTHWJeb7xo7Kis4,7488
146
- langroid-0.22.4.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
147
- langroid-0.22.4.dist-info/METADATA,sha256=nE0exrJpSqQR5MCdjEvLDifMqoCTngZJOn4PvKfqlX8,57107
148
- langroid-0.22.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
149
- langroid-0.22.4.dist-info/RECORD,,
145
+ pyproject.toml,sha256=m9VWz7kgw5OWUlJj_B-LP9ov67jCSioaLfCLTVdi-jg,7488
146
+ langroid-0.22.5.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
147
+ langroid-0.22.5.dist-info/METADATA,sha256=B7F4ITogUktXDfPGpjQB1RDNe2TV1se5JF321Jc2tNY,57107
148
+ langroid-0.22.5.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
149
+ langroid-0.22.5.dist-info/RECORD,,
pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langroid"
3
- version = "0.22.4"
3
+ version = "0.22.5"
4
4
  description = "Harness LLMs with Multi-Agent Programming"
5
5
  authors = ["Prasad Chalasani <pchalasani@gmail.com>"]
6
6
  readme = "README.md"
@@ -62,7 +62,7 @@ fakeredis = "^2.12.1"
62
62
  faker = "^18.9.0"
63
63
  requests = "^2.31.0"
64
64
  pyparsing = "^3.0.9"
65
- nltk = "^3.8.1"
65
+ nltk = "^3.8.2"
66
66
  qdrant-client = "^1.8.0"
67
67
  pydantic = ">=1,<3"
68
68
  pandas = "^2.0.3"