if (FALSE) {
# Requires a downloaded model (not run in checks)
model_path <- "model.gguf"
if (file.exists(model_path)) {
ctx <- edge_load_model(model_path)
# Basic streaming with token display
result <- edge_stream_completion(ctx, "Hello, how are you?",
callback = function(data) {
if (!data$is_final) {
cat(data$token)
flush.console()
} else {
cat("\n[Done: ", data$total_tokens, " tokens]\n")
}
return(TRUE) # Continue generation
})
edge_free_model(ctx)
}
}
Run the code above in your browser using DataLab