Learn R Programming

tidyllm (version 0.1.0)

df_llm_message: Convert a Data Frame to an LLMMessage Object

Description

This function takes a data frame and converts it into an LLMMessage object representing a conversation history. The data frame should contain specific columns (role and content) with each row representing a message in the conversation.

Usage

df_llm_message(.df)

Value

An LLMMessage object containing the structured messages as per the input data frame.

Arguments

.df

A data frame with at least two rows and columns role and content. The column role should contain values from "user", "assistant", or "system", and content should be of type character.

Examples

Run this code
# Example data frame with role and content
df_example <- data.frame(
 role = c("system", "user", "assistant","user"),
 content = c("You allways only answer with two words", 
              "Why is the sky blue?", 
              "Rayleigh scattering",
              "Why is the sun yellow?"),
 stringsAsFactors = FALSE
)
df_llm_message(df_example)

Run the code above in your browser using DataLab