generate {ollamar}R Documentation

Generate a completion.

Description

Generate a response for a given prompt with a provided model.

Usage

generate(
  model,
  prompt,
  stream = FALSE,
  output = c("resp", "jsonlist", "raw", "df"),
  endpoint = "/api/generate"
)

Arguments

model

A character string of the model name such as "llama3".

prompt

A character string of the promp like "The sky is..."

stream

Enable response streaming. Default is FALSE.

output

A character vector of the output format. Default is "resp". Options are "resp", "jsonlist", "raw", "df".

endpoint

The endpoint to generate the completion. Default is "/api/generate".

Value

A response in the format specified in the output parameter.

Examples


generate("llama3", "The sky is...", stream = FALSE, output = "df")
generate("llama3", "The sky is...", stream = TRUE, output = "df")
generate("llama3", "The sky is...", stream = FALSE, output = "jsonlist")


[Package ollamar version 1.1.1 Index]