Skip to content

Commit 8d7df74

Browse files
committed
Add grok
1 parent 9040e36 commit 8d7df74

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export(ask_bing_copilot)
1010
export(ask_chatgpt)
1111
export(ask_claude)
1212
export(ask_copilot)
13+
export(ask_grok)
1314
export(ask_meta_ai)
1415
export(ask_mistral)
1516
export(ask_perplexity)

R/ai-search-functions.R

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ ai_searcher = function(site) {
6565
#' This function allows you to ask questions, get code help,
6666
#' or search for information using ChatGPT.
6767
#'
68-
#' @param query Contents of string to send to ChatGPT. Default is the last error message.
69-
#' @param prompt Optional prompt prefix to add before your query to guide how ChatGPT
68+
#' @param query Contents of string to send to AI Service. Default is the last error message.
69+
#' @param prompt Optional prompt prefix to add before your query to guide how the AI Service
7070
#' responds. If NULL, uses the service-specific default prompt option.
7171
#'
7272
#' @return The generated search URL or an empty string.
@@ -173,6 +173,25 @@ ask_bing_copilot = ai_searcher("copilot")
173173
#' @export
174174
ask_copilot = ask_bing_copilot
175175

176+
#' Search with Grok
177+
#'
178+
#' Searches xAI's Grok, which provides AI assistance focused on
179+
#' maximize truth and objectivity.
180+
#'
181+
#' @inheritParams ask_chatgpt
182+
#' @return The generated search URL or an empty string.
183+
#'
184+
#' @export
185+
#' @family AI assistants
186+
#' @examples
187+
#' # Basic query
188+
#' ask_grok("What are the best practices for R package development?")
189+
#'
190+
#' # Using a custom prompt
191+
#' ask_grok("How to optimize this R code for performance?",
192+
#' prompt = "Focus on efficiency and best practices:")
193+
ask_grok = ai_searcher("grok")
194+
176195
#' Search with Meta AI
177196
#'
178197
#' Searches Meta AI, which provides general-purpose AI assistance

R/index-sites.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ site_index =
111111
site_entry("bing copilot", "https://www.bing.com/search?showconv=1&sendquery=1&q=",
112112
"copilot",
113113
keywords = NULL),
114+
site_entry("grok", "https://www.grok.com/?q=",
115+
keywords = NULL),
114116
site_entry("meta ai", "https://www.meta.ai/?q=",
115117
"meta",
116118
keywords = NULL)

man/ask_grok.Rd

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)