Beyond Tools

Programming with LLM APIs
A Beginner’s Guide in R and Python

posit::conf(2025)

2025-09-16

querychat in R

library(shiny)
library(bslib)
library(querychat)

mtcars_qc_config <- querychat_init(mtcars)

ui <- page_sidebar(
  sidebar = querychat_sidebar("mtcars"),
  # plots, tables, etc.
)

server <- function(input, output, session) {
  mtcars_qc <- querychat_server("mtcars", mtcars_qc_config)

  output$table <- renderTable({
    mtcars_qc$df()
  })
}

shinyApp(ui, server)

querychat in Python

import polars as pl
import querychat
from shiny import App, render, ui

mtcars = pl.read_csv("data/mtcars.csv")

mtcars_qc_config = querychat.init(mtcars, "mtcars")

app_ui = ui.page_sidebar(
    querychat.sidebar("mtcars"),
    # plots, tables, etc.
)

def server(input, output, session):
    mtcars_qc = querychat.server("mtcars", mtcars_qc_config)

    @render.data_frame
    def data_table():
        return qc.df()

app = App(app_ui, server)

Your Turn 25_querychat

  1. I’ve made a Shiny dashboard to explore Airbnb listings in Asheville, NC.

    • Spend 1-2 min: which Neighborhood has most private rooms?
  2. Work through the steps in the comments to use querychat.

  3. Spend a few minutes exploring the data and chatting with the app.
    Which area has the most private rooms?

08:00

MCP

Recall: Tools

a.k.a. functions, tool calling or function calling

  • Bring real-time or up-to-date information to the model

  • Let the model interact with the world

🤔 What other tools could be useful?

  • Get the weather
  • Search the posit::conf() schedule
  • ...

Who should write tools for GitHub?

MCP solves this problem! GitHub writes tools…

and lets you your models use them.

GitHub MCP Server

Your Turn 26_mcp

Follow the instructions in README.R.md or README.py.md for this task.

  1. What MCP servers are out there?

  2. Set up context7 as an MCP server in Positron.

  3. Use context7 tools to answer a coding translation question.

06:00

Agents

What’s an agent?

  • Hadley/Willison definition: Agents are LLMs with a read tool and a write tool

  • The “you know it when you see it” definition: autonomous LLMs, long context, minimal intervention

Demo: Databot

👨‍💻 _demos/27_demo_databot/README.md

Let’s look at data/airbnb-asheville.csv, do some basic work to familiarize ourselves with the data, and then find interesting patterns that would be relevant to someone looking to open an Airbnb in Asheville, NC.

The Future of AI

Please take 5-10 minutes to fill out the workshop survey.
Your feedback is important to us!

pos.it/conf-workshop-survey

Enjoy posit::conf(2025)!