QueryBot and AsyncQueryBot — EARS
Parent LLD: ./LLD.md
Construction
-
[x] QRY-RAG-001: The system shall provide
QueryBotwith a requireddocstoreof typeAbstractDocumentStoreand an optionalmemoryof the same abstract type. -
[x] QRY-RAG-002: After
SimpleBot.__init__, the system shall setself.memoryfrom theQueryBotconstructor argument (optional second document store), independent ofSimpleBot’s defaultmemoryparameter.
Retrieval and message order
-
[x] QRY-RAG-010:
compose_rag_messagesshall calldocstore.retrieve(query_content, n_results)and wrap each returned chunk inRetrievedMessage. -
[x] QRY-RAG-011: Where
memoryis set, the system shall callmemory.retrieve(query_content, n_results)and wrap each chunk inRetrievedMessageafter docstore chunks and before the final userHumanMessage. -
[x] QRY-RAG-012: The final message in the composed list before
to_basemessageshall beHumanMessagewith content equal to the query string. -
[x] QRY-RAG-013: The system shall record nested spans
retrievaland, when applicable,memory_retrieval, with result counts on the spans and outer span.
Completion and persistence
-
[x] QRY-RAG-020:
QueryBot.__call__shall passprocessed_messagesfromcompose_rag_messagestomake_response/stream_chunks, and shall passmessages + [response_message]tosqlite_log. -
[x] QRY-RAG-021: Where
memoryis set,QueryBot.__call__shall callmemory.appendwith the assistant message content string after logging.
AsyncQueryBot
-
[x] QRY-RAG-030:
AsyncQueryBot.__call__shall delegate toQueryBot.__call__viaasyncio.to_threadwith the samequeryandn_results. -
[x] QRY-RAG-031:
AsyncQueryBot.stream_asyncshall usecompose_rag_messagesthenstream_tokens_for_messageswithprocessed_messages, and thefinalizecallback shall log the turn and append assistant content tomemorywhenmemoryis set.
Verification
| ID | Tests / code |
|---|---|
| QRY-RAG-001–002, 010–013, 020–021 | tests/bot/test_querybot.py |
| QRY-RAG-030–031 | tests/test_streaming_async.py (AsyncQueryBot.stream_async); QRY-RAG-030 implementation in llamabot/bot/querybot.py |