Skip to content

Commit 7c910df

Browse files
MattiaMolonr-dh
andauthored
Agentic RAG with iterative sub-agent search (#180)
* feat: allow agentic behavior with iterable tool calling * feat: added system message injection to allow for smoother agentic rag * feat: spawn subagent for search queries * feat: first implementation of sub-agent search * fix: make auto-retrieval assertion robust to parallel tool calls (cherry picked from commit 2fc5d7d) * fix: drop unsupported params in self-query LLM call for GPT-5 compatibility (cherry picked from commit d46fcf6) * fix: fixed token budget miscalculation * fix: pass metadata_filter to run_tools * fix: deduplicate chunk spans based on chunk ids * fix: separate live messages from working messages object during sub calls * feat: updated async_rag to match rag * feat: code clean up * fix: small robustness fixes for edge cases * fix: fix required tool call in litellm * fix: adapted tool description to make it more robust to tests * fix: resolved pr comments - import MetadataFilter at runtime - remove redundant assert tool - added clip to subagent messages - fix bug that allowed empty tool call list to run LLM completion --------- Co-authored-by: r-dh <remydheygere@gmail.com>
1 parent d327f14 commit 7c910df

6 files changed

Lines changed: 469 additions & 121 deletions

File tree

src/raglite/_chatml_function_calling.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ def chatml_function_calling_with_streaming(
400400

401401
# Case 2: Automatic or fixed tool choice
402402
# Case 2 step 1: Determine whether to respond with a message or a tool call
403-
assert (isinstance(tool_choice, str) and tool_choice == "auto") or isinstance(tool_choice, dict)
403+
assert (isinstance(tool_choice, str) and tool_choice in ("auto", "required")) or isinstance(
404+
tool_choice, dict
405+
)
404406
if isinstance(tool_choice, dict):
405407
tools = [t for t in tools if t["function"]["name"] == tool_choice["function"]["name"]]
406408
assert tools

src/raglite/_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,4 @@ class RAGLiteConfig:
103103
# list[Chunk], or list[ChunkSpan].
104104
search_method: SearchMethod = field(default=_vector_search, compare=False)
105105
self_query: bool = False
106+
agentic_iterations: int = 3

src/raglite/_litellm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
# Reduce the logging level for LiteLLM, flashrank, and httpx.
3838
litellm.suppress_debug_info = True
39-
litellm.drop_params = True # Drop unsupported parameters for models like GPT-5
4039
os.environ["LITELLM_LOG"] = "WARNING"
4140
logging.getLogger("LiteLLM").setLevel(logging.WARNING)
4241
logging.getLogger("flashrank").setLevel(logging.WARNING)

0 commit comments

Comments
 (0)