Sub Globals
Dim llm As LlamaEngine
End Sub
Sub Activity_Create(FirstTime As Boolean)
llm.Initialize(Me, "LLM")
' Optional: Enable debug logs and low memory optimizations
llm.DebugMode = True
' llm.LowMemoryMode = True ' Uncomment for low RAM devices
' Load a GGUF model (adjust path to your model file)
' Params: Path, Threads, ContextSize
llm.LoadModel("/sdcard/Download/Qwen3-0.6B-Q4_K_M.gguf", 4, 512)
End Sub
Sub LLM_LoadProgress(Progress As Float)
Log("Loading: " & Round(Progress * 100) & "%")
End Sub
Sub LLM_ModelLoaded(Success As Boolean)
Log("Model loaded: " & Success)
If Success Then
llm.AddSystemMessage("You are a helpful assistant.")
llm.AddUserMessage("What is the capital of France?")
llm.GenerateChat(256, 0.7) ' Generate max 256 tokens with 0.7 temperature
End If
End Sub
Sub LLM_TokenGenerated(Token As String)
' Each token is streamed as it's generated
Log(Token)
End Sub
Sub LLM_Complete(Response As String)
Log("Full response: " & Response)
End Sub
Sub LLM_Error(Message As String)
Log("Error: " & Message)
End Sub
Sub LLM_DebugLog(Message As String)
' Triggered if llm.DebugMode = True
Log("[LLM DEBUG] " & Message)
End Sub