Sends messages to an assistant and receives responses with citations. This is the recommended chat interface, offering more functionality than the OpenAI-compatible interface.
Usage
assistant_chat(
assistant_name,
messages,
model = NULL,
filter = NULL,
context_options = NULL
)Arguments
- assistant_name
Name of the assistant
- messages
List of message objects. Each message should have: - role: Either "user" or "assistant" - content: The message text
- model
Optional model to use (e.g., "gpt-4o"). Uses assistant default if not specified.
- filter
Optional metadata filter to limit which files are searched (list)
- context_options
Optional list of context options: - top_k: Number of context chunks to retrieve (default: 15) - snippet_size: Maximum size of each snippet in tokens - multimodal: Whether to include image context for PDFs (default: TRUE) - include_binary_content: Include base64 image data when multimodal is TRUE
Value
List with http response, content (chat response), and status_code. Content includes: - id: Response ID - model: Model used - message: Response message with role and content - finish_reason: Reason for completion ("stop", etc.) - citations: List of citations referencing source documents - usage: Token usage statistics
Examples
if (FALSE) { # \dontrun{
# Simple chat
assistant_chat(
assistant_name = "my-assistant",
messages = list(
list(role = "user", content = "What is the main topic of the document?")
)
)
# Chat with conversation history
assistant_chat(
assistant_name = "my-assistant",
messages = list(
list(role = "user", content = "Who is the CEO?"),
list(role = "assistant", content = "The CEO is John Smith."),
list(role = "user", content = "When did they start?")
)
)
# Chat with metadata filter
assistant_chat(
assistant_name = "my-assistant",
messages = list(list(role = "user", content = "Summarize the 2023 report")),
filter = list(year = 2023)
)
# Chat with context options
assistant_chat(
assistant_name = "my-assistant",
messages = list(list(role = "user", content = "Describe the images")),
context_options = list(
multimodal = TRUE,
include_binary_content = TRUE,
top_k = 10
)
)
} # }