86 lines
3.0 KiB
Plaintext
86 lines
3.0 KiB
Plaintext
' AR-House Launcher - modo bajo consumo
|
|
' Doble-click para iniciar Ollama + Streamlit y abrir el navegador
|
|
'
|
|
' NOTA: strings sin acentos para evitar problemas de encoding con wscript.exe.
|
|
' Los acentos en cadenas funcionan mal si el archivo no esta en ANSI/UTF-16.
|
|
Option Explicit
|
|
|
|
Dim shell, fso, projectPath, ollamaPath, browserURL
|
|
Dim WshShell, retries, ollamaReady
|
|
|
|
Set shell = CreateObject("WScript.Shell")
|
|
Set fso = CreateObject("Scripting.FileSystemObject")
|
|
Set WshShell = CreateObject("WScript.Shell")
|
|
|
|
projectPath = "D:\Proyectos Software\AR-House"
|
|
browserURL = "http://localhost:8501"
|
|
|
|
' Paso 1: verificar que Ollama existe
|
|
On Error Resume Next
|
|
shell.Run "ollama --version", 0, True
|
|
If Err.Number <> 0 Then
|
|
MsgBox "Ollama no esta instalado o no esta en el PATH." & vbCrLf & _
|
|
"Instalalo desde ollama.com primero.", vbCritical, "AR-House"
|
|
WScript.Quit
|
|
End If
|
|
On Error Goto 0
|
|
|
|
' Paso 2: matar Ollama si esta corriendo (reset limpio)
|
|
shell.Run "taskkill /F /IM ollama.exe /T", 0, True
|
|
WScript.Sleep 1500
|
|
|
|
' Paso 3: lanzar Ollama con env vars de bajo consumo
|
|
Dim ollamaCmd
|
|
ollamaCmd = "cmd /c set OLLAMA_MAX_LOADED_MODELS=1 && " & _
|
|
"set OLLAMA_NUM_PARALLEL=1 && " & _
|
|
"set OLLAMA_KEEP_ALIVE=0 && " & _
|
|
"ollama serve"
|
|
shell.Run ollamaCmd, 0, False
|
|
|
|
' Paso 4: esperar a que Ollama responda (max 15 segundos)
|
|
retries = 0
|
|
ollamaReady = False
|
|
Do While retries < 15 And Not ollamaReady
|
|
WScript.Sleep 1000
|
|
On Error Resume Next
|
|
Dim xmlhttp
|
|
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
|
|
xmlhttp.Open "GET", "http://localhost:11434/api/tags", False
|
|
xmlhttp.Send
|
|
If xmlhttp.Status = 200 Then ollamaReady = True
|
|
On Error Goto 0
|
|
retries = retries + 1
|
|
Loop
|
|
|
|
If Not ollamaReady Then
|
|
MsgBox "Ollama no respondio despues de 15 segundos. Verifica manualmente.", _
|
|
vbExclamation, "AR-House"
|
|
WScript.Quit
|
|
End If
|
|
|
|
' Paso 5: lanzar Streamlit con virtualenv
|
|
Dim streamlitCmd
|
|
streamlitCmd = "cmd /c cd /d """ & projectPath & """ && " & _
|
|
".venv\Scripts\activate && " & _
|
|
"streamlit run app.py --server.headless true"
|
|
shell.Run streamlitCmd, 0, False
|
|
|
|
' Paso 6: esperar a que Streamlit arranque
|
|
WScript.Sleep 8000
|
|
|
|
' Paso 7: abrir navegador (preferir pestana nueva, no ventana nueva)
|
|
'
|
|
' Usamos "cmd /c start" en lugar de shell.Run directo sobre la URL.
|
|
' "start" delega al handler default de URL del sistema, lo que en browsers
|
|
' modernos (Chrome, Edge, Firefox) suele abrir una pestana nueva si el
|
|
' browser ya esta corriendo (en lugar de ventana nueva).
|
|
'
|
|
' Si el browser NO esta corriendo, igual se abre como ventana nueva
|
|
' (es el primer launch). Esto es comportamiento de Windows, no del VBS.
|
|
shell.Run "cmd /c start " & Chr(34) & Chr(34) & " " & Chr(34) & browserURL & Chr(34), 0, False
|
|
|
|
' Paso 8: notificacion al usuario (popup discreto, se cierra solo en 3s)
|
|
WshShell.Popup "AR-House esta listo en tu navegador." & vbCrLf & _
|
|
"Para cerrar todo: doble-click en AR-House-Stop.vbs", _
|
|
3, "AR-House", vbInformation
|