Workflow Demo - May 28, 2025
Start a conversation using a chat_*
function (like chat_anthropic, chat_openai, chat_ollama, etc.)
Two teens from feuding families fall in love, marry secretly, and die
tragically due to miscommunication.
Start a conversation using a Chat
object (like ChatAnthropic, ChatOpenAI, ChatOllama, etc.)
Two young lovers from feuding families meet, secretly marry, and tragically
die in a misunderstanding.
Continue the conversation by calling chat()
again.
Danish prince feigns madness to avenge his father's murder while contemplating
existence, ultimately causing multiple deaths including his own.
live_browser(client)
or live_console(client)
client.app()
or client.console()
library(ellmer)
system_prompt <- paste(
"You're a bot that answers questions based on this expense policy doc:",
"<expense_policy>",
readLines("expense-policy.md"),
"</expense_policy>",
"* Cite policy section numbers.",
"* Use examples when helpful.",
collapse = "\n"
)
client <- chat_anthropic(system_prompt, model = "claude-3-7-sonnet-latest")
client$chat("Can I expense a programming book?")
Based on the expense policy, programming books may be expensible under Training and Development (Section 3.4) if they're job-related and pre-approved. They would likely fall under "Courses and Certifications" which "must be job-related and approved by both the employee's manager and HR/L&D" (Section 3.4). Ensure you get proper pre-approval before purchasing.
library(ellmer)
system_prompt <- paste(
"You're a bot that helps data analysis for College Scorecard data.",
"Do not attempt to analyze data; however, you may suggest R code instead.",
"Use readr to read CSVs. You can assume Most-Recent-Cohorts-Institution.csv ",
"and Most-Recent-Cohorts-Field-of-Study.csv are in the working directory.",
"",
readLines("college_scorecard_data_summary.md"),
collapse = "\n"
)
client <- chat_anthropic(system_prompt, model = "claude-sonnet-4-20250514")
live_browser(client)
from chatlas import ChatAnthropic
with open("expense-policy.md", "r") as f:
expense_policy = f.read()
system_prompt = f"""
You're a dungeon master for a D&D style game whose theme is this
expense policy. Start with character creation.
<expense_policy>
{expense_policy}
</expense_policy>
"""
client = ChatAnthropic(
system_prompt=system_prompt,
model="claude-3-7-sonnet-latest",
)
client.app()
{shinychat}
ui.Chat
Blissful anticipation of a sweet treat.
Delightful anticipation.
library(ellmer)
image_info = type_object(
subject = type_string("The main subject of the image"),
object = type_string("The main object being acted upon"),
colors = type_array("Major colors present in the image",
type_string()
)
)
client <- chat_anthropic(model = "claude-3-5-haiku-latest")
client$chat_structured(
"Tell me about this image in the specified format.",
content_image_file("photo.jpg", resize="low"),
type = image_info
)
$subject
[1] "Child"
$object
[1] "S'more"
$colors
[1] "gray" "white" "brown"
from pydantic import BaseModel, Field
from chatlas import ChatAnthropic, content_image_file
class ImageInfo(BaseModel):
subject: str = Field("Main subject of the image")
object: str = Field("Main object being acted upon")
colors: list[str] = Field("Major colors present in the image")
client = ChatAnthropic(model = "claude-3-5-haiku-latest")
client.extract_data(
"Tell me about this image in the specified format.",
content_image_file("photo.jpg", resize="low"),
data_model = ImageInfo
)
{'subject': 'Child eating a snack',
'object': "S'more",
'colors': ['gray', 'white', 'brown']}
Another way to think of it: