-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
QueryChat doesn't appear to work properly when using it inside a module. The chat spinner just spins indefinitely.
In the examples I've found so far, the qc object is initialized at the global level. However, it works as expected when initialized in the server w/o shiny modules. My motivation for doing it this way is to be able to pass data.tables/data.frames that are created within an app. I also noticed that when using renderUI, the greeting message does not appear and am wondering if it's related to this issue. Ultimately, I think it's a name spacing issue with mod_ui/server but I can't track it down.
Really appreciate any help!
Reprex below
library(shiny)
library(bslib)
library(querychat)
library(ellmer)
options(duckdb.debug = T)
# Module UI
test_module_ui <- function(id) {
ns <- NS(id)
page_fluid(
card(
DT::DTOutput(ns("dt"))
),
card(
uiOutput(ns("querychat_sidebar"))
)
)
}
# Module Server
test_module_server <- function(id) {
moduleServer(id, function(input, output, session) {
ns <- session$ns
message("Module ID: ", id)
message("Session namespace: ", session$ns(NULL))
# Create QueryChat instance
qc <- QueryChat$new(
mtcars,
id = id,
client = ellmer::chat_aws_bedrock(model = "us.anthropic.claude-sonnet-4-5-20250929-v1:0"),
greeting = "Ask me about mtcars!"
)
message("QueryChat created with ID: ", qc$id)
# Initialize the QueryChat server
qc_vals <- qc$server()
# Render the QueryChat UI
output$querychat_sidebar <- renderUI({
qc$ui()
})
# Render the data table
output$dt <- DT::renderDT({
DT::datatable(qc_vals$df())
})
})
}
# Main App UI
ui <- fluidPage(
titlePanel("QueryChat Module Test"),
test_module_ui("test_module")
)
# Main App Server
server <- function(input, output, session) {
test_module_server("test_module")
}
shinyApp(ui, server)
Metadata
Metadata
Assignees
Labels
No labels
