langroid 0.1.225__tar.gz → 0.1.226__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 (127) hide show
  1. {langroid-0.1.225 → langroid-0.1.226}/PKG-INFO +2 -1
  2. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/doc_chat_agent.py +11 -11
  3. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/document_parser.py +30 -6
  4. {langroid-0.1.225 → langroid-0.1.226}/pyproject.toml +2 -1
  5. {langroid-0.1.225 → langroid-0.1.226}/LICENSE +0 -0
  6. {langroid-0.1.225 → langroid-0.1.226}/README.md +0 -0
  7. {langroid-0.1.225 → langroid-0.1.226}/langroid/__init__.py +0 -0
  8. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/__init__.py +0 -0
  9. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/base.py +0 -0
  10. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/batch.py +0 -0
  11. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/callbacks/__init__.py +0 -0
  12. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/callbacks/chainlit.py +0 -0
  13. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/chat_agent.py +0 -0
  14. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/chat_document.py +0 -0
  15. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/helpers.py +0 -0
  16. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/junk +0 -0
  17. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/openai_assistant.py +0 -0
  18. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/__init__.py +0 -0
  19. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
  20. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/lance_rag/__init__.py +0 -0
  21. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
  22. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
  23. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
  24. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/lance_tools.py +0 -0
  25. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/neo4j/__init__.py +0 -0
  26. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
  27. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
  28. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/neo4j/utils/__init__.py +0 -0
  29. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/neo4j/utils/system_message.py +0 -0
  30. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/relevance_extractor_agent.py +0 -0
  31. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/retriever_agent.py +0 -0
  32. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/sql/__init__.py +0 -0
  33. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
  34. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/sql/utils/__init__.py +0 -0
  35. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
  36. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
  37. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/sql/utils/system_message.py +0 -0
  38. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/sql/utils/tools.py +0 -0
  39. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/special/table_chat_agent.py +0 -0
  40. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/task.py +0 -0
  41. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/tool_message.py +0 -0
  42. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/tools/__init__.py +0 -0
  43. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
  44. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/tools/extract_tool.py +0 -0
  45. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/tools/generator_tool.py +0 -0
  46. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/tools/google_search_tool.py +0 -0
  47. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/tools/metaphor_search_tool.py +0 -0
  48. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/tools/recipient_tool.py +0 -0
  49. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/tools/run_python_code.py +0 -0
  50. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/tools/sciphi_search_rag_tool.py +0 -0
  51. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent/tools/segment_extract_tool.py +0 -0
  52. {langroid-0.1.225 → langroid-0.1.226}/langroid/agent_config.py +0 -0
  53. {langroid-0.1.225 → langroid-0.1.226}/langroid/cachedb/__init__.py +0 -0
  54. {langroid-0.1.225 → langroid-0.1.226}/langroid/cachedb/base.py +0 -0
  55. {langroid-0.1.225 → langroid-0.1.226}/langroid/cachedb/momento_cachedb.py +0 -0
  56. {langroid-0.1.225 → langroid-0.1.226}/langroid/cachedb/redis_cachedb.py +0 -0
  57. {langroid-0.1.225 → langroid-0.1.226}/langroid/embedding_models/__init__.py +0 -0
  58. {langroid-0.1.225 → langroid-0.1.226}/langroid/embedding_models/base.py +0 -0
  59. {langroid-0.1.225 → langroid-0.1.226}/langroid/embedding_models/clustering.py +0 -0
  60. {langroid-0.1.225 → langroid-0.1.226}/langroid/embedding_models/models.py +0 -0
  61. {langroid-0.1.225 → langroid-0.1.226}/langroid/embedding_models/protoc/embeddings.proto +0 -0
  62. {langroid-0.1.225 → langroid-0.1.226}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
  63. {langroid-0.1.225 → langroid-0.1.226}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
  64. {langroid-0.1.225 → langroid-0.1.226}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
  65. {langroid-0.1.225 → langroid-0.1.226}/langroid/embedding_models/remote_embeds.py +0 -0
  66. {langroid-0.1.225 → langroid-0.1.226}/langroid/language_models/__init__.py +0 -0
  67. {langroid-0.1.225 → langroid-0.1.226}/langroid/language_models/azure_openai.py +0 -0
  68. {langroid-0.1.225 → langroid-0.1.226}/langroid/language_models/base.py +0 -0
  69. {langroid-0.1.225 → langroid-0.1.226}/langroid/language_models/config.py +0 -0
  70. {langroid-0.1.225 → langroid-0.1.226}/langroid/language_models/openai_assistants.py +0 -0
  71. {langroid-0.1.225 → langroid-0.1.226}/langroid/language_models/openai_gpt.py +0 -0
  72. {langroid-0.1.225 → langroid-0.1.226}/langroid/language_models/prompt_formatter/__init__.py +0 -0
  73. {langroid-0.1.225 → langroid-0.1.226}/langroid/language_models/prompt_formatter/base.py +0 -0
  74. {langroid-0.1.225 → langroid-0.1.226}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
  75. {langroid-0.1.225 → langroid-0.1.226}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
  76. {langroid-0.1.225 → langroid-0.1.226}/langroid/language_models/utils.py +0 -0
  77. {langroid-0.1.225 → langroid-0.1.226}/langroid/mytypes.py +0 -0
  78. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/__init__.py +0 -0
  79. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/agent_chats.py +0 -0
  80. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/code-parsing.md +0 -0
  81. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/code_parser.py +0 -0
  82. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/config.py +0 -0
  83. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/image_text.py +0 -0
  84. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/para_sentence_split.py +0 -0
  85. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/parse_json.py +0 -0
  86. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/parser.py +0 -0
  87. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/repo_loader.py +0 -0
  88. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/search.py +0 -0
  89. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/spider.py +0 -0
  90. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/table_loader.py +0 -0
  91. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/url_loader.py +0 -0
  92. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/url_loader_cookies.py +0 -0
  93. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/urls.py +0 -0
  94. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/utils.py +0 -0
  95. {langroid-0.1.225 → langroid-0.1.226}/langroid/parsing/web_search.py +0 -0
  96. {langroid-0.1.225 → langroid-0.1.226}/langroid/prompts/__init__.py +0 -0
  97. {langroid-0.1.225 → langroid-0.1.226}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
  98. {langroid-0.1.225 → langroid-0.1.226}/langroid/prompts/dialog.py +0 -0
  99. {langroid-0.1.225 → langroid-0.1.226}/langroid/prompts/prompts_config.py +0 -0
  100. {langroid-0.1.225 → langroid-0.1.226}/langroid/prompts/templates.py +0 -0
  101. {langroid-0.1.225 → langroid-0.1.226}/langroid/prompts/transforms.py +0 -0
  102. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/__init__.py +0 -0
  103. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/algorithms/__init__.py +0 -0
  104. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/algorithms/graph.py +0 -0
  105. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/configuration.py +0 -0
  106. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/constants.py +0 -0
  107. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/docker.py +0 -0
  108. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/globals.py +0 -0
  109. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/llms/__init__.py +0 -0
  110. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/llms/strings.py +0 -0
  111. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/logging.py +0 -0
  112. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/output/__init__.py +0 -0
  113. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/output/printing.py +0 -0
  114. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/output/status.py +0 -0
  115. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/pandas_utils.py +0 -0
  116. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/pydantic_utils.py +0 -0
  117. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/system.py +0 -0
  118. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/web/__init__.py +0 -0
  119. {langroid-0.1.225 → langroid-0.1.226}/langroid/utils/web/login.py +0 -0
  120. {langroid-0.1.225 → langroid-0.1.226}/langroid/vector_store/__init__.py +0 -0
  121. {langroid-0.1.225 → langroid-0.1.226}/langroid/vector_store/base.py +0 -0
  122. {langroid-0.1.225 → langroid-0.1.226}/langroid/vector_store/chromadb.py +0 -0
  123. {langroid-0.1.225 → langroid-0.1.226}/langroid/vector_store/lancedb.py +0 -0
  124. {langroid-0.1.225 → langroid-0.1.226}/langroid/vector_store/meilisearch.py +0 -0
  125. {langroid-0.1.225 → langroid-0.1.226}/langroid/vector_store/momento.py +0 -0
  126. {langroid-0.1.225 → langroid-0.1.226}/langroid/vector_store/qdrant_cloud.py +0 -0
  127. {langroid-0.1.225 → langroid-0.1.226}/langroid/vector_store/qdrantdb.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langroid
3
- Version: 0.1.225
3
+ Version: 0.1.226
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  License: MIT
6
6
  Author: Prasad Chalasani
@@ -101,6 +101,7 @@ Requires-Dist: tiktoken (>=0.5.1,<0.6.0)
101
101
  Requires-Dist: torch (==2.0.0) ; extra == "hf-embeddings"
102
102
  Requires-Dist: trafilatura (>=1.5.0,<2.0.0)
103
103
  Requires-Dist: typer (>=0.9.0,<0.10.0)
104
+ Requires-Dist: types-pillow (>=10.2.0.20240406,<11.0.0.0)
104
105
  Requires-Dist: types-pyyaml (>=6.0.12.20240311,<7.0.0.0)
105
106
  Requires-Dist: types-redis (>=4.5.5.2,<5.0.0.0)
106
107
  Requires-Dist: types-requests (>=2.31.0.1,<3.0.0.0)
@@ -66,7 +66,7 @@ logger = logging.getLogger(__name__)
66
66
 
67
67
  DEFAULT_DOC_CHAT_INSTRUCTIONS = """
68
68
  Your task is to answer questions about various documents.
69
- You will be given various passages from these documents, and asked to answer questions
69
+ You will be given various passages from these documents, and asked to answer questions
70
70
  about them, or summarize them into coherent answers.
71
71
  """
72
72
 
@@ -76,7 +76,7 @@ You are a helpful assistant, helping me understand a collection of documents.
76
76
 
77
77
  has_sentence_transformers = False
78
78
  try:
79
- from sentence_transformer import SentenceTransformer # noqa: F401
79
+ from sentence_transformers import SentenceTransformer # noqa: F401
80
80
 
81
81
  has_sentence_transformers = True
82
82
  except ImportError:
@@ -339,7 +339,7 @@ class DocChatAgent(ChatAgent):
339
339
  n_paths = len(paths)
340
340
  print(
341
341
  f"""
342
- [green]I have processed the following {n_urls} URLs
342
+ [green]I have processed the following {n_urls} URLs
343
343
  and {n_paths} docs into {n_splits} parts:
344
344
  """.strip()
345
345
  )
@@ -443,7 +443,7 @@ class DocChatAgent(ChatAgent):
443
443
  if content not in df.columns:
444
444
  raise ValueError(
445
445
  f"""
446
- Content column {content} not in dataframe,
446
+ Content column {content} not in dataframe,
447
447
  so we cannot ingest into the DocChatAgent.
448
448
  Please specify the `content` parameter as a suitable
449
449
  text-based column in the dataframe.
@@ -816,12 +816,12 @@ class DocChatAgent(ChatAgent):
816
816
  # Adjust this prompt depending on context.
817
817
  answer = self.llm_response_forget(
818
818
  f"""
819
- Give an ideal answer to the following query,
820
- in up to 3 sentences. Do not explain yourself,
821
- and do not apologize, just show
819
+ Give an ideal answer to the following query,
820
+ in up to 3 sentences. Do not explain yourself,
821
+ and do not apologize, just show
822
822
  a good possible answer, even if you do not have any information.
823
823
  Preface your answer with "HYPOTHETICAL ANSWER: "
824
-
824
+
825
825
  QUERY: {query}
826
826
  """
827
827
  ).content
@@ -1293,9 +1293,9 @@ class DocChatAgent(ChatAgent):
1293
1293
  logger.warning(
1294
1294
  """
1295
1295
  No docs to summarize! Perhaps you are re-using a previously
1296
- defined collection?
1296
+ defined collection?
1297
1297
  In that case, we don't have access to the original docs.
1298
- To create a summary, use a new collection, and specify a list of docs.
1298
+ To create a summary, use a new collection, and specify a list of docs.
1299
1299
  """
1300
1300
  )
1301
1301
  return None
@@ -1318,7 +1318,7 @@ class DocChatAgent(ChatAgent):
1318
1318
  )
1319
1319
  prompt = f"""
1320
1320
  {instruction}
1321
-
1321
+
1322
1322
  FULL TEXT:
1323
1323
  {full_text}
1324
1324
  """.strip()
@@ -25,7 +25,29 @@ class DocumentType(str, Enum):
25
25
  TXT = "txt"
26
26
 
27
27
 
28
+ def find_last_full_char(possible_unicode: bytes) -> int:
29
+ """
30
+ Find the index of the last full character in a byte string.
31
+ Args:
32
+ possible_unicode (bytes): The bytes to check.
33
+ Returns:
34
+ int: The index of the last full unicode character.
35
+ """
36
+
37
+ for i in range(len(possible_unicode) - 1, 0, -1):
38
+ if (possible_unicode[i] & 0xC0) != 0x80:
39
+ return i
40
+ return 0
41
+
42
+
28
43
  def is_plain_text(path_or_bytes: str | bytes) -> bool:
44
+ """
45
+ Check if a file is plain text by attempting to decode it as UTF-8.
46
+ Args:
47
+ path_or_bytes (str|bytes): The file path or bytes object.
48
+ Returns:
49
+ bool: True if the file is plain text, False otherwise.
50
+ """
29
51
  if isinstance(path_or_bytes, str):
30
52
  if path_or_bytes.startswith(("http://", "https://")):
31
53
  response = requests.get(path_or_bytes)
@@ -38,6 +60,8 @@ def is_plain_text(path_or_bytes: str | bytes) -> bool:
38
60
  content = path_or_bytes[:1024]
39
61
  try:
40
62
  # Attempt to decode the content as UTF-8
63
+ content = content[: find_last_full_char(content)]
64
+
41
65
  _ = content.decode("utf-8")
42
66
  # Additional checks can go here, e.g., to verify that the content
43
67
  # doesn't contain too many unusual characters for it to be considered text
@@ -431,14 +455,14 @@ class ImagePdfParser(DocumentParser):
431
455
 
432
456
  def iterate_pages(
433
457
  self,
434
- ) -> Generator[Tuple[int, Image], None, None]:
458
+ ) -> Generator[Tuple[int, Image], None, None]: # type: ignore
435
459
  from pdf2image import convert_from_bytes
436
460
 
437
461
  images = convert_from_bytes(self.doc_bytes.getvalue())
438
462
  for i, image in enumerate(images):
439
463
  yield i, image
440
464
 
441
- def extract_text_from_page(self, page: Image) -> str:
465
+ def extract_text_from_page(self, page: Image) -> str: # type: ignore
442
466
  """
443
467
  Extract text from a given `pdf2image` page.
444
468
 
@@ -466,7 +490,7 @@ class UnstructuredPDFParser(DocumentParser):
466
490
  raise ImportError(
467
491
  """
468
492
  The `unstructured` library is not installed by default with langroid.
469
- To include this library, please install langroid with the
493
+ To include this library, please install langroid with the
470
494
  `unstructured` extra by running `pip install "langroid[unstructured]"`
471
495
  or equivalent.
472
496
  """
@@ -483,7 +507,7 @@ class UnstructuredPDFParser(DocumentParser):
483
507
  The `unstructured` library failed to parse the pdf.
484
508
  Please try a different library by setting the `library` field
485
509
  in the `pdf` section of the `parsing` field in the config file.
486
- Supported libraries are:
510
+ Supported libraries are:
487
511
  fitz, pypdf, pdfplumber, unstructured
488
512
  """
489
513
  )
@@ -529,7 +553,7 @@ class UnstructuredDocxParser(DocumentParser):
529
553
  raise ImportError(
530
554
  """
531
555
  The `unstructured` library is not installed by default with langroid.
532
- To include this library, please install langroid with the
556
+ To include this library, please install langroid with the
533
557
  `unstructured` extra by running `pip install "langroid[unstructured]"`
534
558
  or equivalent.
535
559
  """
@@ -580,7 +604,7 @@ class UnstructuredDocParser(UnstructuredDocxParser):
580
604
  raise ImportError(
581
605
  """
582
606
  The `unstructured` library is not installed by default with langroid.
583
- To include this library, please install langroid with the
607
+ To include this library, please install langroid with the
584
608
  `unstructured` extra by running `pip install "langroid[unstructured]"`
585
609
  or equivalent.
586
610
  """
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langroid"
3
- version = "0.1.225"
3
+ version = "0.1.226"
4
4
  description = "Harness LLMs with Multi-Agent Programming"
5
5
  authors = ["Prasad Chalasani <pchalasani@gmail.com>"]
6
6
  readme = "README.md"
@@ -96,6 +96,7 @@ huggingface-hub = {version="^0.21.2", optional=true}
96
96
  pdf2image = "^1.17.0"
97
97
  pytesseract = "^0.3.10"
98
98
  types-pyyaml = "^6.0.12.20240311"
99
+ types-pillow = "^10.2.0.20240406"
99
100
 
100
101
  [tool.poetry.extras]
101
102
  # install these using `poetry install -E [...]` where [...] is one of the extras below
File without changes
File without changes