elmer abstracts away differences in the way that different Providers represent various types of content, allowing you to more easily write code that works with any chatbot.
This set of classes represents the various types of content that can be sent to and received from a provider:
ContentText
: simple text (often in markdown format). This is the only type of content that can be streamed live as it's received.ContentImageRemote
andContentImageInline
: images, either as a pointer to a remote URL or included inline in the object. Seecontent_image_file()
and friends for convenient ways to construct these objects.ContentToolRequest
: a request to perform a tool call (sent by the assistant).ContentToolResult
: the result of calling the tool (sent by the user).
Usage
Content()
ContentText(text = character(0))
ContentImage()
ContentImageRemote(url = character(0), detail = character(0))
ContentImageInline(type = character(0), data = NULL)
ContentToolRequest(id = character(0), name = character(0), arguments = list())
ContentToolResult(id = character(0), value = NULL, error = NULL)
Arguments
- text
A single string.
- url
URL to a remote image.
- detail
Not currently used.
- type
MIME type of the image.
- data
Base64 encoded image data.
- id
Tool call id (used to associate a request and a result)
- name
Function name
- arguments
Named list of arguments to call the function with.
- value, error
Either the results of calling the function if it succeeded, otherwise the error message, as a string. One of
value
anderror
will always beNULL
.