MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / make_image_public

Function make_image_public

bmtools/tools/image_generation/api.py:26–62  ·  view source on GitHub ↗

Upload a block to a signed URL and return the public URL.

(client: Steamship, block: Block)

Source from the content-addressed store, hash-verified

24}
25
26def make_image_public(client: Steamship, block: Block) -> str:
27 """Upload a block to a signed URL and return the public URL."""
28 try:
29 from steamship.data.workspace import SignedUrl
30 from steamship.utils.signed_urls import upload_to_signed_url
31 except ImportError:
32 raise ValueError(
33 "The make_image_public function requires the steamship"
34 " package to be installed. Please install steamship"
35 " with `pip install --upgrade steamship`"
36 )
37
38 filepath = str(uuid.uuid4())
39 signed_url = (
40 client.get_workspace()
41 .create_signed_url(
42 SignedUrl.Request(
43 bucket=SignedUrl.Bucket.PLUGIN_DATA,
44 filepath=filepath,
45 operation=SignedUrl.Operation.WRITE,
46 )
47 )
48 .signed_url
49 )
50 read_signed_url = (
51 client.get_workspace()
52 .create_signed_url(
53 SignedUrl.Request(
54 bucket=SignedUrl.Bucket.PLUGIN_DATA,
55 filepath=filepath,
56 operation=SignedUrl.Operation.READ,
57 )
58 )
59 .signed_url
60 )
61 upload_to_signed_url(signed_url, block.raw())
62 return read_signed_url
63
64def show_output(output):
65 """Display the multi-modal output from the agent."""

Callers 1

generate_imageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected