Skip to content

Select different model from UI from selection of bedrock models #63

@Yousuf28

Description

@Yousuf28

`library(shiny)
library(bslib)
library(shinychat)
library(data.table)

df_mod <- ellmer::models_aws_bedrock(profile = NULL)
data.table::setDT(df_mod)
provider_name <- sort(unique(df_mod$provider))

ui <- page_fillable(
titlePanel("shinychat example"),
shiny::selectizeInput(inputId = 'provider',label= 'Select Provider',
choices=provider_name, selected='Anthropic'),
shiny::selectizeInput(inputId ='model' ,'Select Model', choices=NULL),
shiny::br(),
chat_mod_ui(
"claude",
messages = list(
"Hi! Use this chat interface to chat with AI Assistant"
)
)
)

server <- function(input, output, session) {

shiny::observeEvent(input$provider,{
shiny::req(input$provider)
mod_list <- unique(df_mod[provider==input$provider,id])
shiny::updateSelectizeInput(session = session,
inputId = 'model', choices = mod_list)
})

claude <- ellmer::chat_aws_bedrock(system_prompt = 'You are assistant in code writing for programmer. provide all the code in one block. do not need to explain the code.',
model='anthropic.claude-3-5-sonnet-20240620-v1:0'
)

chat_mod_server("claude", claude)
}

shinyApp(ui, server)
`

How can I change the model from user input in claude instance inside chat_mod_server("claude",claude) ?

Image

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions