mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix: add greptile fixes
This commit is contained in:
parent
330a703518
commit
cd56c10b41
3 changed files with 20 additions and 2 deletions
|
|
@ -33,6 +33,10 @@ def _get_compact_threshold(context_management: List[Dict[str, Any]]) -> Optional
|
|||
threshold = entry.get("compact_threshold")
|
||||
if threshold is not None:
|
||||
return max(int(threshold), MIN_COMPACT_THRESHOLD)
|
||||
verbose_logger.warning(
|
||||
"compaction: context_management has type='compaction' but no "
|
||||
"compact_threshold — compaction will not trigger"
|
||||
)
|
||||
return None
|
||||
return None
|
||||
|
||||
|
|
|
|||
|
|
@ -62,12 +62,12 @@ class LiteLLMCompletionTransformationHandler:
|
|||
completion_args = {}
|
||||
completion_args.update(kwargs)
|
||||
completion_args.update(litellm_completion_request)
|
||||
completion_args.pop("context_management", None)
|
||||
|
||||
litellm_completion_response: Union[
|
||||
ModelResponse, litellm.CustomStreamWrapper
|
||||
] = litellm.completion(
|
||||
**litellm_completion_request,
|
||||
**kwargs,
|
||||
**completion_args,
|
||||
)
|
||||
|
||||
if isinstance(litellm_completion_response, ModelResponse):
|
||||
|
|
@ -153,6 +153,7 @@ class LiteLLMCompletionTransformationHandler:
|
|||
"custom_llm_provider"
|
||||
),
|
||||
litellm_metadata=kwargs.get("litellm_metadata", {}),
|
||||
compaction_summary_text=summary_text,
|
||||
)
|
||||
raise ValueError(
|
||||
f"Unexpected response type: {type(litellm_completion_response)}"
|
||||
|
|
|
|||
|
|
@ -57,8 +57,10 @@ class LiteLLMCompletionStreamingIterator(ResponsesAPIStreamingIterator):
|
|||
responses_api_request: ResponsesAPIOptionalRequestParams,
|
||||
custom_llm_provider: Optional[str] = None,
|
||||
litellm_metadata: Optional[dict] = None,
|
||||
compaction_summary_text: Optional[str] = None,
|
||||
):
|
||||
self.model: str = model
|
||||
self.compaction_summary_text: Optional[str] = compaction_summary_text
|
||||
self.litellm_custom_stream_wrapper: litellm.CustomStreamWrapper = (
|
||||
litellm_custom_stream_wrapper
|
||||
)
|
||||
|
|
@ -1176,6 +1178,17 @@ class LiteLLMCompletionStreamingIterator(ResponsesAPIStreamingIterator):
|
|||
responses_api_request=self.responses_api_request,
|
||||
)
|
||||
|
||||
# Append compaction output item if compaction was triggered
|
||||
if self.compaction_summary_text is not None:
|
||||
from litellm.responses.litellm_completion_transformation.handler import (
|
||||
_append_compaction_output,
|
||||
)
|
||||
|
||||
responses_api_response.output = _append_compaction_output(
|
||||
self.compaction_summary_text,
|
||||
responses_api_response.output,
|
||||
)
|
||||
|
||||
# Use the cached response ID to ensure consistency across all events
|
||||
if self._cached_response_id:
|
||||
responses_api_response.id = self._cached_response_id
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue