<Rcpp::exception/C++Error/error/condition>
Error: Error during streaming completion: Invalid model context

"Prompt must be a single character string"
edge_stream_completion(mock_ctx, c("a", "b"), function(x) TRUE),
list(role = "system", content = "You are helpful")
expect_true(grepl("System: You are helpful", result1))
list(role = "system", content = "You are helpful"),
list(role = "assistant", content = "Hi there!")
expect_true(grepl("System: You are helpful", result2))
test_that("edge_stream_completion function signature and validation", {
# Test function exists and has proper signature
# Test parameter validation works before attempting model operations
edge_stream_completion(NULL, "test", function(x) TRUE, n_predict = -1),
"could not find function"  # Will error on internal function call
# Test that callback validation happens first
# Test that prompt validation happens first
edge_stream_completion(NULL, c("a", "b"), function(x) TRUE),
# Test valid parameters get to the internal function call
test_that("edge_stream_completion early stopping callback logic", {
# Test callback return value logic (without requiring model)
if (!data$is_final && data$position >= 3) {
mock_data <- list(is_final = FALSE, position = 5)
test_that("edge_stream_completion error handling in callbacks", {
# Test error-throwing callback functions
# Test that callback function itself can be created and is valid
expect_error(error_callback(list()), "Test error in callback")
if (!is.null(data$position) && data$position == 2) {
# Test with mock data that should trigger error
mock_error_data <- list(is_final = FALSE, position = 2)
# Test with mock data that should not trigger error
mock_ok_data <- list(is_final = FALSE, position = 1)
# Test that function exists and validates inputs properly
# Test special character handling in prompts
# Test that prompt validation works correctly with special characters
# Should not error on prompt validation itself
# This will error on the internal function call, not on prompt validation
# Expect error about missing internal function, not prompt validation
expect_true(grepl("could not find function", e$message))
test_that("Streaming callback function validation", {
# Test different callback function scenarios
# Test callback that returns different values