mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix: Add pre and post call for list batches (#15673)
This commit is contained in:
parent
f55745fc5e
commit
ce9e22688d
2 changed files with 33 additions and 2 deletions
|
|
@ -369,7 +369,13 @@ async def list_batches(
|
|||
|
||||
```
|
||||
"""
|
||||
from litellm.proxy.proxy_server import llm_router, proxy_logging_obj, version
|
||||
from litellm.proxy.proxy_server import (
|
||||
llm_router,
|
||||
proxy_logging_obj,
|
||||
version,
|
||||
general_settings,
|
||||
proxy_config,
|
||||
)
|
||||
|
||||
verbose_proxy_logger.debug("GET /v1/batches after={} limit={}".format(after, limit))
|
||||
try:
|
||||
|
|
@ -379,8 +385,23 @@ async def list_batches(
|
|||
detail={"error": CommonProxyErrors.no_llm_router.value},
|
||||
)
|
||||
|
||||
## check for target model names
|
||||
# Include original request and headers in the data
|
||||
data = await _read_request_body(request=request)
|
||||
base_llm_response_processor = ProxyBaseLLMRequestProcessing(data=data)
|
||||
(
|
||||
data,
|
||||
litellm_logging_obj,
|
||||
) = await base_llm_response_processor.common_processing_pre_call_logic(
|
||||
request=request,
|
||||
general_settings=general_settings,
|
||||
user_api_key_dict=user_api_key_dict,
|
||||
version=version,
|
||||
proxy_logging_obj=proxy_logging_obj,
|
||||
proxy_config=proxy_config,
|
||||
route_type="alist_batches",
|
||||
)
|
||||
|
||||
## check for target model names
|
||||
target_model_names = target_model_names or data.get("target_model_names", None)
|
||||
if target_model_names:
|
||||
model = target_model_names.split(",")[0]
|
||||
|
|
@ -388,6 +409,7 @@ async def list_batches(
|
|||
model=model,
|
||||
after=after,
|
||||
limit=limit,
|
||||
**data,
|
||||
)
|
||||
else:
|
||||
custom_llm_provider = (
|
||||
|
|
@ -399,8 +421,16 @@ async def list_batches(
|
|||
custom_llm_provider=custom_llm_provider, # type: ignore
|
||||
after=after,
|
||||
limit=limit,
|
||||
**data,
|
||||
)
|
||||
|
||||
## POST CALL HOOKS ###
|
||||
_response = await proxy_logging_obj.post_call_success_hook(
|
||||
data=data, user_api_key_dict=user_api_key_dict, response=response
|
||||
)
|
||||
if _response is not None and type(response) == type(_response):
|
||||
response = _response
|
||||
|
||||
### RESPONSE HEADERS ###
|
||||
hidden_params = getattr(response, "_hidden_params", {}) or {}
|
||||
model_id = hidden_params.get("model_id", None) or ""
|
||||
|
|
|
|||
|
|
@ -295,6 +295,7 @@ class ProxyBaseLLMRequestProcessing:
|
|||
"acancel_responses",
|
||||
"acreate_batch",
|
||||
"aretrieve_batch",
|
||||
"alist_batches",
|
||||
"afile_content",
|
||||
"atext_completion",
|
||||
"acreate_fine_tuning_job",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue