Skip to contents

These functions wrap shinychat::chat_ui() and shinychat::chat_server() with commons-specific answer provenance UI. Answers produced from registered measures get a compact verified-answer pill. Answers produced from fallback SQL or R can cite text from the agent's context, measure definitions, or data documentation; verified citations render as footnotes whose tooltips name their source. Fallback answers with no verified citation get an untrusted caution pill.

Usage

commons_ui(id, ...)

commons_server(id, client, ...)

Arguments

id

The ID of the chat element; must match between commons_ui() and commons_server().

...

In commons_ui(), extra arguments passed to shinychat::chat_ui(). In commons_server(), arguments passed to shinychat::chat_server().

client

A commons() agent. Create a new agent for each Shiny session.

Value

commons_ui() returns UI. commons_server() returns the shinychat::chat_server() result.

Examples

if (FALSE) { # \dontrun{
library(shiny)

ui <- page_fillable(
  commons_ui("chat")
)

server <- function(input, output, session) {
  agent <- commons(
    ellmer::chat_anthropic(),
    data_sources = data_source(sales = sales)
  )
  commons_server("chat", agent)
}

shinyApp(ui, server)
} # }