Factory function to create a new ChatSession object.
Usage
create_chat_session(
model = NULL,
system_prompt = NULL,
tools = NULL,
hooks = NULL,
max_steps = 10,
agent = NULL
)Examples
if (FALSE) { # \dontrun{
# Create a chat session
chat <- create_chat_session(
model = "openai:gpt-4o",
system_prompt = "You are a helpful R programming assistant."
)
# Create from an existing agent
agent <- create_agent("MathAgent", "Does math", system_prompt = "You are a math wizard.")
chat <- create_chat_session(model = "openai:gpt-4o", agent = agent)
# Send messages
response <- chat$send("How do I read a CSV file?")
print(response$text)
# Continue the conversation (history is maintained)
response <- chat$send("What about Excel files?")
# Check stats
print(chat$stats())
# Save session
chat$save("my_session.rds")
} # }