Skip to contents

Ollamar functions

API endpoints

Make calls to the Ollama server/API.

generate()
Generate a response for a given prompt
chat()
Generate a chat completion with message history
create()
Create a model from a Modelfile
list_models()
List models that are available locally
show()
Show model information
copy()
Copy a model
delete()
Delete a model and its data
pull()
Pull/download a model from the Ollama library
push()
Push or upload a model to a model library
embed()
Generate embedding for inputs
embeddings()
Generate embeddings for a single prompt - deprecated in favor of embed()
ps()
List models that are currently loaded into memory

API helpers

Work with and extend the Ollama API.

resp_process()
Process httr2 response object
ohelp()
Chat with a model in real-time in R console
model_avail()
Check if model is available locally
image_encode_base64()
Read image file and encode it to base64
test_connection()
Test connection to Ollama server
create_request()
Create a httr2 request object

Manipulate chat history

Manipulate chat history for Ollama and other LLM providers.

create_messages()
Create a list of messages
create_message()
Create a message
append_message()
Append message to a list
prepend_message()
Prepend message to a list
delete_message()
Delete a message in a specified position from a list
insert_message()
Insert message into a list at a specified position
validate_message()
Validate a message
validate_messages()
Validate a list of messages
encode_images_in_messages()
Encode images in messages to base64 format

Model options

Functions to get information about the options available.

check_option_valid()
Check if an option is valid
check_options()
Check if a vector of options are valid
search_options()
Search for options based on a query
validate_options()
Validate additional options or parameters provided to the API call

Internal functions and variables

Functions and variables used internally by the package.

package_config
Package configuration
model_options
Model options
stream_handler()
Stream handler helper function
resp_process_stream()
Process httr2 response object for streaming