@danhachuel/thunderbolt 0.5.9 → 0.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/main.py +8 -2
- package/hermes_ui/api_key_tests.py +16 -0
- package/package.json +1 -1
package/app/main.py
CHANGED
|
@@ -4775,10 +4775,16 @@ def render_thumbnails():
|
|
|
4775
4775
|
with image_col:
|
|
4776
4776
|
image_path = record.get("image_path")
|
|
4777
4777
|
if image_path and image_path.is_file():
|
|
4778
|
-
|
|
4778
|
+
# Pass bytes to Streamlit and avoid the deprecated
|
|
4779
|
+
# ``use_container_width`` argument. On Windows the
|
|
4780
|
+
# deprecation warning can be emitted after the bootstrap
|
|
4781
|
+
# stream has been closed, which masks the real page with
|
|
4782
|
+
# ``ValueError: I/O operation on closed file``.
|
|
4783
|
+
image_bytes = image_path.read_bytes()
|
|
4784
|
+
st.image(image_bytes)
|
|
4779
4785
|
st.download_button(
|
|
4780
4786
|
"Descarregar thumbnail",
|
|
4781
|
-
data=
|
|
4787
|
+
data=image_bytes,
|
|
4782
4788
|
file_name=image_path.name,
|
|
4783
4789
|
mime="image/jpeg" if image_path.suffix.lower() in {".jpg", ".jpeg"} else "image/png",
|
|
4784
4790
|
key=f"thumbnail_download_{task_id}_{record['variant_index']}",
|
|
@@ -128,6 +128,20 @@ def test_nano_banana_credentials(api_key: str, model: str) -> dict[str, Any]:
|
|
|
128
128
|
)
|
|
129
129
|
|
|
130
130
|
|
|
131
|
+
def test_canva_credentials(card: Mapping[str, Any]) -> dict[str, Any]:
|
|
132
|
+
"""Validate Canva with the configured API key or OAuth access token."""
|
|
133
|
+
source = dict(card) if isinstance(card, Mapping) else {}
|
|
134
|
+
api_key = str(source.get("api_key") or "").strip()
|
|
135
|
+
oauth_token = source.get("oauth_token") if isinstance(source.get("oauth_token"), Mapping) else {}
|
|
136
|
+
token = api_key or str(oauth_token.get("access_token") or "").strip()
|
|
137
|
+
if not token:
|
|
138
|
+
return _missing("Introduza a API key ou autorize o Canva antes de testar este provider.")
|
|
139
|
+
return _get(
|
|
140
|
+
"https://api.canva.com/rest/v1/users/me",
|
|
141
|
+
headers={"Authorization": f"Bearer {token}", "Accept": "application/json"},
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
131
145
|
def test_google_lyria_credentials(api_key: str, model: str) -> dict[str, Any]:
|
|
132
146
|
"""Validate access to the selected Lyria model without requesting audio generation."""
|
|
133
147
|
api_key = str(api_key or "").strip()
|
|
@@ -146,6 +160,8 @@ def test_media_provider_card(card: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
146
160
|
"""Run a bounded, non-generative check for an image/video provider card."""
|
|
147
161
|
source = dict(card) if isinstance(card, Mapping) else {}
|
|
148
162
|
provider = str(source.get("provider") or "").strip().lower()
|
|
163
|
+
if provider == "canva":
|
|
164
|
+
return test_canva_credentials(source)
|
|
149
165
|
api_key = str(source.get("api_key") or "").strip()
|
|
150
166
|
model = str(source.get("model") or "").strip()
|
|
151
167
|
base_url = str(source.get("base_url") or "").strip().rstrip("/")
|
package/package.json
CHANGED