langroid 0.2.4__tar.gz → 0.2.6__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 (135) hide show
  1. {langroid-0.2.4 → langroid-0.2.6}/PKG-INFO +10 -9
  2. {langroid-0.2.4 → langroid-0.2.6}/README.md +7 -7
  3. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/task.py +26 -4
  4. {langroid-0.2.4 → langroid-0.2.6}/langroid/mytypes.py +7 -1
  5. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/constants.py +7 -2
  6. langroid-0.2.6/langroid/utils/web/__init__.py +0 -0
  7. {langroid-0.2.4 → langroid-0.2.6}/pyproject.toml +2 -2
  8. {langroid-0.2.4 → langroid-0.2.6}/LICENSE +0 -0
  9. {langroid-0.2.4 → langroid-0.2.6}/langroid/__init__.py +0 -0
  10. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/__init__.py +0 -0
  11. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/base.py +0 -0
  12. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/batch.py +0 -0
  13. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/callbacks/__init__.py +0 -0
  14. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/callbacks/chainlit.py +0 -0
  15. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/chat_agent.py +0 -0
  16. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/chat_document.py +0 -0
  17. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/helpers.py +0 -0
  18. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/junk +0 -0
  19. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/openai_assistant.py +0 -0
  20. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/__init__.py +0 -0
  21. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/doc_chat_agent.py +0 -0
  22. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
  23. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/lance_rag/__init__.py +0 -0
  24. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
  25. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
  26. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
  27. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/lance_tools.py +0 -0
  28. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/neo4j/__init__.py +0 -0
  29. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
  30. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
  31. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/neo4j/utils/__init__.py +0 -0
  32. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/neo4j/utils/system_message.py +0 -0
  33. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/relevance_extractor_agent.py +0 -0
  34. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/retriever_agent.py +0 -0
  35. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/sql/__init__.py +0 -0
  36. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
  37. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/sql/utils/__init__.py +0 -0
  38. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
  39. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
  40. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/sql/utils/system_message.py +0 -0
  41. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/sql/utils/tools.py +0 -0
  42. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/special/table_chat_agent.py +0 -0
  43. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/tool_message.py +0 -0
  44. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/tools/__init__.py +0 -0
  45. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
  46. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/tools/extract_tool.py +0 -0
  47. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/tools/generator_tool.py +0 -0
  48. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/tools/google_search_tool.py +0 -0
  49. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/tools/metaphor_search_tool.py +0 -0
  50. /langroid-0.2.4/langroid/agent_config.py → /langroid-0.2.6/langroid/agent/tools/note_tool.py +0 -0
  51. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/tools/recipient_tool.py +0 -0
  52. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/tools/retrieval_tool.py +0 -0
  53. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/tools/rewind_tool.py +0 -0
  54. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/tools/run_python_code.py +0 -0
  55. {langroid-0.2.4 → langroid-0.2.6}/langroid/agent/tools/segment_extract_tool.py +0 -0
  56. /langroid-0.2.4/langroid/embedding_models/protoc/__init__.py → /langroid-0.2.6/langroid/agent_config.py +0 -0
  57. {langroid-0.2.4 → langroid-0.2.6}/langroid/cachedb/__init__.py +0 -0
  58. {langroid-0.2.4 → langroid-0.2.6}/langroid/cachedb/base.py +0 -0
  59. {langroid-0.2.4 → langroid-0.2.6}/langroid/cachedb/momento_cachedb.py +0 -0
  60. {langroid-0.2.4 → langroid-0.2.6}/langroid/cachedb/redis_cachedb.py +0 -0
  61. {langroid-0.2.4 → langroid-0.2.6}/langroid/embedding_models/__init__.py +0 -0
  62. {langroid-0.2.4 → langroid-0.2.6}/langroid/embedding_models/base.py +0 -0
  63. {langroid-0.2.4 → langroid-0.2.6}/langroid/embedding_models/clustering.py +0 -0
  64. {langroid-0.2.4 → langroid-0.2.6}/langroid/embedding_models/models.py +0 -0
  65. {langroid-0.2.4/langroid/utils/llms → langroid-0.2.6/langroid/embedding_models/protoc}/__init__.py +0 -0
  66. {langroid-0.2.4 → langroid-0.2.6}/langroid/embedding_models/protoc/embeddings.proto +0 -0
  67. {langroid-0.2.4 → langroid-0.2.6}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
  68. {langroid-0.2.4 → langroid-0.2.6}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
  69. {langroid-0.2.4 → langroid-0.2.6}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
  70. {langroid-0.2.4 → langroid-0.2.6}/langroid/embedding_models/remote_embeds.py +0 -0
  71. {langroid-0.2.4 → langroid-0.2.6}/langroid/exceptions.py +0 -0
  72. {langroid-0.2.4 → langroid-0.2.6}/langroid/language_models/__init__.py +0 -0
  73. {langroid-0.2.4 → langroid-0.2.6}/langroid/language_models/azure_openai.py +0 -0
  74. {langroid-0.2.4 → langroid-0.2.6}/langroid/language_models/base.py +0 -0
  75. {langroid-0.2.4 → langroid-0.2.6}/langroid/language_models/config.py +0 -0
  76. {langroid-0.2.4 → langroid-0.2.6}/langroid/language_models/mock_lm.py +0 -0
  77. {langroid-0.2.4 → langroid-0.2.6}/langroid/language_models/openai_gpt.py +0 -0
  78. {langroid-0.2.4 → langroid-0.2.6}/langroid/language_models/prompt_formatter/__init__.py +0 -0
  79. {langroid-0.2.4 → langroid-0.2.6}/langroid/language_models/prompt_formatter/base.py +0 -0
  80. {langroid-0.2.4 → langroid-0.2.6}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
  81. {langroid-0.2.4 → langroid-0.2.6}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
  82. {langroid-0.2.4 → langroid-0.2.6}/langroid/language_models/utils.py +0 -0
  83. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/__init__.py +0 -0
  84. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/agent_chats.py +0 -0
  85. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/code-parsing.md +0 -0
  86. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/code_parser.py +0 -0
  87. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/config.py +0 -0
  88. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/document_parser.py +0 -0
  89. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/image_text.py +0 -0
  90. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/para_sentence_split.py +0 -0
  91. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/parse_json.py +0 -0
  92. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/parser.py +0 -0
  93. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/repo_loader.py +0 -0
  94. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/routing.py +0 -0
  95. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/search.py +0 -0
  96. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/spider.py +0 -0
  97. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/table_loader.py +0 -0
  98. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/url_loader.py +0 -0
  99. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/url_loader_cookies.py +0 -0
  100. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/urls.py +0 -0
  101. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/utils.py +0 -0
  102. {langroid-0.2.4 → langroid-0.2.6}/langroid/parsing/web_search.py +0 -0
  103. {langroid-0.2.4 → langroid-0.2.6}/langroid/prompts/__init__.py +0 -0
  104. {langroid-0.2.4 → langroid-0.2.6}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
  105. {langroid-0.2.4 → langroid-0.2.6}/langroid/prompts/dialog.py +0 -0
  106. {langroid-0.2.4 → langroid-0.2.6}/langroid/prompts/prompts_config.py +0 -0
  107. {langroid-0.2.4 → langroid-0.2.6}/langroid/prompts/templates.py +0 -0
  108. {langroid-0.2.4 → langroid-0.2.6}/langroid/pydantic_v1/__init__.py +0 -0
  109. {langroid-0.2.4 → langroid-0.2.6}/langroid/pydantic_v1/main.py +0 -0
  110. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/__init__.py +0 -0
  111. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/algorithms/__init__.py +0 -0
  112. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/algorithms/graph.py +0 -0
  113. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/configuration.py +0 -0
  114. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/docker.py +0 -0
  115. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/globals.py +0 -0
  116. {langroid-0.2.4/langroid/utils/web → langroid-0.2.6/langroid/utils/llms}/__init__.py +0 -0
  117. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/llms/strings.py +0 -0
  118. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/logging.py +0 -0
  119. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/object_registry.py +0 -0
  120. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/output/__init__.py +0 -0
  121. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/output/citations.py +0 -0
  122. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/output/printing.py +0 -0
  123. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/output/status.py +0 -0
  124. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/pandas_utils.py +0 -0
  125. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/pydantic_utils.py +0 -0
  126. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/system.py +0 -0
  127. {langroid-0.2.4 → langroid-0.2.6}/langroid/utils/web/login.py +0 -0
  128. {langroid-0.2.4 → langroid-0.2.6}/langroid/vector_store/__init__.py +0 -0
  129. {langroid-0.2.4 → langroid-0.2.6}/langroid/vector_store/base.py +0 -0
  130. {langroid-0.2.4 → langroid-0.2.6}/langroid/vector_store/chromadb.py +0 -0
  131. {langroid-0.2.4 → langroid-0.2.6}/langroid/vector_store/lancedb.py +0 -0
  132. {langroid-0.2.4 → langroid-0.2.6}/langroid/vector_store/meilisearch.py +0 -0
  133. {langroid-0.2.4 → langroid-0.2.6}/langroid/vector_store/momento.py +0 -0
  134. {langroid-0.2.4 → langroid-0.2.6}/langroid/vector_store/qdrant_cloud.py +0 -0
  135. {langroid-0.2.4 → langroid-0.2.6}/langroid/vector_store/qdrantdb.py +0 -0
@@ -1,15 +1,16 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langroid
3
- Version: 0.2.4
3
+ Version: 0.2.6
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.10,<3.12
8
+ Requires-Python: >=3.10,<4.0
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
13
14
  Provides-Extra: all
14
15
  Provides-Extra: chainlit
15
16
  Provides-Extra: chromadb
@@ -149,7 +150,7 @@ This Multi-Agent paradigm is inspired by the
149
150
  `Langroid` is a fresh take on LLM app-development, where considerable thought has gone
150
151
  into simplifying the developer experience; it does not use `Langchain`.
151
152
 
152
- Companies are using/adapting Langroid in production. Here is a quote from one of them:
153
+ 📢 Companies are using/adapting Langroid in **production**. Here is a quote:
153
154
 
154
155
  >[Nullify](https://www.nullify.ai) uses AI Agents for secure software development.
155
156
  > It finds, prioritizes and fixes vulnerabilities. We have internally adapted Langroid's multi-agent orchestration framework in production, after evaluating CrewAI, Autogen, LangChain, Langflow, etc. We found Langroid to be far superior to those frameworks in terms of ease of setup and flexibility. Langroid's Agent and Task abstractions are intuitive, well thought out, and provide a great developer experience. We wanted the quickest way to get something in production. With other frameworks it would have taken us weeks, but with Langroid we got to good results in minutes. Highly recommended! <br> -- Jacky Wong, Head of AI at Nullify.
@@ -460,17 +461,17 @@ such as [ollama](https://github.com/ollama), [oobabooga](https://github.com/ooba
460
461
  - **Observability, Logging, Lineage:** Langroid generates detailed logs of multi-agent interactions and
461
462
  maintains provenance/lineage of messages, so that you can trace back
462
463
  the origin of a message.
463
- - **[Tools/Plugins/Function-calling](https://langroid.github.io/langroid/quick-start/chat-agent-tool/)**: Langroid supports OpenAI's recently
464
- released [function calling](https://platform.openai.com/docs/guides/gpt/function-calling)
465
- feature. In addition, Langroid has its own native equivalent, which we
466
- call **tools** (also known as "plugins" in other contexts). Function
467
- calling and tools have the same developer-facing interface, implemented
464
+ - **[Tools/Plugins/Function-calling](https://langroid.github.io/langroid/quick-start/chat-agent-tool/)**:
465
+ Langroid supports OpenAI's [function calling](https://platform.openai.com/docs/guides/gpt/function-calling), as
466
+ well as an equivalent `ToolMessage` mechanism which works with
467
+ any LLM, not just OpenAI's.
468
+ Function calling and tools have the same developer-facing interface, implemented
468
469
  using [Pydantic](https://docs.pydantic.dev/latest/),
469
470
  which makes it very easy to define tools/functions and enable agents
470
471
  to use them. Benefits of using Pydantic are that you never have to write
471
472
  complex JSON specs for function calling, and when the LLM
472
473
  hallucinates malformed JSON, the Pydantic error message is sent back to
473
- the LLM so it can fix it!
474
+ the LLM so it can fix it.
474
475
 
475
476
  ---
476
477
 
@@ -46,7 +46,7 @@ This Multi-Agent paradigm is inspired by the
46
46
  `Langroid` is a fresh take on LLM app-development, where considerable thought has gone
47
47
  into simplifying the developer experience; it does not use `Langchain`.
48
48
 
49
- Companies are using/adapting Langroid in production. Here is a quote from one of them:
49
+ 📢 Companies are using/adapting Langroid in **production**. Here is a quote:
50
50
 
51
51
  >[Nullify](https://www.nullify.ai) uses AI Agents for secure software development.
52
52
  > It finds, prioritizes and fixes vulnerabilities. We have internally adapted Langroid's multi-agent orchestration framework in production, after evaluating CrewAI, Autogen, LangChain, Langflow, etc. We found Langroid to be far superior to those frameworks in terms of ease of setup and flexibility. Langroid's Agent and Task abstractions are intuitive, well thought out, and provide a great developer experience. We wanted the quickest way to get something in production. With other frameworks it would have taken us weeks, but with Langroid we got to good results in minutes. Highly recommended! <br> -- Jacky Wong, Head of AI at Nullify.
@@ -357,17 +357,17 @@ such as [ollama](https://github.com/ollama), [oobabooga](https://github.com/ooba
357
357
  - **Observability, Logging, Lineage:** Langroid generates detailed logs of multi-agent interactions and
358
358
  maintains provenance/lineage of messages, so that you can trace back
359
359
  the origin of a message.
360
- - **[Tools/Plugins/Function-calling](https://langroid.github.io/langroid/quick-start/chat-agent-tool/)**: Langroid supports OpenAI's recently
361
- released [function calling](https://platform.openai.com/docs/guides/gpt/function-calling)
362
- feature. In addition, Langroid has its own native equivalent, which we
363
- call **tools** (also known as "plugins" in other contexts). Function
364
- calling and tools have the same developer-facing interface, implemented
360
+ - **[Tools/Plugins/Function-calling](https://langroid.github.io/langroid/quick-start/chat-agent-tool/)**:
361
+ Langroid supports OpenAI's [function calling](https://platform.openai.com/docs/guides/gpt/function-calling), as
362
+ well as an equivalent `ToolMessage` mechanism which works with
363
+ any LLM, not just OpenAI's.
364
+ Function calling and tools have the same developer-facing interface, implemented
365
365
  using [Pydantic](https://docs.pydantic.dev/latest/),
366
366
  which makes it very easy to define tools/functions and enable agents
367
367
  to use them. Benefits of using Pydantic are that you never have to write
368
368
  complex JSON specs for function calling, and when the LLM
369
369
  hallucinates malformed JSON, the Pydantic error message is sent back to
370
- the LLM so it can fix it!
370
+ the LLM so it can fix it.
371
371
 
372
372
  ---
373
373
 
@@ -41,7 +41,6 @@ from langroid.parsing.routing import parse_addressed_message
41
41
  from langroid.pydantic_v1 import BaseModel
42
42
  from langroid.utils.configuration import settings
43
43
  from langroid.utils.constants import (
44
- AT, # regex for start of an addressed recipient e.g. "@"
45
44
  DONE,
46
45
  NO_ANSWER,
47
46
  PASS,
@@ -74,6 +73,18 @@ class TaskConfig(BaseModel):
74
73
  inf_loop_wait_factor (int): wait this * cycle_len msgs before loop-check
75
74
  restart_subtask_run (bool): whether to restart *every* run of this task
76
75
  when run as a subtask.
76
+ addressing_prefix (str): prefix an agent can use to address other
77
+ agents, or entities of the agent. E.g., if this is "@", the addressing
78
+ string would be "@Alice", or "@user", "@llm", "@agent", etc.
79
+ If this is an empty string, then addressing is disabled.
80
+ Default is empty string "".
81
+ CAUTION: this is a deprecated practice, since normal prompts
82
+ can accidentally contain such addressing prefixes, and will break
83
+ your runs. This could happen especially when your prompt/context
84
+ contains code, but of course could occur in normal text as well.
85
+ Instead, use the `RecipientTool` to have agents address other agents or
86
+ entities. If you do choose to use `addressing_prefix`, the recommended
87
+ setting is to use `langroid.utils.constants.AT`, which currently is "|@|".
77
88
  """
78
89
 
79
90
  inf_loop_cycle_len: int = 10
@@ -81,6 +92,7 @@ class TaskConfig(BaseModel):
81
92
  inf_loop_wait_factor: int = 5
82
93
  restart_as_subtask: bool = False
83
94
  logs_dir: str = "logs"
95
+ addressing_prefix: str = ""
84
96
 
85
97
 
86
98
  class Task:
@@ -1190,7 +1202,10 @@ class Task:
1190
1202
  if result is None:
1191
1203
  return None
1192
1204
  # if result content starts with @name, set recipient to name
1193
- is_pass, recipient, content = parse_routing(result)
1205
+ is_pass, recipient, content = parse_routing(
1206
+ result,
1207
+ addressing_prefix=self.config.addressing_prefix,
1208
+ )
1194
1209
  if is_pass is None: # no routing, i.e. neither PASS nor SEND
1195
1210
  return result
1196
1211
  if is_pass:
@@ -1648,6 +1663,7 @@ class Task:
1648
1663
 
1649
1664
  def parse_routing(
1650
1665
  msg: ChatDocument | str,
1666
+ addressing_prefix: str = "",
1651
1667
  ) -> Tuple[bool | None, str | None, str | None]:
1652
1668
  """
1653
1669
  Parse routing instruction if any, of the form:
@@ -1656,6 +1672,8 @@ def parse_routing(
1656
1672
  @<recipient> <content> (send content to recipient)
1657
1673
  Args:
1658
1674
  msg (ChatDocument|str|None): message to parse
1675
+ addressing_prefix (str): prefix to address other agents or entities,
1676
+ (e.g. "@". See documentation of `TaskConfig` for details).
1659
1677
  Returns:
1660
1678
  Tuple[bool|None, str|None, str|None]:
1661
1679
  bool: true=PASS, false=SEND, or None if neither
@@ -1682,8 +1700,12 @@ def parse_routing(
1682
1700
  else:
1683
1701
  return False, addressee, content_to_send
1684
1702
  if (
1685
- AT in content
1686
- and (addressee_content := parse_addressed_message(content, AT))[0] is not None
1703
+ addressing_prefix != ""
1704
+ and addressing_prefix in content
1705
+ and (addressee_content := parse_addressed_message(content, addressing_prefix))[
1706
+ 0
1707
+ ]
1708
+ is not None
1687
1709
  ):
1688
1710
  (addressee, content_to_send) = addressee_content
1689
1711
  # if no content then treat same as PASS_TO
@@ -22,11 +22,17 @@ class Entity(str, Enum):
22
22
  SYSTEM = "System"
23
23
 
24
24
  def __eq__(self, other: object) -> bool:
25
- """Allow case-insensitive comparison with strings."""
25
+ """Allow case-insensitive equality (==) comparison with strings."""
26
+ if other is None:
27
+ return False
26
28
  if isinstance(other, str):
27
29
  return self.value.lower() == other.lower()
28
30
  return super().__eq__(other)
29
31
 
32
+ def __ne__(self, other: object) -> bool:
33
+ """Allow case-insensitive non-equality (!=) comparison with strings."""
34
+ return not self.__eq__(other)
35
+
30
36
  def __hash__(self) -> int:
31
37
  """Override this to ensure hashability of the enum,
32
38
  so it can be used sets and dictionary keys.
@@ -18,6 +18,11 @@ DONE = "DONE"
18
18
  USER_QUIT_STRINGS = ["q", "x", "quit", "exit", "bye", DONE]
19
19
  PASS = "__PASS__"
20
20
  PASS_TO = PASS + ":"
21
- SEND_TO = "SEND:"
21
+ SEND_TO = "__SEND__:"
22
22
  TOOL = "TOOL"
23
- AT = "@"
23
+ # This is a recommended setting for TaskConfig.addressing_prefix if using it at all;
24
+ # prefer to use `RecipientTool` to allow agents addressing others.
25
+ # Caution the AT string should NOT contain any 'word' characters, i.e.
26
+ # it no letters, digits or underscores.
27
+ # See tests/main/test_msg_routing for example usage
28
+ AT = "|@|"
File without changes
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langroid"
3
- version = "0.2.4"
3
+ version = "0.2.6"
4
4
  description = "Harness LLMs with Multi-Agent Programming"
5
5
  authors = ["Prasad Chalasani <pchalasani@gmail.com>"]
6
6
  readme = "README.md"
@@ -10,7 +10,7 @@ include = ["pyproject.toml"]
10
10
 
11
11
  # =============== MAIN DEPS ==============
12
12
  [tool.poetry.dependencies]
13
- python = ">=3.10,<3.12"
13
+ python = "^3.10"
14
14
 
15
15
  # =========== OPTIONALS ==============================
16
16
  chromadb = {version=">=0.4.21, <=0.4.23", optional=true}
File without changes
File without changes
File without changes