forked from phoenix/litellm-mirror
fix(replicate.py): correctly handly invalid replicate response
This commit is contained in:
parent
c6962bda80
commit
d18dc2648c
2 changed files with 9 additions and 2 deletions
|
@ -295,7 +295,15 @@ def handle_prediction_response_streaming(prediction_url, api_token, print_verbos
|
||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
status = response_data["status"]
|
status = response_data["status"]
|
||||||
if "output" in response_data:
|
if "output" in response_data:
|
||||||
output_string = "".join(response_data["output"])
|
try:
|
||||||
|
output_string = "".join(response_data["output"])
|
||||||
|
except Exception as e:
|
||||||
|
raise ReplicateError(
|
||||||
|
status_code=422,
|
||||||
|
message="Unable to parse response. Got={}".format(
|
||||||
|
response_data["output"]
|
||||||
|
),
|
||||||
|
)
|
||||||
new_output = output_string[len(previous_output) :]
|
new_output = output_string[len(previous_output) :]
|
||||||
print_verbose(f"New chunk: {new_output}")
|
print_verbose(f"New chunk: {new_output}")
|
||||||
yield {"output": new_output, "status": status}
|
yield {"output": new_output, "status": status}
|
||||||
|
|
|
@ -1415,7 +1415,6 @@ def test_bedrock_claude_3_streaming():
|
||||||
"gpt-3.5-turbo",
|
"gpt-3.5-turbo",
|
||||||
"databricks/databricks-dbrx-instruct", # databricks
|
"databricks/databricks-dbrx-instruct", # databricks
|
||||||
"predibase/llama-3-8b-instruct", # predibase
|
"predibase/llama-3-8b-instruct", # predibase
|
||||||
"replicate/meta/meta-llama-3-8b-instruct", # replicate
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue