langroid 0.45.2__py3-none-any.whl → 0.45.3__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
@@ -1363,8 +1363,7 @@ class Agent(ABC):
1363
1363
 
1364
1364
  has_orch = any(isinstance(t, ORCHESTRATION_TOOLS) for t in tools)
1365
1365
  if has_orch and len(tools) > 1:
1366
- err_str = "ERROR: Use ONE tool at a time!"
1367
- return [err_str for _ in tools]
1366
+ return ["ERROR: Use ONE tool at a time!"] * len(tools)
1368
1367
 
1369
1368
  return []
1370
1369
 
@@ -1499,8 +1498,6 @@ class Agent(ABC):
1499
1498
  # as a response to the tool message even though the tool was not intended
1500
1499
  # for this agent.
1501
1500
  return None
1502
- if len(tools) > 1 and not self.config.allow_multiple_tools:
1503
- return self.to_ChatDocument("ERROR: Use ONE tool at a time!")
1504
1501
  if len(tools) == 0:
1505
1502
  fallback_result = self.handle_message_fallback(msg)
1506
1503
  if fallback_result is None:
@@ -1509,10 +1506,14 @@ class Agent(ABC):
1509
1506
  fallback_result,
1510
1507
  chat_doc=msg if isinstance(msg, ChatDocument) else None,
1511
1508
  )
1512
- chat_doc = msg if isinstance(msg, ChatDocument) else None
1513
1509
 
1514
- results = self._get_multiple_orch_tool_errs(tools)
1510
+ results: List[str | ChatDocument | None] = []
1511
+ if len(tools) > 1 and not self.config.allow_multiple_tools:
1512
+ results = ["ERROR: Use ONE tool at a time!"] * len(tools)
1513
+ if not results:
1514
+ results = self._get_multiple_orch_tool_errs(tools)
1515
1515
  if not results:
1516
+ chat_doc = msg if isinstance(msg, ChatDocument) else None
1516
1517
  results = [self.handle_tool_message(t, chat_doc=chat_doc) for t in tools]
1517
1518
  # if there's a solitary ChatDocument|str result, return it as is
1518
1519
  if len(results) == 1 and isinstance(results[0], (str, ChatDocument)):
@@ -85,6 +85,8 @@ class ChatAgentConfig(AgentConfig):
85
85
  enabled when such tool calls are not desired.
86
86
  output_format_include_defaults: Whether to include fields with default arguments
87
87
  in the output schema
88
+ full_citations: Whether to show source reference citation + content for each
89
+ citation, or just the main reference citation.
88
90
  """
89
91
 
90
92
  system_message: str = "You are a helpful assistant."
@@ -404,8 +404,8 @@ class DocumentParser(Parser):
404
404
  # that it needs to be combined with the next chunk.
405
405
  while len(split) > self.config.chunk_size:
406
406
  # pretty formatting of pages (e.g. 1-3, 4, 5-7)
407
- p_0 = int(pages[0])
408
- p_n = int(pages[-1])
407
+ p_0 = int(pages[0]) - self.config.page_number_offset
408
+ p_n = int(pages[-1]) - self.config.page_number_offset
409
409
  page_str = f"pages {p_0}-{p_n}" if p_0 != p_n else f"page {p_0}"
410
410
  text = self.tokenizer.decode(split[: self.config.chunk_size])
411
411
  docs.append(
@@ -426,8 +426,8 @@ class DocumentParser(Parser):
426
426
  # since it's already included in the prior chunk;
427
427
  # the only exception is if there have been no chunks so far.
428
428
  if len(split) > self.config.overlap or n_chunks == 0:
429
- p_0 = int(pages[0])
430
- p_n = int(pages[-1])
429
+ p_0 = int(pages[0]) - self.config.page_number_offset
430
+ p_n = int(pages[-1]) - self.config.page_number_offset
431
431
  page_str = f"pages {p_0}-{p_n}" if p_0 != p_n else f"page {p_0}"
432
432
  text = self.tokenizer.decode(split[: self.config.chunk_size])
433
433
  docs.append(
@@ -103,6 +103,9 @@ class ParsingConfig(BaseSettings):
103
103
  chunk_size: int = 200 # aim for this many tokens per chunk
104
104
  overlap: int = 50 # overlap between chunks
105
105
  max_chunks: int = 10_000
106
+ # offset to subtract from page numbers:
107
+ # e.g. if physical page 12 is displayed as page 1, set page_number_offset = 11
108
+ page_number_offset: int = 0
106
109
  # aim to have at least this many chars per chunk when truncating due to punctuation
107
110
  min_chunk_chars: int = 350
108
111
  discard_chunk_chars: int = 5 # discard chunks with fewer than this many chars
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langroid
3
- Version: 0.45.2
3
+ Version: 0.45.3
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  Author-email: Prasad Chalasani <pchalasani@gmail.com>
6
6
  License: MIT
@@ -3,9 +3,9 @@ langroid/exceptions.py,sha256=OPjece_8cwg94DLPcOGA1ddzy5bGh65pxzcHMnssTz8,2995
3
3
  langroid/mytypes.py,sha256=wfb320SFnZVTv_CgcLWsvoKBXxAFfY4EISeue8MFqpQ,2912
4
4
  langroid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  langroid/agent/__init__.py,sha256=ll0Cubd2DZ-fsCMl7e10hf9ZjFGKzphfBco396IKITY,786
6
- langroid/agent/base.py,sha256=LSRtSjXE1If49K14H_8BFoWiK4pHsO0-obgYehyC2DQ,79517
6
+ langroid/agent/base.py,sha256=yM7ul2byHhwCFm6w8_4RULkPdhI8XR3n7XqNBS0hD20,79567
7
7
  langroid/agent/batch.py,sha256=vi1r5i1-vN80WfqHDSwjEym_KfGsqPGUtwktmiK1nuk,20635
8
- langroid/agent/chat_agent.py,sha256=1SKFOv74eFbTiLQ4bkvx6CTGXmKIyebZVOSkbKnc5V8,85070
8
+ langroid/agent/chat_agent.py,sha256=Z53oleOUcOXVs_UL90spttGoAooe0mrx3tDtOuhKVms,85214
9
9
  langroid/agent/chat_document.py,sha256=xzMtrPbaW-Y-BnF7kuhr2dorsD-D5rMWzfOqJ8HAoo8,17885
10
10
  langroid/agent/openai_assistant.py,sha256=JkAcs02bIrgPNVvUWVR06VCthc5-ulla2QMBzux_q6o,34340
11
11
  langroid/agent/task.py,sha256=HB6N-Jn80HFqCf0ZYOC1v3Bn3oO7NLjShHQJJFwW0q4,90557
@@ -81,10 +81,10 @@ langroid/language_models/prompt_formatter/llama2_formatter.py,sha256=YdcO88qyBeu
81
81
  langroid/parsing/__init__.py,sha256=2oUWJJAxIavq9Wtw5RGlkXLq3GF3zgXeVLLW4j7yeb8,1138
82
82
  langroid/parsing/agent_chats.py,sha256=sbZRV9ujdM5QXvvuHVjIi2ysYSYlap-uqfMMUKulrW0,1068
83
83
  langroid/parsing/code_parser.py,sha256=5ze0MBytrGGkU69pA_bJDjRm6QZz_QYfPcIwkagUa7U,3796
84
- langroid/parsing/document_parser.py,sha256=Q58y8BHovJJAOi8kwgN8MEH66BxGVlrVjbZMBSJ_Cts,52822
84
+ langroid/parsing/document_parser.py,sha256=fyCx4X1192asom5tp3DNV4J5Em2u4Z7rCC0FA8dNsSQ,52954
85
85
  langroid/parsing/para_sentence_split.py,sha256=AJBzZojP3zpB-_IMiiHismhqcvkrVBQ3ZINoQyx_bE4,2000
86
86
  langroid/parsing/parse_json.py,sha256=aADo38bAHQhC8on4aWZZzVzSDy-dK35vRLZsFI2ewh8,4756
87
- langroid/parsing/parser.py,sha256=ArAPWQ2Op_1B8i26xpkWHwnZiXgDrcyih2A6l8R49aI,14136
87
+ langroid/parsing/parser.py,sha256=ZUvBhzMZQWKerbb9UECbcqkNc9wWKuUgPyC8L6baxao,14295
88
88
  langroid/parsing/pdf_utils.py,sha256=rmNJ9UzuBgXTAYwj1TtRJcD8h53x7cizhgyYHKO88I4,1513
89
89
  langroid/parsing/repo_loader.py,sha256=NpysuyzRHvgL3F4BB_wGo5sCUnZ3FOlVCJmZ7CaUdbs,30202
90
90
  langroid/parsing/routing.py,sha256=-FcnlqldzL4ZoxuDwXjQPNHgBe9F9-F4R6q7b_z9CvI,1232
@@ -127,7 +127,7 @@ langroid/vector_store/pineconedb.py,sha256=otxXZNaBKb9f_H75HTaU3lMHiaR2NUp5MqwLZ
127
127
  langroid/vector_store/postgres.py,sha256=wHPtIi2qM4fhO4pMQr95pz1ZCe7dTb2hxl4VYspGZoA,16104
128
128
  langroid/vector_store/qdrantdb.py,sha256=O6dSBoDZ0jzfeVBd7LLvsXu083xs2fxXtPa9gGX3JX4,18443
129
129
  langroid/vector_store/weaviatedb.py,sha256=Yn8pg139gOy3zkaPfoTbMXEEBCiLiYa1MU5d_3UA1K4,11847
130
- langroid-0.45.2.dist-info/METADATA,sha256=86UjdUNW5UpWQ0kP8_sz7EkMIgdrklulwipPm0fOcpQ,63335
131
- langroid-0.45.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
132
- langroid-0.45.2.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
133
- langroid-0.45.2.dist-info/RECORD,,
130
+ langroid-0.45.3.dist-info/METADATA,sha256=_6oOG_rHqN8JUymnv8uIbHaqpk5N7gHiUUqMqEFXvFc,63335
131
+ langroid-0.45.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
132
+ langroid-0.45.3.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
133
+ langroid-0.45.3.dist-info/RECORD,,