{"id":14066045,"url":"https://github.com/GabrielKaiserQFin/PerplexR","last_synced_at":"2025-07-29T21:34:57.295Z","repository":{"id":218408368,"uuid":"746328022","full_name":"GabrielKaiserQFin/PerplexR","owner":"GabrielKaiserQFin","description":"This package offers R users an intuitive interface for the Perplexity API.","archived":false,"fork":false,"pushed_at":"2024-12-02T14:30:16.000Z","size":392,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-12-02T15:32:42.915Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GabrielKaiserQFin.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-21T18:29:17.000Z","updated_at":"2024-12-02T14:26:40.000Z","dependencies_parsed_at":"2024-02-18T14:27:03.984Z","dependency_job_id":"4fe0be69-a8b6-4758-b1e3-35047038cfb0","html_url":"https://github.com/GabrielKaiserQFin/PerplexR","commit_stats":null,"previous_names":["gabrielkaiserqfin/perplexr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielKaiserQFin%2FPerplexR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielKaiserQFin%2FPerplexR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielKaiserQFin%2FPerplexR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielKaiserQFin%2FPerplexR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GabrielKaiserQFin","download_url":"https://codeload.github.com/GabrielKaiserQFin/PerplexR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227758620,"owners_count":17815600,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:04:54.824Z","updated_at":"2024-12-04T05:31:17.626Z","avatar_url":"https://github.com/GabrielKaiserQFin.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nlibrary(perplexR)\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n\n```\n\n# perplexR \u003ca href=\"https://github.com/GabrielKaiserQFin/perplexR\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/perplexR)](https://CRAN.R-project.org/package=perplexR)\n[![CRAN downloads](https://cranlogs.r-pkg.org/badges/perplexR)](https://cran.rstudio.com/web/packages/perplexR/index.html)\n[![R-CMD-check](https://github.com/GabrielKaiserQFin/perplexR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/GabrielKaiserQFin/PerplexR/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\nThe objective of `perplexR` is to offer R users an intuitive interface for leveraging the capabilities of the Perplexity API [Pro subscription](https://docs.perplexity.ai/guides/getting-started). Utilizing the supplied functions, users can enhance their programming productivity by incorporating Large Language Models. Furthermore, `perplexR` includes RStudio add-ins, enabling seamless interactive integration of Perplexity prompts.\n\n## Installation\n\nYou can install the development version of perplexR from [GitHub](https://github.com/GabrielKaiserQFin/perplexR) with:\n\n```{r eval = FALSE}\n# install.packages(\"devtools\")\ndevtools::install_github(\"GabrielKaiserQFin/perplexR\")\n```\n\n\u003c!-- Or install the current released version of `{perplexR}` from  --\u003e\n\u003c!-- [CRAN](https://cran.r-project.org/package=perplexR): --\u003e\n\n\u003c!-- ```{r eval = FALSE} --\u003e\n\u003c!-- install.packages(\"perplexR\") --\u003e\n\u003c!-- ``` --\u003e\n\n## Requirements\n\nIf you have a Pro subscription, you can create an API key by accessing [Perplexity API page](https://www.perplexity.ai/settings/api), otherwise you can not use `{perplexR}`.\n\nTo use your API key in `{perplexR}`, you need to configure it in the .Renviron file, by executing `usethis::edit_r_environ()` and add the following line:\n\n```{r eval = FALSE}\nPERPLEXITY_API_KEY=XX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n```\n\nOtherwise you can also do this on a session-by-session basis by performing the following step:\n```{r eval = FALSE}\nSys.setenv(PERPLEXITY_API_KEY = \"XX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\")\n```\n\n## Examples\n\n### Addin:\n\nIn RStudio go to **Addins** and select **Ask Large Language Model**, which will open an interactive prompt in your Viewer, where you can choose between different Large Language Models and adjust the temperature and the number of tokens to be used.\nJust ask anything of you interest and hit the confirm button. The **Done** button lets you close the app.\nSimilarly, you can mark or copy any text or code and use the other add-ins as described below. Add-in shortcuts will improve your efficiency even further. \n\n\n### AskMe:\n\nThis is a basic example which shows you how to ask any question.\n\n```{r Example AskMe, cache=TRUE}\nAskMe(\"What do you think about Large language models?\")\n```\n\n\n### rewriteText:\n\nThis is a basic example which shows you how to rewrite text.\n\n```{r Example rewriteText, cache=TRUE}\nrewriteText(\"Dear Recipient, I hope this message finds you well.\")\n```\n\n### translateText:\n\nThis is a basic example which shows you how to translate text.\n\n```{r Example translateText, cache=TRUE}\ntranslateText(\"Dear Recipient, I hope this message finds you well.\", toLanguage = \"Spanish\")\n```\n\n### annotateCode:\n\nThis is a basic example which shows you how to annotate code.\n\n```{r Example annotateCode, cache=TRUE}\nannotateCode(\"z \u003c- function(x) scale(x)^2\")\n```\n\n\n### buildUnitTests:\n\nThis is a basic example which shows you how to build Unit Tests for your function.\n\n```{r Example buildUnitTests, cache=TRUE}\nbuildUnitTests(\"z \u003c- function(x) scale(x)^2\")\n```\n\n\n### clarifyCode:\n\nThis is a basic example to clarify your code.\n\n```{r Example clarifyCode, cache=TRUE}\nclarifyCode(\"for (i in 1:10) {\\n  print(i ** 2)\\n}\")\n```\n\n\n### debugCode:\n\nThis is a basic example which shows you how to find bugs in your code.\n\n```{r Example debugCode, cache=TRUE}\ndebugCode(\"z \u003c- function(x) scale(x)2\")\n```\n\n\n### documentCode:\n\nThis is a basic example which shows you how to document your code. Formatting style is `Roxygen2` but can be set to NULL.\n\n```{r Example documentCode, cache=TRUE}\ndocumentCode(\"z \u003c- function(x) scale(x)^2\", inLineDocumentation = NULL)\n```\n\n\n### finishCode:\n\nThis is a basic example which shows you how to finish your code.\n\n```{r Example finishCode, cache=TRUE}\nfinishCode(\"# A function to scale a vector and square the resulting z-score z2 \u003c- function(\")\n```\n\n\n### optimizeCode:\n\nThis is a basic example which shows you how to optimize your code.\n\n```{r Example optimizeCode, cache=TRUE}\noptimizeCode(\"z \u003c- function(x) scale(x)^2\")\n```\n\n\n### translateCode:\n\nThis is a basic example which shows you how to translate your code from `R` to `Python`.\n\n```{r Example translateCode, cache=TRUE}\ntranslateCode(\"z \u003c- function(x) scale(x)^2\", from = \"R\", to = \"Python\")\n```\n\n\n### namingGenie:\n\nThis is a basic example which shows you how to create a function or variable name.\n\n```{r Example namingGenie, cache=TRUE}\nnamingGenie(\"function(x) scale(x)^2\")\n```\n\n\n\n## Perplexity Model Arguments\n\nThe parameters of perplexity models can be adjusted by passing functional arguments.\n\n*  `text` or `code`: The text or code input required for processing by Large Language Model. If omitted, the function will utilize the content currently held in the clipboard.\n\n* `PERPLEXITY_API_KEY`: The PERPLEXITY API key. By default it is set to `Sys.getenv(\"PERPLEXITY_API_KEY\")`.\n\n*  `modelSelection`: Default is `\"llama-3.1-sonar-small-128k-online\"` but other available [models](https://docs.perplexity.ai/guides/model-cards) are:\n                                `\"llama-3.1-sonar-large-128k-online\"`,\n                                `\"llama-3.1-sonar-huge-128k-online\"`\n\n\n*  `systemRole`: System role for model. Default is set to \"You are a helpful assistant\".\n\n*  `maxTokens`: The maximum integer of completion tokens returned by the API. The total number of tokens requested in max_tokens plus the number of prompt tokens sent in messages must not exceed the context window token limit of model requested. If left unspecified, then the model will generate tokens until either it reaches its stop token or the end of its context window.\n\n*  `temperatur`: The amount of randomness in the response, valued between 0 inclusive and 2 exclusive. Higher values are more random, and lower values are more deterministic. You should either set temperature or top_p, but not both.\n\n*  `top_p`: The nucleus sampling threshold, valued between 0 and 1 inclusive. For each subsequent token, the model considers the results of the tokens with top_p probability mass. You should either alter temperature or top_p, but not both.\n\n*  `top_k`: The number of tokens to keep for highest top-k filtering, specified as an integer between 0 and 2048 inclusive. If set to 0, top-k filtering is disabled.\n\n*  `presence_penalty`: A value between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. Incompatible with frequency_penalty.\n\n*  `frequency_penalty`: A multiplicative penalty greater than 0. Values greater than 1.0 penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. A value of 1.0 means no penalty. Incompatible with presence_penalty.\n\n*  `proxy`: Default value is NULL. To execute Perplexity queries via a proxy server, specify the proxy address and port as an argument to the function instance. Use the following format: `\"proxy_address:proxy_port\"`. An example would be: `\"81.94.255.13:8080\"`\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGabrielKaiserQFin%2FPerplexR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGabrielKaiserQFin%2FPerplexR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGabrielKaiserQFin%2FPerplexR/lists"}