Package 'clinChat'

Title: Conversational Interfaces for Clinical Data with Large Language Models
Description: Provides tools and Shiny applications for interacting with clinical datasets through natural language using large language models. Built on 'ellmer' and 'shinychat', it emphasizes privacy-aware workflows where data remains local and only necessary summaries or tool results are shared with the model. Includes ready-to-use chat interfaces for exploratory analysis, summarization, and querying of clinical data.
Authors: Shekhar Chalwadi [aut, cre]
Maintainer: Shekhar Chalwadi <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-11-11 23:56:36 UTC
Source: https://github.com/cran/clinChat

Help Index


Conversational Interfaces for Clinical Data with Large Language Models

Description

Provides tools and Shiny applications for interacting with clinical datasets through natural language using large language models. Built on ellmer and shinychat, it emphasizes privacy-aware workflows where data remains local and only necessary summaries or tool results are shared with the model.

Author(s)

Shekhar Chalwadi [email protected]

See Also

Useful links:


Generate a list of tools for clinical data exploration

Description

Generate a list of tools for clinical data exploration.

Usage

clinical_tools(data)

Arguments

data

A data.frame.

Value

A list of ellmer tool objects.


Create a clinical data chat object

Description

Creates an ellmer::Chat object pre-configured with tools for exploring a clinical dataset. Data remains local; only tool results are shared with the model.

Usage

create_clinical_chat(data, system_prompt = NULL, provider = NULL, ...)

Arguments

data

A data.frame containing clinical data.

system_prompt

Character. System prompt for the model. Defaults to a clinical analyst persona that emphasizes accuracy and privacy.

provider

Character or NULL. Provider string for ellmer::chat(), e.g. "openai/gpt-4o-mini". If NULL, uses the default from ellmer.

...

Additional arguments passed to ellmer::chat().

Value

An ellmer Chat object with clinical tools registered.

Examples

# Create sample clinical data (executable)
data <- data.frame(
  patient_id = 1:20,
  age = sample(25:80, 20, replace = TRUE),
  sex = sample(c("M", "F"), 20, replace = TRUE),
  outcome = sample(c("responder", "non-responder"), 20, replace = TRUE)
)

# Inspect available tools (no API key required)
tools <- clinical_tools(data)
length(tools)

# Creating a chat object requires a configured LLM provider
if (FALSE) {
  chat <- create_clinical_chat(data, provider = "openai/gpt-4o-mini")
  # chat$chat("How many responders are there by sex?")
}

Launch a Shiny chat application for clinical data

Description

Starts an interactive Shiny app that lets users chat with a clinical dataset using a large language model. Uses shinychat for the interface and ellmer for the model backend.

Usage

run_clinchat_app(
  data,
  system_prompt = NULL,
  provider = NULL,
  title = "Clinical Data Chat",
  ...
)

Arguments

data

A data.frame of clinical data.

system_prompt

Optional custom system prompt.

provider

Provider string for ellmer (e.g. "openai/gpt-4o-mini").

title

Title shown in the app.

...

Additional arguments passed to shiny::runApp().

Value

Invisibly returns the Shiny app object. Called for its side effect of launching the app.

Examples

# Sample data
data <- iris[1:20, ]

# Launching the app requires a configured LLM provider
if (FALSE) {
  run_clinchat_app(data, title = "Iris Explorer")
}