We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b9bda63 commit c0b4a01Copy full SHA for c0b4a01
1 file changed
src/raglite/_rag.py
@@ -152,6 +152,14 @@ def _limit_chunkspans(
152
# Early exit if we're already under the limit
153
if total_tokens <= max_tokens:
154
return tool_chunk_spans
155
+ # If the context window is completely exhausted, return empty spans.
156
+ if max_tokens <= 0 or total_tokens == 0:
157
+ logger.warning(
158
+ "RAG context was limited to 0 out of %d chunks due to context window size. "
159
+ "Consider using a model with a bigger context window or reducing the number of retrieved chunks.",
160
+ total_chunk_spans,
161
+ )
162
+ return {tool_id: [] for tool_id in tool_chunk_spans}
163
# Allocate tokens proportionally and truncate
164
new_total_chunk_spans = 0
165
scale_ratio = max_tokens / total_tokens
0 commit comments