@danhachuel/thunderbolt 0.5.49 → 0.5.51
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.
|
@@ -276,8 +276,14 @@ def validate_paligemma_api_key(
|
|
|
276
276
|
if "integrate.api.nvidia.com" in configured:
|
|
277
277
|
configured = configured.replace("integrate.api.nvidia.com", "ai.api.nvidia.com")
|
|
278
278
|
endpoint = configured if "/vlm/google/paligemma" in configured else f"{configured}/vlm/google/paligemma"
|
|
279
|
+
# O endpoint VLM devolve 422 quando recebe apenas texto; uma imagem mínima
|
|
280
|
+
# permite testar autenticação e validação do contrato sem usar ficheiros do utilizador.
|
|
281
|
+
one_pixel_png = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="
|
|
279
282
|
payload = {
|
|
280
|
-
"messages": [{"role": "user", "content":
|
|
283
|
+
"messages": [{"role": "user", "content": [
|
|
284
|
+
{"type": "text", "text": "Describe this image in one word."},
|
|
285
|
+
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{one_pixel_png}"}},
|
|
286
|
+
]}],
|
|
281
287
|
"max_tokens": 8,
|
|
282
288
|
"temperature": 0,
|
|
283
289
|
}
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import io
|
|
4
4
|
import os
|
|
5
|
+
import signal
|
|
5
6
|
import sys
|
|
6
7
|
|
|
7
8
|
# Este ficheiro é o primeiro módulo Python executado pelo launcher. As
|
|
@@ -28,6 +29,26 @@ def _utf8_stream(stream: object) -> object:
|
|
|
28
29
|
sys.stdout = _utf8_stream(sys.stdout)
|
|
29
30
|
sys.stderr = _utf8_stream(sys.stderr)
|
|
30
31
|
|
|
32
|
+
|
|
33
|
+
def _custom_sigint_handler(signum: int, frame: object) -> None:
|
|
34
|
+
"""Encerrar sem executar ``server.stop``/Click do handler do Streamlit."""
|
|
35
|
+
print("\nEncerrando servidor...", file=sys.stderr, flush=True)
|
|
36
|
+
raise SystemExit(0)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
_original_signal = signal.signal
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _protected_signal(signum: signal.Signals, handler: object) -> object:
|
|
43
|
+
"""Não permitir que Streamlit substitua o handler seguro de SIGINT."""
|
|
44
|
+
if signum == signal.SIGINT:
|
|
45
|
+
return _original_signal(signal.SIGINT, _custom_sigint_handler)
|
|
46
|
+
return _original_signal(signum, handler)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
_original_signal(signal.SIGINT, _custom_sigint_handler)
|
|
50
|
+
signal.signal = _protected_signal
|
|
51
|
+
|
|
31
52
|
from streamlit.web.cli import main # noqa: E402
|
|
32
53
|
|
|
33
54
|
if __name__ == "__main__":
|