diff --git a/DESCRIPTION b/DESCRIPTION index 3fcaf1e..8b8fa91 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: searcher -Title: Query Search Interfaces -Version: 0.0.7.2 +Title: Query Search Interfaces and AI Assistants +Version: 0.1.0 Authors@R: c( person("James", "Balamuta", email = "balamut2@illinois.edu", @@ -13,11 +13,17 @@ Authors@R: c( comment = c(ORCID = "0000-0001-9412-0457") ) ) -Description: Provides a search interface to look up terms - on 'Google', 'Bing', 'DuckDuckGo', 'Startpage', 'Ecosia', 'rseek', - 'Twitter', 'StackOverflow', 'RStudio Community', 'GitHub', and 'BitBucket'. - Upon searching, a browser window will open with the aforementioned search - results. +Description: Provides search interfaces to look up terms on major search engines + including 'Google', 'Bing', 'DuckDuckGo', 'Startpage', 'Ecosia', 'Brave', + 'Kagi', 'rseek', social platforms like 'X' (formerly Twitter), 'BlueSky', + 'Mastodon', programming communities such as 'StackOverflow', 'Posit Community', + and code repositories including 'GitHub', 'grep.app', and 'BitBucket'. + Additionally, provides direct integration with AI assistants through + specialized query functions for 'ChatGPT', 'Claude AI', 'Perplexity AI', + 'Mistral AI', 'Microsoft Copilot', and 'Meta AI', complete with an AI prompt + management system for R-optimized interactions. Upon searching or querying, + a browser window will open with the search results or AI interface pre-populated + with the specified query. URL: https://github.com/coatless-rpkg/searcher, https://r-pkg.thecoatlessprofessor.com/searcher/ BugReports: https://github.com/coatless-rpkg/searcher/issues Depends: R (>= 3.3.0) diff --git a/NAMESPACE b/NAMESPACE index 0e92b8a..c5fd5d9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,9 +10,12 @@ export(ask_bing_copilot) export(ask_chatgpt) export(ask_claude) export(ask_copilot) +export(ask_grok) +export(ask_le_chat) export(ask_meta_ai) export(ask_mistral) export(ask_perplexity) +export(ask_xai) export(search_bb) export(search_bing) export(search_bitbucket) diff --git a/NEWS.md b/NEWS.md index aa8cd92..81c6dcb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,14 +1,15 @@ -# searcher 0.0.8 +# searcher 0.1.0 ## Features - Added GenAI Search Portals: - - `ask_chatgpt()`: Searches with ChatGPT - - `ask_claude()`: Searches with Claude AI - - `ask_perplexity()`: Searches with Perplexity AI - - `ask_mistral()`: Searches with Mistral AI - - `ask_copilot()`: Searches with Microsoft Bing's Copilot - - `ask_meta_ai()`: Searches with Meta AI + - `ask_chatgpt()`: Discuss with OpenAI's ChatGPT + - `ask_claude()`: Discuss with Anthropic's Claude AI + - `ask_perplexity()`: Discuss with Perplexity AI + - `ask_mistral()`/`ask_le_chat()`: Discuss with Mistral AI's Le Chat + - `ask_copilot()`: Discuss with Microsoft Bing's Copilot + - `ask_xai()`/`ask_grok()`: Discuss with xAI's Grok + - `ask_meta_ai()`: Discuss with Meta AI - Added an AI Prompt Management System with Persona Prompts: - `ai_prompt()`: Set a prompt for the AI - `ai_prompt_active()`: View the active prompt @@ -17,7 +18,7 @@ - `ai_prompt_register()`: Add a custom prompt - `ai_prompt_remove()`: Remove a prompt - Added new vignettes: - - `search-with-ai-assistants.Rmd`: Overview of the AI Searching Techniques + - `using-ai-assistants-with-searcher.Rmd`: Overview of the AI Searching Techniques - `managing-ai-prompts.Rmd`: Overview of `searcher`'s AI Prompt Management System - Added search portals: - `search_brave()`: Searches on Brave. @@ -42,9 +43,9 @@ - Reorganized search functions into separate help pages by category: - Search engines (Google, Bing, etc.) + - AI assistants (ChatGPT, Claude, etc.) - Community sites (StackOverflow, Twitter, etc.) - Code repositories (GitHub, BitBucket, etc.) - - AI assistants (ChatGPT, Claude, etc.) - Implemented `@family` tags to group related functions in the "See also" section - Added more specific, relevant examples for each function - Added brief descriptions of each AI service's strengths and characteristics diff --git a/R/ai-search-functions.R b/R/ai-search-functions.R index c748507..06771b3 100644 --- a/R/ai-search-functions.R +++ b/R/ai-search-functions.R @@ -65,8 +65,8 @@ ai_searcher = function(site) { #' This function allows you to ask questions, get code help, #' or search for information using ChatGPT. #' -#' @param query Contents of string to send to ChatGPT. Default is the last error message. -#' @param prompt Optional prompt prefix to add before your query to guide how ChatGPT +#' @param query Contents of string to send to AI Service. Default is the last error message. +#' @param prompt Optional prompt prefix to add before your query to guide how the AI Service #' responds. If NULL, uses the service-specific default prompt option. #' #' @return The generated search URL or an empty string. @@ -149,6 +149,11 @@ ask_perplexity = ai_searcher("perplexity") #' prompt = "Explain the error and fix it:") ask_mistral = ai_searcher("mistral") + +#' @rdname ask_mistral +#' @export +ask_le_chat = ask_mistral + #' Search with Bing Copilot #' #' Searches Microsoft Bing Copilot, which combines web search results @@ -173,6 +178,29 @@ ask_bing_copilot = ai_searcher("copilot") #' @export ask_copilot = ask_bing_copilot +#' Search with Grok +#' +#' Searches xAI's Grok, which provides AI assistance focused on +#' maximize truth and objectivity. +#' +#' @inheritParams ask_chatgpt +#' @return The generated search URL or an empty string. +#' +#' @export +#' @family AI assistants +#' @examples +#' # Basic query +#' ask_grok("What are the best practices for R package development?") +#' +#' # Using a custom prompt +#' ask_grok("How to optimize this R code for performance?", +#' prompt = "Focus on efficiency and best practices:") +ask_grok = ai_searcher("grok") + +#' @rdname ask_grok +#' @export +ask_xai = ask_grok + #' Search with Meta AI #' #' Searches Meta AI, which provides general-purpose AI assistance diff --git a/R/index-sites.R b/R/index-sites.R index 8360000..fad7d07 100644 --- a/R/index-sites.R +++ b/R/index-sites.R @@ -111,6 +111,8 @@ site_index = site_entry("bing copilot", "https://www.bing.com/search?showconv=1&sendquery=1&q=", "copilot", keywords = NULL), + site_entry("grok", "https://www.grok.com/?q=", + keywords = NULL), site_entry("meta ai", "https://www.meta.ai/?q=", "meta", keywords = NULL) diff --git a/R/search-functions.R b/R/search-functions.R index d10bb31..9182795 100644 --- a/R/search-functions.R +++ b/R/search-functions.R @@ -11,8 +11,8 @@ #' `"twitter"` or `"x"`, `"bluesky"`, `"mastodon"`, `"stackoverflow"`, #' `"github"`, `"grep"`, `"bitbucket"`, #' `"chatgpt"`, `"claude"`, `"perplexity"`, -#' `"mistral"`, `"bing copilot"` or `"copilot"`, and -#' `"meta ai"` or `"meta"`. +#' `"mistral"` or `"le chat"`, `"bing copilot"` or `"copilot"`, and +#' `"grok"` or `"xai"`, `"meta ai"` or `"meta"`. #' @param query Contents of string to search. Default is the error message. #' @param rlang Search for results written in R. Default is `TRUE` #' @param prompt Optional prompt prefix to add before your query to guide how the AI @@ -56,6 +56,7 @@ search_site = function(query, "mistral", "bing copilot", "copilot", + "grok", "meta ai", "meta" ), @@ -92,9 +93,12 @@ search_site = function(query, chatgpt = ask_chatgpt(query, prompt), claude = ask_claude(query, prompt), perplexity = ask_perplexity(query, prompt), + `le chat` = , # empty case carried below mistral = ask_mistral(query, prompt), `bing copilot` = , # empty case carried below copilot = ask_bing_copilot(query, prompt), + xai = , # empty case carried below + grok = ask_grok(query, prompt), `meta ai` = , # empty case carried below, meta = ask_meta_ai(query, prompt) ) diff --git a/README.Rmd b/README.Rmd index 1d45a35..994bf03 100644 --- a/README.Rmd +++ b/README.Rmd @@ -127,6 +127,12 @@ search_bitbucket("assertions", rlang = FALSE) # or search_bb(...) ## AI Assistants The package also provides functions to query AI assistants directly from R. +The following AI Assistant platforms are supported: OpenAI's [ChatGPT](https://chatgpt.com/), +Anthropic's [Claude](https://claude.ai/), +[Perplexity](https://www.perplexity.ai/), +Microsoft (Bing)'s [Copilot](https://copilot.microsoft.com/), +Mistral's [le Chat](https://chat.mistral.ai/chat), +xAI's [Grok](https://grok.com/), and [Meta.ai](https://www.meta.ai/). These functions open a browser with your query pre-filled, using customizable prompts that help the AI give more effective responses for R programming: @@ -137,6 +143,7 @@ ask_claude("Explain what purrr::map_df does") ask_perplexity("Compare dplyr vs data.table performance") ask_mistral("How to handle missing data in R?") ask_bing_copilot("Write a function to calculate the median") +ask_grok("What is better base R or tidyverse for research?") ask_meta_ai("What are the best R packages for time series analysis?") # Search with an error message @@ -157,7 +164,7 @@ ask_chatgpt( ) ``` -See `vignette("search-with-ai-assistants", package = "searcher")` for more +See `vignette("using-ai-assistants-with-searcher", package = "searcher")` for more details on using AI assistants in searches through `searcher`. ## AI Prompt Management diff --git a/README.md b/README.md index 5e3dce3..dfb4ab5 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,12 @@ The goal of `searcher` is to provide a search interface directly inside of *R*. For example, to look up `rcpp example numeric vector` or `ggplot2 fix axis labels` call one of the `search_*()` functions to automatically have a web browser open, go to a search site, and type the -query. `searcher` also provides direct integration with AI assistants, -allowing you to send queries to ChatGPT, Claude, and other AI services -with R-optimized prompts. By default, the search functions will attempt -to search the last error on call if no query is specified. +query. `searcher` also provides direct integration with AI assistants +through `ask_*()` functions, allowing you to send queries to ChatGPT, +Claude, and other AI services with R-optimized prompts. + +By default, the search and ask functions will attempt to search the last +error on call if no query is specified.
- %\VignetteIndexEntry{Frequently Asked Questions (FAQ) about searcher} + %\VignetteIndexEntry{Frequently Asked Questions (FAQ)} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- @@ -60,7 +60,7 @@ The package supports multiple types of platforms: - **Search Engines** - Google, Bing, DuckDuckGo, Startpage, Ecosia, Qwant, Brave, Kagi, Rseek - **AI Assistants** - - ChatGPT, Claude, Perplexity, Mistral, Bing Copilot, Meta AI + - ChatGPT, Claude, Perplexity, Mistral, Microsoft (Bing)'s Copilot, Grok, Meta AI - **Developer Communities** - StackOverflow, Posit Community, Twitter/X, Mastodon, BlueSky - **Code Repositories** @@ -215,7 +215,7 @@ ai_prompt("As an R educator, explain this concept in detail:") ask_chatgpt("What is the tidyverse?") ``` -See `vignette("search-with-ai-assistants", "searcher")` for more details on +See `vignette("using-ai-assistants-with-searcher", "searcher")` for more details on effective prompting. ## Prompt Management diff --git a/vignettes/managing-ai-prompts.Rmd b/vignettes/managing-ai-prompts.Rmd index 9f7166f..a1f84af 100644 --- a/vignettes/managing-ai-prompts.Rmd +++ b/vignettes/managing-ai-prompts.Rmd @@ -1,10 +1,10 @@ --- -title: "Managing AI Prompts in `searcher`" +title: "Managing AI Prompts in searcher" author: "James Joseph Balamuta" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{Managing AI Prompts in `searcher`} + %\VignetteIndexEntry{Managing AI Prompts in searcher} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- @@ -23,7 +23,7 @@ knitr::opts_chunk$set( The `searcher` package includes a powerful prompt management system for working with AI assistants. This vignette explains how to use this system to create, manage, and apply effective prompts when using AI search functions. It -complements the main `vignette("search-with-ai-assistants", package = "searcher")`, +complements the main `vignette("using-ai-assistants-with-searcher", package = "searcher")`, which provides a broader overview of using AI services with R. ## What are Prompts? @@ -236,7 +236,7 @@ approach enhances the quality of AI-generated responses and, subsequently, helps you save time and improve the efficiency of your R workflow. The system presented in this vignette transforms the custom prompts described -in `vignette("search-with-ai-assistants", package = "searcher")` from one-off tools +in `vignette("using-ai-assistants-with-searcher", package = "searcher")` from one-off tools into a systematic library that can be maintained, shared, and reused. This represents a shift from ad-hoc prompting to a more deliberate approach that treats prompts as valuable assets in your R programming toolkit. diff --git a/vignettes/search-with-ai-assistants.Rmd b/vignettes/using-ai-assistants-with-searcher.Rmd similarity index 98% rename from vignettes/search-with-ai-assistants.Rmd rename to vignettes/using-ai-assistants-with-searcher.Rmd index e9bdf62..254b73c 100644 --- a/vignettes/search-with-ai-assistants.Rmd +++ b/vignettes/using-ai-assistants-with-searcher.Rmd @@ -33,7 +33,8 @@ The package supports the following AI services: 3. **Perplexity** (`ask_perplexity()`) - Research-focused AI with internet search capabilities 4. **Mistral** (`ask_mistral()`) - Mistral AI's assistant with strong reasoning capabilities 5. **Bing Copilot** (`ask_bing_copilot()` or `ask_copilot()`) - Microsoft's AI assistant with web search integration -6. **Meta AI** (`ask_meta_ai()`) - Meta's conversational AI assistant +6. **Grok** (`ask_grok()`) - xAI's AI assistant, known for its desire to maximize truth and objectivity +7. **Meta AI** (`ask_meta_ai()`) - Meta's conversational AI assistant # Basic Usage @@ -57,6 +58,9 @@ ask_mistral("Debug this function: calculate_median <- function(x) mean(x)") # Compare programming approaches with Bing Copilot ask_copilot("Compare data.table vs dplyr for large datasets") +# Ask Grok about R best practices +ask_grok("What are the best practices for data cleaning in R?") + # Ask Meta AI about best practices ask_meta_ai("What's the best way to handle missing data in R?") ``` @@ -78,6 +82,7 @@ The following URLs are used to create new chat sessions: | `ask_perplexity()` | Perplexity AI | `https://www.perplexity.ai/search?q=` (with additional parameters) | | `ask_mistral()` | Mistral AI | `https://chat.mistral.ai/chat?q=` | | `ask_bing_copilot()` | Microsoft Bing Copilot | `https://www.bing.com/search?showconv=1&sendquery=1&q=` | +| `ask_grok()` | xAI | `https://www.grok.com/?q=` | | `ask_meta_ai()` | Meta AI | `https://www.meta.ai/?q=` | ## Account Requirements