tidyprompt0.3.0 package

Prompt Large Language Models and Enhance Their Functionality

add_image

Add an image to a tidyprompt (multimodal)

add_msg_to_chat_history

Add a message to a chat history

add_text

Add text to a tidyprompt

answer_as_boolean

Make LLM answer as a boolean (TRUE or FALSE)

answer_as_category

Make LLM answer as a category

answer_as_integer

Make LLM answer as an integer (between min and max)

answer_as_json

Make LLM answer as JSON (with optional schema; structured output)

answer_as_key_value

Make LLM answer as a list of key-value pairs

answer_as_list

Make LLM answer as a list of items

answer_as_multi_category

Build prompt for categorizing a text into multiple categories

answer_as_named_list

Make LLM answer as a named list

answer_as_regex_match

Make LLM answer match a specific regex

answer_as_text

Make LLM answer as a constrained text response

answer_by_chain_of_thought

Set chain of thought mode for a prompt

answer_by_react

Set ReAct mode for a prompt

answer_using_r

Enable LLM to draft and execute R code

answer_using_sql

Enable LLM to draft and execute SQL queries on a database

answer_using_tools

Enable LLM to call R functions (and/or MCP server tools)

chat_history.character

Method for chat_history() when the input is a single string

chat_history.data.frame

Method for chat_history() when the input is a data.frame

chat_history.default

Default method for chat_history()

chat_history

Create or validate chat_history object

construct_prompt_text

Construct prompt text from a tidyprompt object

df_to_string

Convert a dataframe to a string representation

extract_from_return_list

Function to extract a specific element from a list

get_chat_history

Get the chat history of a tidyprompt object

get_prompt_wraps

Get prompt wraps from a tidyprompt object

is_tidyprompt

Check if object is a tidyprompt object

llm_break_soft

Create an llm_break_soft object

llm_break

Create an llm_break object

llm_feedback

Create an llm_feedback object

llm_provider_ellmer

Create a new LLM provider from an ellmer::chat() object

llm_provider_google_gemini

Create a new Google Gemini LLM provider

llm_provider_groq

Create a new Groq LLM provider

llm_provider_mistral

Create a new Mistral LLM provider

llm_provider_ollama

Create a new Ollama LLM provider

llm_provider_openai

Create a new OpenAI LLM provider

llm_provider_openrouter

Create a new OpenRouter LLM provider

llm_provider_xai

Create a new XAI (Grok) LLM provider

llm_provider-class

LlmProvider R6 Class

llm_verify

Have LLM check the result of a prompt (LLM-in-the-loop)

persistent_chat-class

PersistentChat R6 class

prompt_wrap

Wrap a prompt with functions for modification and handling the LLM res...

provider_prompt_wrap

Create a provider-level prompt wrap

quit_if

Make evaluation of a prompt stop if LLM gives a specific response

r_json_schema_to_example

Generate an example object from a JSON schema

send_prompt

Send a prompt to a LLM provider

set_chat_history

Set the chat history of a tidyprompt object

set_system_prompt

Set system prompt of a tidyprompt object

skim_with_labels_and_levels

Skim a dataframe and include labels and levels

tidyprompt-class

Tidyprompt R6 Class

tidyprompt-package

tidyprompt: Prompt Large Language Models and Enhance Their Functionali...

tidyprompt

Create a tidyprompt object

tools_add_docs

Add tidyprompt function documentation to a function

tools_get_docs

Extract documentation from a function

user_verify

Have user check the result of a prompt (human-in-the-loop)

vector_list_to_string

Convert a named or unnamed list/vector to a string representation

Easily construct prompts and associated logic for interacting with large language models (LLMs). 'tidyprompt' introduces the concept of prompt wraps, which are building blocks that you can use to quickly turn a simple prompt into a complex one. Prompt wraps do not just modify the prompt text, but also add extraction and validation functions that will be applied to the response of the LLM. This ensures that the user gets the desired output. 'tidyprompt' can add various features to prompts and their evaluation by LLMs, such as structured output, automatic feedback, retries, reasoning modes, autonomous R function calling, and R code generation and evaluation. It is designed to be compatible with any LLM provider that offers chat completion.

  • Maintainer: Luka Koning
  • License: GPL (>= 3) | file LICENSE
  • Last published: 2025-11-30