mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-24 00:52:24 +00:00
refactor(responses): build agentic follow-up kwargs as one frozen mapping
This commit is contained in:
parent
bbee8692a8
commit
3298b41687
1 changed files with 24 additions and 14 deletions
|
|
@ -4,6 +4,7 @@ import ssl
|
|||
from collections.abc import AsyncIterator, Coroutine, Iterator, Mapping, Sequence
|
||||
from contextlib import asynccontextmanager
|
||||
from functools import lru_cache
|
||||
from itertools import chain
|
||||
from types import MappingProxyType, ModuleType
|
||||
from typing import TYPE_CHECKING, Any, Final, Literal, Optional, TypedDict, TypeVar, Union, cast, get_type_hints
|
||||
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
|
||||
|
|
@ -5572,20 +5573,29 @@ class BaseLLMHTTPHandler:
|
|||
}
|
||||
|
||||
internal_keys: Final = {"litellm_logging_obj"}
|
||||
kwargs_for_followup: Final = {
|
||||
**{
|
||||
k: v
|
||||
for k, v in kwargs.items()
|
||||
if not is_interception_internal_key(k, prefixes=NON_CODE_INTERPRETER_INTERCEPTION_INTERNAL_PREFIXES)
|
||||
and k != "_code_interpreter_interception_converted_stream"
|
||||
and k not in internal_keys
|
||||
and k not in optional_params
|
||||
},
|
||||
**{k: v for k, v in patch.kwargs.items() if k not in optional_params},
|
||||
"_agentic_loop_depth": depth + 1,
|
||||
"max_agentic_loops": max_loops,
|
||||
"_agentic_loop_fingerprints": fingerprints + [fingerprint],
|
||||
}
|
||||
kwargs_for_followup: Final = MappingProxyType(
|
||||
{
|
||||
key: value
|
||||
for key, value in chain(
|
||||
(
|
||||
(k, v)
|
||||
for k, v in kwargs.items()
|
||||
if not is_interception_internal_key(
|
||||
k, prefixes=NON_CODE_INTERPRETER_INTERCEPTION_INTERNAL_PREFIXES
|
||||
)
|
||||
and k != "_code_interpreter_interception_converted_stream"
|
||||
and k not in internal_keys
|
||||
and k not in optional_params
|
||||
),
|
||||
((k, v) for k, v in patch.kwargs.items() if k not in optional_params),
|
||||
(
|
||||
("_agentic_loop_depth", depth + 1),
|
||||
("max_agentic_loops", max_loops),
|
||||
("_agentic_loop_fingerprints", fingerprints + [fingerprint]),
|
||||
),
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
try:
|
||||
response: ResponsesAPIResponse | BaseResponsesAPIStreamingIterator = await litellm.aresponses(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue