Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat: implement support for limit, order, before, and after parameters in get_assistants" #7542

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions litellm/assistants/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ def get_assistants(
timeout=timeout,
max_retries=optional_params.max_retries,
organization=organization,
order=getattr(optional_params, "order", "desc"),
limit=getattr(optional_params, "limit", 20),
before=getattr(optional_params, "before", None),
after=getattr(optional_params, "after", None),
client=client,
aget_assistants=aget_assistants, # type: ignore
) # type: ignore
Expand Down
49 changes: 5 additions & 44 deletions litellm/llms/openai/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -1928,10 +1928,6 @@ async def async_get_assistants(
max_retries: Optional[int],
organization: Optional[str],
client: Optional[AsyncOpenAI],
order: Optional[str] = 'desc',
limit: Optional[int] = 20,
before: Optional[str] = None,
after: Optional[str] = None,
) -> AsyncCursorPage[Assistant]:
openai_client = self.async_get_openai_client(
api_key=api_key,
Expand All @@ -1941,16 +1937,8 @@ async def async_get_assistants(
organization=organization,
client=client,
)
request_params = {
"order": order,
"limit": limit,
}
if before:
request_params["before"] = before
if after:
request_params["after"] = after

response = await openai_client.beta.assistants.list(**request_params)

response = await openai_client.beta.assistants.list()

return response

Expand All @@ -1965,11 +1953,7 @@ def get_assistants(
max_retries: Optional[int],
organization: Optional[str],
client: Optional[AsyncOpenAI],
aget_assistants: Literal[True],
order: Optional[str] = 'desc',
limit: Optional[int] = 20,
before: Optional[str] = None,
after: Optional[str] = None,
aget_assistants: Literal[True],
) -> Coroutine[None, None, AsyncCursorPage[Assistant]]:
...

Expand All @@ -1982,11 +1966,7 @@ def get_assistants(
max_retries: Optional[int],
organization: Optional[str],
client: Optional[OpenAI],
aget_assistants: Optional[Literal[False]],
order: Optional[str] = 'desc',
limit: Optional[int] = 20,
before: Optional[str] = None,
after: Optional[str] = None,
aget_assistants: Optional[Literal[False]],
) -> SyncCursorPage[Assistant]:
...

Expand All @@ -2001,10 +1981,6 @@ def get_assistants(
organization: Optional[str],
client=None,
aget_assistants=None,
order: Optional[str] = 'desc',
limit: Optional[int] = 20,
before: Optional[str] = None,
after: Optional[str] = None,
):
if aget_assistants is not None and aget_assistants is True:
return self.async_get_assistants(
Expand All @@ -2014,10 +1990,6 @@ def get_assistants(
max_retries=max_retries,
organization=organization,
client=client,
order=order,
limit=limit,
before=before,
after=after,
)
openai_client = self.get_openai_client(
api_key=api_key,
Expand All @@ -2028,18 +2000,7 @@ def get_assistants(
client=client,
)

request_params = {
"order": order,
"limit": limit,
}

if before:
request_params["before"] = before
if after:
request_params["after"] = after


response = openai_client.beta.assistants.list(**request_params)
response = openai_client.beta.assistants.list()

return response

Expand Down
26 changes: 0 additions & 26 deletions litellm/proxy/proxy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4434,10 +4434,6 @@ async def get_assistants(
request: Request,
fastapi_response: Response,
user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
order: Optional[str] = Query(None, description="Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order."),
limit: Optional[int] = Query(None, description="A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20."),
after: Optional[str] = Query(None, description="A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list."),
before: Optional[str] = Query(None, description="A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list."),
):
"""
Returns a list of assistants.
Expand All @@ -4460,28 +4456,6 @@ async def get_assistants(
proxy_config=proxy_config,
)

# Validate `order` parameter
if order and order not in ["asc", "desc"]:
raise HTTPException(
status_code=400, detail={"error": "order must be 'asc' or 'desc'"}
)
if order:
data["order"] = order

# Validate `limit` parameter
if limit is not None:
if not (1 <= limit <= 100):
raise HTTPException(
status_code=400, detail={"error": "limit must be between 1 and 100"}
)
data["limit"] = limit

# Add pagination cursors if provided
if after:
data["after"] = after
if before:
data["before"] = before

# for now use custom_llm_provider=="openai" -> this will change as LiteLLM adds more providers for acreate_batch
if llm_router is None:
raise HTTPException(
Expand Down
Loading