langroid 0.25.0__tar.gz → 0.26.0__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.
Files changed (148) hide show
  1. {langroid-0.25.0 → langroid-0.26.0}/PKG-INFO +2 -2
  2. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/callbacks/chainlit.py +57 -129
  3. {langroid-0.25.0 → langroid-0.26.0}/pyproject.toml +3 -3
  4. {langroid-0.25.0 → langroid-0.26.0}/LICENSE +0 -0
  5. {langroid-0.25.0 → langroid-0.26.0}/README.md +0 -0
  6. {langroid-0.25.0 → langroid-0.26.0}/langroid/__init__.py +0 -0
  7. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/__init__.py +0 -0
  8. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/base.py +0 -0
  9. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/batch.py +0 -0
  10. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/callbacks/__init__.py +0 -0
  11. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/chat_agent.py +0 -0
  12. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/chat_document.py +0 -0
  13. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/helpers.py +0 -0
  14. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/junk +0 -0
  15. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/openai_assistant.py +0 -0
  16. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/__init__.py +0 -0
  17. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/arangodb/__init__.py +0 -0
  18. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/arangodb/arangodb_agent.py +0 -0
  19. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/arangodb/system_messages.py +0 -0
  20. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/arangodb/tools.py +0 -0
  21. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/arangodb/utils.py +0 -0
  22. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/doc_chat_agent.py +0 -0
  23. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
  24. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/lance_rag/__init__.py +0 -0
  25. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
  26. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
  27. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
  28. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/lance_tools.py +0 -0
  29. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/neo4j/__init__.py +0 -0
  30. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
  31. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
  32. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/neo4j/system_messages.py +0 -0
  33. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/neo4j/tools.py +0 -0
  34. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/relevance_extractor_agent.py +0 -0
  35. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/retriever_agent.py +0 -0
  36. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/sql/__init__.py +0 -0
  37. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
  38. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/sql/utils/__init__.py +0 -0
  39. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
  40. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
  41. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/sql/utils/system_message.py +0 -0
  42. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/sql/utils/tools.py +0 -0
  43. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/special/table_chat_agent.py +0 -0
  44. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/structured_message.py +0 -0
  45. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/task.py +0 -0
  46. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/tool_message.py +0 -0
  47. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/tools/__init__.py +0 -0
  48. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
  49. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/tools/file_tools.py +0 -0
  50. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/tools/google_search_tool.py +0 -0
  51. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/tools/metaphor_search_tool.py +0 -0
  52. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/tools/orchestration.py +0 -0
  53. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/tools/recipient_tool.py +0 -0
  54. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/tools/retrieval_tool.py +0 -0
  55. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/tools/rewind_tool.py +0 -0
  56. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/tools/segment_extract_tool.py +0 -0
  57. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/typed_task.py +0 -0
  58. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent/xml_tool_message.py +0 -0
  59. {langroid-0.25.0 → langroid-0.26.0}/langroid/agent_config.py +0 -0
  60. {langroid-0.25.0 → langroid-0.26.0}/langroid/cachedb/__init__.py +0 -0
  61. {langroid-0.25.0 → langroid-0.26.0}/langroid/cachedb/base.py +0 -0
  62. {langroid-0.25.0 → langroid-0.26.0}/langroid/cachedb/momento_cachedb.py +0 -0
  63. {langroid-0.25.0 → langroid-0.26.0}/langroid/cachedb/redis_cachedb.py +0 -0
  64. {langroid-0.25.0 → langroid-0.26.0}/langroid/embedding_models/__init__.py +0 -0
  65. {langroid-0.25.0 → langroid-0.26.0}/langroid/embedding_models/base.py +0 -0
  66. {langroid-0.25.0 → langroid-0.26.0}/langroid/embedding_models/clustering.py +0 -0
  67. {langroid-0.25.0 → langroid-0.26.0}/langroid/embedding_models/models.py +0 -0
  68. {langroid-0.25.0 → langroid-0.26.0}/langroid/embedding_models/protoc/__init__.py +0 -0
  69. {langroid-0.25.0 → langroid-0.26.0}/langroid/embedding_models/protoc/embeddings.proto +0 -0
  70. {langroid-0.25.0 → langroid-0.26.0}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
  71. {langroid-0.25.0 → langroid-0.26.0}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
  72. {langroid-0.25.0 → langroid-0.26.0}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
  73. {langroid-0.25.0 → langroid-0.26.0}/langroid/embedding_models/remote_embeds.py +0 -0
  74. {langroid-0.25.0 → langroid-0.26.0}/langroid/exceptions.py +0 -0
  75. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/.chainlit/config.toml +0 -0
  76. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/.chainlit/translations/en-US.json +0 -0
  77. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/__init__.py +0 -0
  78. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/azure_openai.py +0 -0
  79. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/base.py +0 -0
  80. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/config.py +0 -0
  81. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/mock_lm.py +0 -0
  82. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/openai_gpt.py +0 -0
  83. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/prompt_formatter/__init__.py +0 -0
  84. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/prompt_formatter/base.py +0 -0
  85. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
  86. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
  87. {langroid-0.25.0 → langroid-0.26.0}/langroid/language_models/utils.py +0 -0
  88. {langroid-0.25.0 → langroid-0.26.0}/langroid/mytypes.py +0 -0
  89. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/__init__.py +0 -0
  90. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/agent_chats.py +0 -0
  91. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/code-parsing.md +0 -0
  92. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/code_parser.py +0 -0
  93. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/config.py +0 -0
  94. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/document_parser.py +0 -0
  95. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/image_text.py +0 -0
  96. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/para_sentence_split.py +0 -0
  97. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/parse_json.py +0 -0
  98. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/parser.py +0 -0
  99. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/repo_loader.py +0 -0
  100. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/routing.py +0 -0
  101. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/search.py +0 -0
  102. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/spider.py +0 -0
  103. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/table_loader.py +0 -0
  104. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/url_loader.py +0 -0
  105. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/url_loader_cookies.py +0 -0
  106. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/urls.py +0 -0
  107. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/utils.py +0 -0
  108. {langroid-0.25.0 → langroid-0.26.0}/langroid/parsing/web_search.py +0 -0
  109. {langroid-0.25.0 → langroid-0.26.0}/langroid/prompts/__init__.py +0 -0
  110. {langroid-0.25.0 → langroid-0.26.0}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
  111. {langroid-0.25.0 → langroid-0.26.0}/langroid/prompts/dialog.py +0 -0
  112. {langroid-0.25.0 → langroid-0.26.0}/langroid/prompts/prompts_config.py +0 -0
  113. {langroid-0.25.0 → langroid-0.26.0}/langroid/prompts/templates.py +0 -0
  114. {langroid-0.25.0 → langroid-0.26.0}/langroid/py.typed +0 -0
  115. {langroid-0.25.0 → langroid-0.26.0}/langroid/pydantic_v1/__init__.py +0 -0
  116. {langroid-0.25.0 → langroid-0.26.0}/langroid/pydantic_v1/main.py +0 -0
  117. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/.chainlit/config.toml +0 -0
  118. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/.chainlit/translations/en-US.json +0 -0
  119. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/__init__.py +0 -0
  120. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/algorithms/__init__.py +0 -0
  121. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/algorithms/graph.py +0 -0
  122. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/configuration.py +0 -0
  123. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/constants.py +0 -0
  124. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/docker.py +0 -0
  125. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/git_utils.py +0 -0
  126. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/globals.py +0 -0
  127. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/llms/__init__.py +0 -0
  128. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/llms/strings.py +0 -0
  129. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/logging.py +0 -0
  130. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/object_registry.py +0 -0
  131. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/output/__init__.py +0 -0
  132. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/output/citations.py +0 -0
  133. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/output/printing.py +0 -0
  134. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/output/status.py +0 -0
  135. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/pandas_utils.py +0 -0
  136. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/pydantic_utils.py +0 -0
  137. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/system.py +0 -0
  138. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/types.py +0 -0
  139. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/web/__init__.py +0 -0
  140. {langroid-0.25.0 → langroid-0.26.0}/langroid/utils/web/login.py +0 -0
  141. {langroid-0.25.0 → langroid-0.26.0}/langroid/vector_store/__init__.py +0 -0
  142. {langroid-0.25.0 → langroid-0.26.0}/langroid/vector_store/base.py +0 -0
  143. {langroid-0.25.0 → langroid-0.26.0}/langroid/vector_store/chromadb.py +0 -0
  144. {langroid-0.25.0 → langroid-0.26.0}/langroid/vector_store/lancedb.py +0 -0
  145. {langroid-0.25.0 → langroid-0.26.0}/langroid/vector_store/meilisearch.py +0 -0
  146. {langroid-0.25.0 → langroid-0.26.0}/langroid/vector_store/momento.py +0 -0
  147. {langroid-0.25.0 → langroid-0.26.0}/langroid/vector_store/qdrant_cloud.py +0 -0
  148. {langroid-0.25.0 → langroid-0.26.0}/langroid/vector_store/qdrantdb.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langroid
3
- Version: 0.25.0
3
+ Version: 0.26.0
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  License: MIT
6
6
  Author: Prasad Chalasani
@@ -42,7 +42,7 @@ Requires-Dist: arango-datasets (>=1.2.2,<2.0.0) ; extra == "all" or extra == "ar
42
42
  Requires-Dist: async-generator (>=1.10,<2.0)
43
43
  Requires-Dist: bs4 (>=0.0.1,<0.0.2)
44
44
  Requires-Dist: cerebras-cloud-sdk (>=1.1.0,<2.0.0)
45
- Requires-Dist: chainlit (==1.1.202) ; extra == "all" or extra == "chainlit"
45
+ Requires-Dist: chainlit (>=1.3.2,<2.0.0) ; extra == "all" or extra == "chainlit"
46
46
  Requires-Dist: chromadb (>=0.4.21,<=0.4.23) ; extra == "vecdbs" or extra == "all" or extra == "chromadb"
47
47
  Requires-Dist: colorlog (>=6.7.0,<7.0.0)
48
48
  Requires-Dist: docstring-parser (>=0.15,<0.16)
@@ -16,7 +16,6 @@ except ImportError:
16
16
  raise LangroidImportError("chainlit", "chainlit")
17
17
 
18
18
  from chainlit import run_sync
19
- from chainlit.config import config
20
19
  from chainlit.logger import logger
21
20
 
22
21
  import langroid as lr
@@ -227,7 +226,6 @@ class ChainlitAgentCallbacks:
227
226
  def __init__(
228
227
  self,
229
228
  agent: lr.Agent,
230
- msg: cl.Message = None,
231
229
  config: ChainlitCallbackConfig = ChainlitCallbackConfig(),
232
230
  ):
233
231
  """Add callbacks to the agent, and save the initial message,
@@ -240,6 +238,7 @@ class ChainlitAgentCallbacks:
240
238
  agent.callbacks.show_llm_response = self.show_llm_response
241
239
  agent.callbacks.show_agent_response = self.show_agent_response
242
240
  agent.callbacks.get_user_response = self.get_user_response
241
+ agent.callbacks.get_user_response_async = self.get_user_response_async
243
242
  agent.callbacks.get_last_step = self.get_last_step
244
243
  agent.callbacks.set_parent_agent = self.set_parent_agent
245
244
  agent.callbacks.show_error_message = self.show_error_message
@@ -250,8 +249,6 @@ class ChainlitAgentCallbacks:
250
249
  # We don't want to suppress LLM output in async + streaming,
251
250
  # since we often use chainlit async callbacks to display LLM output
252
251
  self.agent.llm.config.async_stream_quiet = False
253
- if msg is not None:
254
- self.show_first_user_message(msg)
255
252
 
256
253
  def _get_parent_id(self) -> str | None:
257
254
  """Get step id under which we need to nest the current step:
@@ -281,10 +278,11 @@ class ChainlitAgentCallbacks:
281
278
 
282
279
  def start_llm_stream(self) -> Callable[[str], None]:
283
280
  """Returns a streaming fn that can be passed to the LLM class"""
284
- self.stream = cl.Step(
281
+ self.stream = cl.Message(
282
+ content="",
285
283
  id=self.curr_step.id if self.curr_step is not None else None,
286
- name=self._entity_name("llm"),
287
- type="llm",
284
+ author=self._entity_name("llm"),
285
+ type="assistant_message",
288
286
  parent_id=self._get_parent_id(),
289
287
  )
290
288
  self.last_step = self.stream
@@ -296,7 +294,6 @@ class ChainlitAgentCallbacks:
296
294
  under parent {self._get_parent_id()}
297
295
  """
298
296
  )
299
- run_sync(self.stream.send()) # type: ignore
300
297
 
301
298
  def stream_token(t: str) -> None:
302
299
  if self.stream is None:
@@ -307,10 +304,11 @@ class ChainlitAgentCallbacks:
307
304
 
308
305
  async def start_llm_stream_async(self) -> Callable[[str], None]:
309
306
  """Returns a streaming fn that can be passed to the LLM class"""
310
- self.stream = cl.Step(
307
+ self.stream = cl.Message(
308
+ content="",
311
309
  id=self.curr_step.id if self.curr_step is not None else None,
312
- name=self._entity_name("llm"),
313
- type="llm",
310
+ author=self._entity_name("llm"),
311
+ type="assistant_message",
314
312
  parent_id=self._get_parent_id(),
315
313
  )
316
314
  self.last_step = self.stream
@@ -320,9 +318,8 @@ class ChainlitAgentCallbacks:
320
318
  Starting LLM stream for {self.agent.config.name}
321
319
  id = {self.stream.id}
322
320
  under parent {self._get_parent_id()}
323
- """
321
+ """
324
322
  )
325
- await self.stream.send() # type: ignore
326
323
 
327
324
  async def stream_token(t: str) -> None:
328
325
  if self.stream is None:
@@ -346,14 +343,14 @@ class ChainlitAgentCallbacks:
346
343
  else:
347
344
  run_sync(self.stream.update()) # type: ignore
348
345
  stream_id = self.stream.id if content else None
349
- step = cl.Step(
346
+ step = cl.Message(
347
+ content=textwrap.dedent(content) or NO_ANSWER,
350
348
  id=stream_id,
351
- name=self._entity_name("llm", tool=is_tool),
352
- type="llm",
349
+ author=self._entity_name("llm", tool=is_tool),
350
+ type="assistant_message",
353
351
  parent_id=self._get_parent_id(),
354
352
  language="json" if is_tool else None,
355
353
  )
356
- step.output = textwrap.dedent(content) or NO_ANSWER
357
354
  logger.info(
358
355
  f"""
359
356
  Finish STREAM LLM response for {self.agent.config.name}
@@ -371,16 +368,16 @@ class ChainlitAgentCallbacks:
371
368
  language: str | None = None,
372
369
  ) -> None:
373
370
  """Show non-streaming LLM response."""
374
- step = cl.Step(
371
+ step = cl.Message(
372
+ content=textwrap.dedent(content) or NO_ANSWER,
375
373
  id=self.curr_step.id if self.curr_step is not None else None,
376
- name=self._entity_name("llm", tool=is_tool, cached=cached),
377
- type="llm",
378
- parent_id=self._get_parent_id(),
374
+ author=self._entity_name("llm", tool=is_tool, cached=cached),
375
+ type="assistant_message",
379
376
  language=language or ("json" if is_tool else None),
377
+ parent_id=self._get_parent_id(),
380
378
  )
381
379
  self.last_step = step
382
380
  self.curr_step = None
383
- step.output = textwrap.dedent(content) or NO_ANSWER
384
381
  logger.info(
385
382
  f"""
386
383
  Showing NON-STREAM LLM response for {self.agent.config.name}
@@ -391,34 +388,31 @@ class ChainlitAgentCallbacks:
391
388
  run_sync(step.send()) # type: ignore
392
389
 
393
390
  def show_error_message(self, error: str) -> None:
394
- """Show error message as a step."""
395
- step = cl.Step(
396
- name=self.agent.config.name + f"({ERROR})",
391
+ """Show error message."""
392
+ step = cl.Message(
393
+ content=error,
394
+ author=self.agent.config.name + f"({ERROR})",
397
395
  type="run",
398
- parent_id=self._get_parent_id(),
399
396
  language="text",
397
+ parent_id=self._get_parent_id(),
400
398
  )
401
399
  self.last_step = step
402
- step.output = error
403
400
  run_sync(step.send())
404
401
 
405
402
  def show_agent_response(self, content: str, language="text") -> None:
406
- """Show message from agent (typically tool handler).
407
- Agent response can be considered as a "step"
408
- between LLM response and user response
409
- """
410
- step = cl.Step(
403
+ """Show message from agent (typically tool handler)."""
404
+ if language == "text":
405
+ content = wrap_text_preserving_structure(content, width=90)
406
+ step = cl.Message(
407
+ content=content,
411
408
  id=self.curr_step.id if self.curr_step is not None else None,
412
- name=self._entity_name("agent"),
409
+ author=self._entity_name("agent"),
413
410
  type="tool",
414
- parent_id=self._get_parent_id(),
415
411
  language=language,
412
+ parent_id=self._get_parent_id(),
416
413
  )
417
- if language == "text":
418
- content = wrap_text_preserving_structure(content, width=90)
419
414
  self.last_step = step
420
415
  self.curr_step = None
421
- step.output = content
422
416
  logger.info(
423
417
  f"""
424
418
  Showing AGENT response for {self.agent.config.name}
@@ -433,13 +427,13 @@ class ChainlitAgentCallbacks:
433
427
  so that the UI displays a spinner while the process is running."""
434
428
  if self.curr_step is not None:
435
429
  run_sync(self.curr_step.remove()) # type: ignore
436
- step = cl.Step(
437
- name=self._entity_name(entity),
430
+ step = cl.Message(
431
+ content="",
432
+ author=self._entity_name(entity),
438
433
  type="run",
439
434
  parent_id=self._get_parent_id(),
440
435
  language="text",
441
436
  )
442
- step.output = ""
443
437
  self.last_step = step
444
438
  self.curr_step = step
445
439
  logger.info(
@@ -503,54 +497,23 @@ class ChainlitAgentCallbacks:
503
497
  return "" # process the "feedback" case here
504
498
 
505
499
  def get_user_response(self, prompt: str) -> str:
506
- """Ask for user response, wait for it, and return it,
507
- as a cl.Step rather than as a cl.Message so we can nest it
508
- under the parent step.
509
- """
510
- return run_sync(self.ask_user_step(prompt=prompt, suppress_values=["c"]))
500
+ """Ask for user response, wait for it, and return it"""
511
501
 
512
- def show_user_response(self, message: str) -> None:
513
- """Show user response as a step."""
514
- step = cl.Step(
515
- id=cl.context.current_step.id,
516
- name=self._entity_name("user"),
517
- type="run",
518
- parent_id=self._get_parent_id(),
519
- )
520
- step.output = message
521
- logger.info(
522
- f"""
523
- Showing USER response for {self.agent.config.name}
524
- id = {step.id}
525
- under parent {self._get_parent_id()}
526
- """
527
- )
528
- run_sync(step.send())
502
+ return run_sync(self.ask_user(prompt=prompt, suppress_values=["c"]))
529
503
 
530
- def show_first_user_message(self, msg: cl.Message):
531
- """Show first user message as a step."""
532
- step = cl.Step(
533
- id=msg.id,
534
- name=self._entity_name("user"),
535
- type="run",
536
- parent_id=self._get_parent_id(),
537
- )
538
- self.last_step = step
539
- step.output = msg.content
540
- run_sync(step.update())
504
+ async def get_user_response_async(self, prompt: str) -> str:
505
+ """Ask for user response, wait for it, and return it"""
506
+
507
+ return await self.ask_user(prompt=prompt, suppress_values=["c"])
541
508
 
542
- async def ask_user_step(
509
+ async def ask_user(
543
510
  self,
544
511
  prompt: str,
545
512
  timeout: int = USER_TIMEOUT,
546
513
  suppress_values: List[str] = ["c"],
547
514
  ) -> str:
548
515
  """
549
- Ask user for input, as a step nested under parent_id.
550
- Rather than rely entirely on AskUserMessage (which doesn't let us
551
- nest the question + answer under a step), we instead create fake
552
- steps for the question and answer, and only rely on AskUserMessage
553
- with an empty prompt to await user response.
516
+ Ask user for input.
554
517
 
555
518
  Args:
556
519
  prompt (str): Prompt to display to user
@@ -561,31 +524,16 @@ class ChainlitAgentCallbacks:
561
524
  Returns:
562
525
  str: User response
563
526
  """
564
-
565
- # save hide_cot status to restore later
566
- # (We should probably use a ctx mgr for this)
567
- hide_cot = config.ui.hide_cot
568
-
569
- # force hide_cot to False so that the user question + response is visible
570
- config.ui.hide_cot = False
571
-
572
- if prompt != "":
573
- # Create a question step to ask user
574
- question_step = cl.Step(
575
- name=f"{self.agent.config.name} (AskUser ❓)",
576
- type="run",
577
- parent_id=self._get_parent_id(),
578
- )
579
- question_step.output = prompt
580
- await question_step.send() # type: ignore
581
-
582
- # Use AskUserMessage to await user response,
583
- # but with an empty prompt so the question is not visible,
584
- # but still pauses for user input in the input box.
585
- res = await cl.AskUserMessage(
586
- content="",
527
+ ask_msg = cl.AskUserMessage(
528
+ content=prompt,
529
+ author=f"{self.agent.config.name}(Awaiting user input...)",
530
+ type="assistant_message",
587
531
  timeout=timeout,
588
- ).send()
532
+ )
533
+ res = await ask_msg.send()
534
+ if prompt == "":
535
+ # if there was no actual prompt, clear the row from the UI for clarity.
536
+ await ask_msg.remove()
589
537
 
590
538
  if res is None:
591
539
  run_sync(
@@ -595,31 +543,10 @@ class ChainlitAgentCallbacks:
595
543
  )
596
544
  return "x"
597
545
 
598
- # The above will try to display user response in res
599
- # but we create fake step with same id as res and
600
- # erase it using empty output so it's not displayed
601
- step = cl.Step(
602
- id=res["id"],
603
- name="TempUserResponse",
604
- type="run",
605
- parent_id=self._get_parent_id(),
606
- )
607
- step.output = ""
608
- await step.update() # type: ignore
609
-
610
546
  # Finally, reproduce the user response at right nesting level
611
547
  if res["output"] in suppress_values:
612
- config.ui.hide_cot = hide_cot # restore original value
613
548
  return ""
614
549
 
615
- step = cl.Step(
616
- name=self._entity_name(entity="user"),
617
- type="run",
618
- parent_id=self._get_parent_id(),
619
- )
620
- step.output = res["output"]
621
- await step.send() # type: ignore
622
- config.ui.hide_cot = hide_cot # restore original value
623
550
  return res["output"]
624
551
 
625
552
 
@@ -632,13 +559,12 @@ class ChainlitTaskCallbacks(ChainlitAgentCallbacks):
632
559
  def __init__(
633
560
  self,
634
561
  task: lr.Task,
635
- msg: cl.Message = None,
636
562
  config: ChainlitCallbackConfig = ChainlitCallbackConfig(),
637
563
  ):
638
564
  """Inject callbacks recursively, ensuring msg is passed to the
639
565
  top-level agent"""
640
566
 
641
- super().__init__(task.agent, msg, config)
567
+ super().__init__(task.agent, config)
642
568
  self._inject_callbacks(task)
643
569
  self.task = task
644
570
  if config.show_subtask_response:
@@ -659,12 +585,14 @@ class ChainlitTaskCallbacks(ChainlitAgentCallbacks):
659
585
  """Show sub-task response as a step, nested at the right level."""
660
586
 
661
587
  # The step should nest under the calling agent's last step
662
- step = cl.Step(
663
- name=self.task.agent.config.name + f"( ⏎ From {task.agent.config.name})",
588
+ step = cl.Message(
589
+ content=content or NO_ANSWER,
590
+ author=(
591
+ self.task.agent.config.name + f"( ⏎ From {task.agent.config.name})"
592
+ ),
664
593
  type="run",
665
594
  parent_id=self._get_parent_id(),
666
595
  language="json" if is_tool else None,
667
596
  )
668
- step.output = content or NO_ANSWER
669
597
  self.last_step = step
670
598
  run_sync(step.send())
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langroid"
3
- version = "0.25.0"
3
+ version = "0.26.0"
4
4
  description = "Harness LLMs with Multi-Agent Programming"
5
5
  authors = ["Prasad Chalasani <pchalasani@gmail.com>"]
6
6
  readme = "README.md"
@@ -22,7 +22,7 @@ pymysql = {version = "^1.1.0", optional = true}
22
22
  meilisearch-python-sdk = {version="^2.2.3", optional=true}
23
23
  litellm = {version = "^1.30.1", optional = true}
24
24
  metaphor-python = {version = "^0.1.23", optional = true}
25
- chainlit = {version = "1.1.202", optional = true}
25
+ chainlit = {version = "^1.3.2", optional = true}
26
26
  python-socketio = {version="^5.11.0", optional=true}
27
27
  neo4j = {version = "^5.14.1", optional = true}
28
28
  huggingface-hub = {version="^0.21.2", optional=true}
@@ -242,7 +242,7 @@ lint.select = [
242
242
  lint.exclude = ["docs/**", ".venv", "venv", "examples/**", "examples_dev", "langroid/utils/web", "notebooks", "__init__.py", "langroid/embedding_models/protoc/*"]
243
243
  lint.fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
244
244
  lint.unfixable = []
245
- lint.extend-ignore = ["F821","F401"]
245
+ lint.extend-ignore = ["F821", "F401"]
246
246
 
247
247
  [tool.pytest.ini_options]
248
248
  filterwarnings = ["ignore::DeprecationWarning"]
File without changes
File without changes
File without changes
File without changes
File without changes