From ea303b0f61d88ca6001458b35421bfbf94b7e589 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 5 Mar 2024 19:06:24 -0800 Subject: [PATCH] fix(replicate.py): handle model endpoint --- litellm/llms/replicate.py | 9 +++--- litellm/tests/log.txt | 51 ++++++++++++++------------------ litellm/tests/test_completion.py | 4 +-- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/litellm/llms/replicate.py b/litellm/llms/replicate.py index bc296bfd08a..2e1f1b607be 100644 --- a/litellm/llms/replicate.py +++ b/litellm/llms/replicate.py @@ -104,7 +104,8 @@ def start_prediction( version_id = version_id.replace("deployments/", "") base_url = f"https://api.replicate.com/v1/deployments/{version_id}" print_verbose(f"Deployment base URL: {base_url}\n") - + else: # assume it's a model + base_url = f"https://api.replicate.com/v1/models/{version_id}" headers = { "Authorization": f"Token {api_token}", "Content-Type": "application/json", @@ -306,9 +307,9 @@ def completion( result, logs = handle_prediction_response( prediction_url, api_key, print_verbose ) - model_response[ - "ended" - ] = time.time() # for pricing this must remain right after calling api + model_response["ended"] = ( + time.time() + ) # for pricing this must remain right after calling api ## LOGGING logging_obj.post_call( input=prompt, diff --git a/litellm/tests/log.txt b/litellm/tests/log.txt index 7b53823b0f8..03b5c605ecc 100644 --- a/litellm/tests/log.txt +++ b/litellm/tests/log.txt @@ -5,7 +5,7 @@ plugins: timeout-2.2.0, asyncio-0.23.2, anyio-3.7.1, xdist-3.3.1 asyncio: mode=Mode.STRICT collected 1 item -test_custom_callback_input.py . [100%] +test_completion.py . [100%] =============================== warnings summary =============================== ../../../../../../opt/homebrew/lib/python3.11/site-packages/pydantic/_internal/_config.py:271 @@ -15,54 +15,49 @@ test_custom_callback_input.py . [100%] ../../../../../../opt/homebrew/lib/python3.11/site-packages/pydantic/_internal/_config.py:271 ../../../../../../opt/homebrew/lib/python3.11/site-packages/pydantic/_internal/_config.py:271 ../../../../../../opt/homebrew/lib/python3.11/site-packages/pydantic/_internal/_config.py:271 +../../../../../../opt/homebrew/lib/python3.11/site-packages/pydantic/_internal/_config.py:271 ../../../../../../opt/homebrew/lib/python3.11/site-packages/pydantic/_internal/_config.py:271 /opt/homebrew/lib/python3.11/site-packages/pydantic/_internal/_config.py:271: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning) -../proxy/_types.py:99 - /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:99: PydanticDeprecatedSince20: `pydantic.config.Extra` is deprecated, use literal values instead (e.g. `extra='allow'`). Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ +../proxy/_types.py:102 + /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:102: PydanticDeprecatedSince20: `pydantic.config.Extra` is deprecated, use literal values instead (e.g. `extra='allow'`). Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ extra = Extra.allow # Allow extra fields -../proxy/_types.py:102 - /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:102: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ +../proxy/_types.py:105 + /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:105: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ @root_validator(pre=True) -../proxy/_types.py:131 - /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:131: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ +../proxy/_types.py:134 + /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:134: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ @root_validator(pre=True) -../proxy/_types.py:177 - /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:177: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ +../proxy/_types.py:180 + /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:180: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ @root_validator(pre=True) -../proxy/_types.py:232 - /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:232: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ +../proxy/_types.py:235 + /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:235: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ @root_validator(pre=True) -../proxy/_types.py:244 - /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:244: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ +../proxy/_types.py:247 + /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:247: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ @root_validator(pre=True) -../proxy/_types.py:279 - /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:279: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ +../proxy/_types.py:282 + /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:282: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ @root_validator(pre=True) -../proxy/_types.py:305 - /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:305: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ +../proxy/_types.py:308 + /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:308: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ @root_validator(pre=True) -../../../../../../opt/homebrew/lib/python3.11/site-packages/pydantic/_internal/_fields.py:149 - /opt/homebrew/lib/python3.11/site-packages/pydantic/_internal/_fields.py:149: UserWarning: Field "model_max_budget" has conflict with protected namespace "model_". - - You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`. - warnings.warn( - -../proxy/_types.py:553 - /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:553: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ +../proxy/_types.py:557 + /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:557: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ @root_validator(pre=True) -../proxy/_types.py:574 - /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:574: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ +../proxy/_types.py:578 + /Users/krrishdholakia/Documents/litellm/litellm/proxy/_types.py:578: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ @root_validator(pre=True) ../utils.py:36 @@ -115,4 +110,4 @@ test_custom_callback_input.py . [100%] import imghdr, base64 -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html -======================= 1 passed, 43 warnings in 13.05s ======================== +======================== 1 passed, 43 warnings in 4.47s ======================== diff --git a/litellm/tests/test_completion.py b/litellm/tests/test_completion.py index eca0cd93437..1423c7c4332 100644 --- a/litellm/tests/test_completion.py +++ b/litellm/tests/test_completion.py @@ -1406,9 +1406,9 @@ def test_completion_replicate_vicuna(): def test_replicate_custom_prompt_dict(): litellm.set_verbose = True - model_name = "replicate/meta/llama-2-7b-chat:13c3cdee13ee059ab779f0291d29054dab00a47dad8261375654de5540165fb0" + model_name = "replicate/mistralai/mixtral-8x7b-instruct-v0.1" litellm.register_prompt_template( - model="replicate/meta/llama-2-7b-chat:13c3cdee13ee059ab779f0291d29054dab00a47dad8261375654de5540165fb0", + model="replicate/mistralai/mixtral-8x7b-instruct-v0.1", initial_prompt_value="You are a good assistant", # [OPTIONAL] roles={ "system": {