MCPcopy Create free account
hub / github.com/BUPT-GAMMA/MASFactory / load_bytes

Method load_bytes

masfactory/core/multimodal.py:60–82  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

58 filename: str | None = None
59
60 def load_bytes(self) -> bytes:
61 if self.source_kind == "bytes":
62 if isinstance(self.value, bytes):
63 return self.value
64 raise ValueError(
65 f"generic model 'unknown' does not support {self.modality.value!r} source "
66 f"{self.source_kind!r} for field 'unknown'."
67 )
68 if self.source_kind == "base64":
69 if not isinstance(self.value, str):
70 raise ValueError("base64 media value must be a string")
71 raw = self.value
72 if raw.startswith("data:") and "," in raw:
73 raw = raw.split(",", 1)[1]
74 return base64.b64decode(raw)
75 if self.source_kind == "path":
76 if not isinstance(self.value, str):
77 raise ValueError("path media value must be a string")
78 return Path(self.value).read_bytes()
79 raise ValueError(
80 f"generic model 'unknown' does not support {self.modality.value!r} source "
81 f"{self.source_kind!r} for field 'unknown'."
82 )
83
84 def fingerprint(self) -> str:
85 digest = hashlib.sha256()

Callers 4

fingerprintMethod · 0.95
prompt_summaryMethod · 0.95
encode_gemini_partsMethod · 0.80
asset_to_base64Function · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected