mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
Revert "Add return_exceptions to litellm.batch_completion"
This commit is contained in:
parent
d968dedd77
commit
df8e33739d
3 changed files with 2 additions and 45 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -52,5 +52,3 @@ litellm/proxy/_new_secret_config.yaml
|
||||||
litellm/proxy/_new_secret_config.yaml
|
litellm/proxy/_new_secret_config.yaml
|
||||||
litellm/proxy/_super_secret_config.yaml
|
litellm/proxy/_super_secret_config.yaml
|
||||||
litellm/proxy/_super_secret_config.yaml
|
litellm/proxy/_super_secret_config.yaml
|
||||||
.python-version
|
|
||||||
litellm/llms/tokenizers/9b5ad71b2ce5302211f9c61530b329a4922fc6a4
|
|
||||||
|
|
|
@ -2302,7 +2302,6 @@ def batch_completion(
|
||||||
deployment_id=None,
|
deployment_id=None,
|
||||||
request_timeout: Optional[int] = None,
|
request_timeout: Optional[int] = None,
|
||||||
timeout: Optional[int] = 600,
|
timeout: Optional[int] = 600,
|
||||||
return_exceptions: bool = False,
|
|
||||||
# Optional liteLLM function params
|
# Optional liteLLM function params
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
|
@ -2326,7 +2325,6 @@ def batch_completion(
|
||||||
user (str, optional): The user string for generating completions. Defaults to "".
|
user (str, optional): The user string for generating completions. Defaults to "".
|
||||||
deployment_id (optional): The deployment ID for generating completions. Defaults to None.
|
deployment_id (optional): The deployment ID for generating completions. Defaults to None.
|
||||||
request_timeout (int, optional): The request timeout for generating completions. Defaults to None.
|
request_timeout (int, optional): The request timeout for generating completions. Defaults to None.
|
||||||
return_exceptions (bool): Whether to return exceptions and partial results when exceptions occur. Defaults to False.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list: A list of completion results.
|
list: A list of completion results.
|
||||||
|
@ -2385,17 +2383,7 @@ def batch_completion(
|
||||||
completions.append(future)
|
completions.append(future)
|
||||||
|
|
||||||
# Retrieve the results from the futures
|
# Retrieve the results from the futures
|
||||||
# results = [future.result() for future in completions]
|
|
||||||
if return_exceptions:
|
|
||||||
results = []
|
|
||||||
for future in completions:
|
|
||||||
try:
|
|
||||||
results.append(future.result())
|
|
||||||
except Exception as exc:
|
|
||||||
results.append(exc)
|
|
||||||
else:
|
|
||||||
results = [future.result() for future in completions]
|
results = [future.result() for future in completions]
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
"""Test batch_completion's return_exceptions."""
|
|
||||||
import pytest
|
|
||||||
import litellm
|
|
||||||
|
|
||||||
msg1 = [{"role": "user", "content": "hi 1"}]
|
|
||||||
msg2 = [{"role": "user", "content": "hi 2"}]
|
|
||||||
|
|
||||||
|
|
||||||
def test_batch_completion_return_exceptions_default():
|
|
||||||
"""Test batch_completion's return_exceptions."""
|
|
||||||
with pytest.raises(Exception):
|
|
||||||
_ = litellm.batch_completion(
|
|
||||||
model="gpt-3.5-turbo",
|
|
||||||
messages=[msg1, msg2],
|
|
||||||
api_key="sk_xxx", # deliberately set invalid key
|
|
||||||
# return_exceptions=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_batch_completion_return_exceptions_true():
|
|
||||||
"""Test batch_completion's return_exceptions."""
|
|
||||||
res = litellm.batch_completion(
|
|
||||||
model="gpt-3.5-turbo",
|
|
||||||
messages=[msg1, msg2],
|
|
||||||
api_key="sk_xxx", # deliberately set invalid key
|
|
||||||
return_exceptions=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert isinstance(res[0], litellm.exceptions.AuthenticationError)
|
|
Loading…
Add table
Add a link
Reference in a new issue