{"id":14066031,"url":"https://github.com/hauselin/ollama-r","last_synced_at":"2025-04-04T15:06:36.992Z","repository":{"id":236830016,"uuid":"793235019","full_name":"hauselin/ollama-r","owner":"hauselin","description":"R library to run Ollama language models","archived":false,"fork":false,"pushed_at":"2025-03-24T14:21:15.000Z","size":4136,"stargazers_count":89,"open_issues_count":0,"forks_count":12,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-28T14:11:09.171Z","etag":null,"topics":["ai","api","llm","llms","ollama","ollama-api","r"],"latest_commit_sha":null,"homepage":"https://hauselin.github.io/ollama-r/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hauselin.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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-04-28T19:42:25.000Z","updated_at":"2025-03-24T14:19:05.000Z","dependencies_parsed_at":"2024-05-02T17:39:43.878Z","dependency_job_id":"621f0005-fd48-490f-94f0-a85d03e90153","html_url":"https://github.com/hauselin/ollama-r","commit_stats":{"total_commits":161,"total_committers":3,"mean_commits":"53.666666666666664","dds":0.06832298136645965,"last_synced_commit":"e45b5c58c3d8207e197e3065fbb1dba55b2504af"},"previous_names":["hauselin/ollamar","hauselin/ollama-r"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hauselin%2Follama-r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hauselin%2Follama-r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hauselin%2Follama-r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hauselin%2Follama-r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hauselin","download_url":"https://codeload.github.com/hauselin/ollama-r/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198449,"owners_count":20900079,"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":["ai","api","llm","llms","ollama","ollama-api","r"],"created_at":"2024-08-13T07:04:54.445Z","updated_at":"2025-04-04T15:06:36.977Z","avatar_url":"https://github.com/hauselin.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}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# ollamar \u003ca href=\"https://hauselin.github.io/ollama-r/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"117\" alt=\"ollamar website\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/ollamar)](https://CRAN.R-project.org/package=ollamar)\n[![R-CMD-check](https://github.com/hauselin/ollama-r/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/hauselin/ollama-r/actions/workflows/R-CMD-check.yaml)\n[![CRAN_Download_Badge](https://cranlogs.r-pkg.org/badges/grand-total/ollamar)](https://cran.r-project.org/package=ollamar)\n[![DOI](https://joss.theoj.org/papers/10.21105/joss.07211/status.svg)](https://doi.org/10.21105/joss.07211)\n\u003c!-- badges: end --\u003e\n\nThe [Ollama R library](https://hauselin.github.io/ollama-r/) is the easiest way to integrate R with [Ollama](https://ollama.com/), which lets you run language models locally on your own machine.\n\nThe library also makes it easy to work with data structures (e.g., conversational/chat histories) that are standard for different LLMs (such as those provided by OpenAI and Anthropic). It also lets you specify different output formats (e.g., dataframes, text/vector, lists) that best suit your need, allowing easy integration with other libraries/tools and parallelization via the `httr2` library.\n\nTo use this R library, ensure the [Ollama](https://ollama.com) app is installed. Ollama can use GPUs for accelerating LLM inference. See [Ollama GPU documentation](https://github.com/ollama/ollama/blob/main/docs/gpu.md) for more information.\n\nSee [Ollama's Github page](https://github.com/ollama/ollama) for more information. This library uses the [Ollama REST API (see documentation for details)](https://github.com/ollama/ollama/blob/main/docs/api.md) and was last tested on v0.5.4.\n\n\u003e Note: You should have at least 8 GB of RAM available to run the 7B models, 16 GB to run the 13B models, and 32 GB to run the 33B models.\n\n## Ollama R vs Ollama Python/JS\n\nThis library has been inspired by the official [Ollama Python](https://github.com/ollama/ollama-python) and [Ollama JavaScript](https://github.com/ollama/ollama-js) libraries. If you're coming from Python or JavaScript, you should feel right at home. Alternatively, if you plan to use Ollama with Python or JavaScript, using this R library will help you understand the Python/JavaScript libraries as well.\n\n## Installation\n\n1. Download and install the [Ollama](https://ollama.com) app.\n\n- [macOS](https://ollama.com/download/Ollama-darwin.zip)\n- [Windows preview](https://ollama.com/download/OllamaSetup.exe)\n- Linux: `curl -fsSL https://ollama.com/install.sh | sh`\n- [Docker image](https://hub.docker.com/r/ollama/ollama)\n\n2. Open/launch the Ollama app to start the local server.\n\n3. Install either the stable or latest/development version of `ollamar`.\n\nStable version:\n\n```{r eval=FALSE}\ninstall.packages(\"ollamar\")\n```\n\nFor the latest/development version with more features/bug fixes (see latest changes [here](https://hauselin.github.io/ollama-r/news/index.html)), you can install it from GitHub using the `install_github` function from the `remotes` library. If it doesn't work or you don't have `remotes` library, please run `install.packages(\"remotes\")` in R or RStudio before running the code below.\n\n```{r eval=FALSE}\n# install.packages(\"remotes\")  # run this line if you don't have the remotes library\nremotes::install_github(\"hauselin/ollamar\")\n```\n\n## Example usage\n\nBelow is a basic demonstration of how to use the library. For details, see the [getting started vignette](https://hauselin.github.io/ollama-r/articles/ollamar.html) on our [main page](https://hauselin.github.io/ollama-r/).\n\n`ollamar` uses the [`httr2` library](https://httr2.r-lib.org/index.html) to make HTTP requests to the Ollama server, so many functions in this library returns an `httr2_response` object by default. If the response object says `Status: 200 OK`, then the request was successful.\n\n```{r eval=FALSE}\nlibrary(ollamar)\n\ntest_connection()  # test connection to Ollama server\n# if you see \"Ollama local server not running or wrong server,\" Ollama app/server isn't running\n\n# download a model\npull(\"llama3.1\")  # download a model (equivalent bash code: ollama run llama3.1)\n\n# generate a response/text based on a prompt; returns an httr2 response by default\nresp \u003c- generate(\"llama3.1\", \"tell me a 5-word story\")\nresp\n\n#' interpret httr2 response object\n#' \u003chttr2_response\u003e\n#' POST http://127.0.0.1:11434/api/generate  # endpoint\n#' Status: 200 OK  # if successful, status code should be 200 OK\n#' Content-Type: application/json\n#' Body: In memory (414 bytes)\n\n# get just the text from the response object\nresp_process(resp, \"text\")\n# get the text as a tibble dataframe\nresp_process(resp, \"df\")\n\n# alternatively, specify the output type when calling the function initially\ntxt \u003c- generate(\"llama3.1\", \"tell me a 5-word story\", output = \"text\")\n\n# list available models (models you've pulled/downloaded)\nlist_models()\n                        name    size parameter_size quantization_level            modified\n1               codegemma:7b    5 GB             9B               Q4_0 2024-07-27T23:44:10\n2            llama3.1:latest  4.7 GB           8.0B               Q4_0 2024-07-31T07:44:33\n```\n\n## Citing `ollamar`\n\nIf you use this library, please cite [this paper](https://joss.theoj.org/papers/10.21105/joss.07211) using the following BibTeX entry:\n\n```bibtex\n@article{Lin2025JOSS,\n  author = {Lin, Hause and Safi, Tawab}, \n  title = {ollamar: An R package for running large language models}, \n  journal = {Journal of Open Source Software}, \n  volume = {10}, \n  number = {105}, \n  pages = {7211}, \n  year = {2025},\n  month = jan,\n  volume = {10}, \n  doi = {10.21105/joss.07211},\n\turl = {https://joss.theoj.org/papers/10.21105/joss.07211}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhauselin%2Follama-r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhauselin%2Follama-r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhauselin%2Follama-r/lists"}