Hi. After the presentation of "Harnessing LLMs for Data Analysis", I felt impressed for the technology and have tried it by myself.
But I have two main problems for using querychat package in R.
I do not have so much knowledge about shiny and shinychat, so I would be happy if somebodies help and give any advices. I am completely stacked.
Problems:
- The "greeting" message does not appear on the chat box.
- After input and order in the chat box, the AI is still working with showing three dots, "...". for minutes. I waited for 20 mins, but nothing changed.
Environment:
- R version: R.4.5.0
- Deployment: https://connect.posit.cloud/ via Github (free option)
- AI: Anthropic (API purchased) API values are assigned on Configure variables on connect.posit.colod
- Shiny: Free version
What I tried:
- Tried OPENAI_API_KEY with free version. -> a same result.
- Reffered to the codes of Mr.jacobpstein. -> a same result.
Screenshots:
- No greeting message:
- three dots working.
Codes (used example codes on "querychat" on Github. :
ANTHROPIC_API_KEY <- Sys.getenv("ANTHROPIC_API_KEY")
library(shiny)
library(bslib)
library(querychat)
# 1. Configure querychat. This is where you specify the dataset and can also
# override options like the greeting message, system prompt, model, etc.
querychat_config <- querychat_init(mtcars,
greeting = "Hello! Tell me about something.",
create_chat_func = purrr::partial(
ellmer::chat_anthropic,
model = "claude-3-5-sonnet-20241022"
)
)
ui <- page_sidebar(
# 2. Use querychat_sidebar(id) in a bslib::page_sidebar.
# Alternatively, use querychat_ui(id) elsewhere if you don't want your
# chat interface to live in a sidebar.
sidebar = querychat_sidebar("chat"),
DT::DTOutput("dt")
)
server <- function(input, output, session) {
# 3. Create a querychat object using the config from step 1.
querychat <- querychat_server("chat", querychat_config)
output$dt <- DT::renderDT({
# 4. Use the filtered/sorted data frame anywhere you wish, via the
# querychat$df() reactive.
DT::datatable(querychat$df())
})
}
shinyApp(ui, server)