These functions wrap shinychat::chat_app(), shinychat::chat_ui(), and
shinychat::chat_server() for commons agents. The server verifies each
<commons-citation> the model writes against its own context, measure
definitions, and data documentation as the answer streams, and rewrites
verified citations inline as numbered, server-authored <shiny-aside>
elements. Citation details name the trusted source.
A compact provenance aside follows the answer when it was produced by a
governed calculation, or when a fallback answer cites nothing verified.
Arguments
- client
A
commons()agent. Create a new agent for each Shiny session.- ...
In
commons_app(), extra arguments passed toshiny::shinyApp(). Incommons_ui(), extra arguments passed toshinychat::chat_ui(). Incommons_server(), arguments passed toshinychat::chat_server().- id
The ID of the chat element; must match between
commons_ui()andcommons_server().
Value
commons_app() returns a shiny::shinyApp() object. commons_ui()
returns UI. commons_server() returns the shinychat::chat_server()
result.
Examples
if (FALSE) { # \dontrun{
agent <- commons(
ellmer::chat_anthropic(),
data_sources = data_source(sales = sales)
)
commons_app(agent)
# Inside a custom Shiny app
library(shiny)
ui <- bslib::page_fillable(
commons_ui("chat")
)
server <- function(input, output, session) {
session_agent <- commons(
ellmer::chat_anthropic(),
data_sources = data_source(sales = sales)
)
commons_server("chat", session_agent)
}
shinyApp(ui, server)
} # }
