The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
R package to use Google’s gemini via API on R
install.packages("gemini.R")
install.packages("gemini.R",
repos = c("https://jhk0530.r-universe.dev", "https://cloud.r-project.org")
)
# install.packages("pak")
::pak("jhk0530/gemini.R") pak
library(gemini.R)
setAPI("your API key") # check https://makersuite.google.com/app/apikey
gemini("Explain about the gemini in astrology in one line")
# text
# "Gemini, the third astrological sign, is associated with
# communication, adaptability, and a thirst for knowledge."
# uses default prompt as "Explain this image"
# uses included image of gemini.R package
gemini_image(image = system.file("docs/reference/figures/image.png", package = "gemini.R"))
# text
# " The image shows a table with a white tablecloth. On the table are two cups of coffee,
# a bowl of blueberries, and five scones. The scones are covered in blueberries and have
# a crumbly texture. There are also some pink flowers on the table. The background is a
# dark blue color. The image is taken from a top-down perspective."
To use gemini_image
function, image file required. and I
recommend to use shiny app with fileInput
function.
library(shiny)
library(gemini.R)
setAPI("YOUR KEY")
<- fluidPage(
ui sidebarLayout(
NULL,
mainPanel(
fileInput(
inputId = "file",
label = "Choose file to upload",
),imageOutput(outputId = "image1"),
textInput(
inputId = "prompt",
label = "Prompt",
placeholder = "Enter Prompts Here"
),actionButton("goButton", "Ask to gemini"),
textOutput("text1")
)
)
)
<- function(input, output) {
server
observeEvent(input$file, {
<- input$file$datapath
path $image1 <- renderImage({
outputlist(
src = path
)deleteFile = FALSE)
},
})
observeEvent(input$goButton, {
$text1 <- renderText({
outputgemini_image(input$prompt, input$file$datapath)
})
})
}
shinyApp(ui = ui, server = server)
You may customize keyboard shortcut for this feature.
Before use the API, I recommend that you to check at least the following. - Google Cloud Platform Terms of Service - Gemini API Additional Terms of Service
There may be more terms and conditions that you need to check. Any app which uses the API should be compliant with the Google Terms of Service.
[!note]
image is from Google AI for Developers
I’ve got many inspiration from Deepanshu Bhalla’s article
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.