We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8a49af4 commit c5cd5ccCopy full SHA for c5cd5cc
1 file changed
src/raglite/_rag.py
@@ -206,6 +206,14 @@ def _limit_chunkspans(
206
# Early exit if we're already under the limit
207
if total_tokens <= max_tokens:
208
return tool_chunk_spans
209
+ # If the context window is completely exhausted, return empty spans.
210
+ if max_tokens <= 0 or total_tokens == 0:
211
+ logger.warning(
212
+ "RAG context was limited to 0 out of %d chunks due to context window size. "
213
+ "Consider using a model with a bigger context window or reducing the number of retrieved chunks.",
214
+ total_chunk_spans,
215
+ )
216
+ return {tool_id: [] for tool_id in tool_chunk_spans}
217
# Allocate tokens proportionally and truncate
218
new_total_chunk_spans = 0
219
scale_ratio = max_tokens / total_tokens
0 commit comments