Skip to content

Commit

Permalink
build(deps): manual fix!! bump replicate from 0.34.1 to 1.0.3 in /aut…
Browse files Browse the repository at this point in the history
…ogpt_platform/backend (#8476)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nicholas Tindle <[email protected]>
  • Loading branch information
dependabot[bot] and ntindle authored Nov 5, 2024
1 parent 799c6e5 commit f17c20e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
15 changes: 12 additions & 3 deletions autogpt_platform/backend/backend/blocks/replicate_flux_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import replicate
from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr
from replicate.helpers import FileOutput

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
Expand Down Expand Up @@ -197,7 +198,7 @@ def run_model(
client = replicate.Client(api_token=api_key.get_secret_value())

# Run the model with additional parameters
output = client.run(
output: FileOutput | list[FileOutput] = client.run( # type: ignore This is because they changed the return type, and didn't update the type hint! It should be overloaded depending on the value of `use_file_output` to `FileOutput | list[FileOutput]` but it's `Any | Iterator[Any]`
f"{model_name}",
input={
"prompt": prompt,
Expand All @@ -210,13 +211,21 @@ def run_model(
"output_quality": output_quality,
"safety_tolerance": safety_tolerance,
},
wait=False, # don't arbitrarily return data:octect/stream or sometimes url depending on the model???? what is this api
)

# Check if output is a list or a string and extract accordingly; otherwise, assign a default message
if isinstance(output, list) and len(output) > 0:
result_url = output[0] # If output is a list, get the first element
if isinstance(output[0], FileOutput):
result_url = output[0].url # If output is a list, get the first element
else:
result_url = output[
0
] # If output is a list and not a FileOutput, get the first element. Should never happen, but just in case.
elif isinstance(output, FileOutput):
result_url = output.url # If output is a FileOutput, use the url
elif isinstance(output, str):
result_url = output # If output is a string, use it directly
result_url = output # If output is a string (for some reason due to their janky type hinting), use it directly
else:
result_url = (
"No output received" # Fallback message if output is not as expected
Expand Down
20 changes: 10 additions & 10 deletions autogpt_platform/backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion autogpt_platform/backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ uvicorn = { extras = ["standard"], version = "^0.30.1" }
websockets = "^13.1"
youtube-transcript-api = "^0.6.2"
googlemaps = "^4.10.0"
replicate = "^0.34.1"
replicate = "^1.0.3"
pinecone = "^5.3.1"
cryptography = "^43.0.3"
[tool.poetry.group.dev.dependencies]
Expand Down

0 comments on commit f17c20e

Please sign in to comment.