
Summarize or analyze one or more local documents using Gemini API
Source:R/gemini_docs.R
gemini_docs.Rd
Summarize, compare, or analyze the content of one or more local documents (PDF, TXT, HTML, etc.) using the Gemini API.
Usage
gemini_docs(
pdf_path,
prompt,
type = "PDF",
model = "2.5-flash",
api_key = Sys.getenv("GEMINI_API_KEY"),
large = FALSE,
local = FALSE
)
Arguments
- pdf_path
Path(s) to the local file(s). Can be a character vector.
- prompt
The prompt to send to Gemini (e.g., "Summarize these documents").
- type
File type. One of "PDF", "JavaScript", "Python", "TXT", "HTML", "CSS", "Markdown", "CSV", "XML", "RTF". Default is "PDF".
- model
The model to use. Default is '2.5-flash'. see https://ai.google.dev/gemini-api/docs/models/gemini
- api_key
Gemini API key. Defaults to
Sys.getenv("GEMINI_API_KEY")
. The API key is sent via the HTTP headerx-goog-api-key
.- large
Logical. If
TRUE
, use the file upload API for large files (only one file supported). Default isFALSE
.- local
Logical. If
TRUE
, treatpdf_path
as a local file path. IfFALSE
, download from URL. Default isFALSE
.
Details
This function encodes one or more local files, sends them along with a prompt to the Gemini API, and returns the generated summary or response.
Examples
if (FALSE) { # \dontrun{
gemini_docs(
pdf_path = c("doc1.pdf", "doc2.pdf"),
prompt = "Compare these documents",
type = "PDF",
model = "2.5-flash"
)
} # }