Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.6%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
A Flexible Interface for 'LLM' API Interactions
Basic Info
- Host: GitHub
- Owner: knowusuboaky
- License: other
- Language: R
- Default Branch: main
- Homepage: https://knowusuboaky.github.io/chatLLM/
- Size: 2.46 MB
Statistics
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 1
- Releases: 0
Created about 1 year ago
· Last pushed 11 months ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
output: github_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
eval = FALSE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# chatLLM
[](https://cran.r-project.org/package=chatLLM)
[](https://app.codecov.io/gh/knowusuboaky/chatLLM?branch=main)
[](https://github.com/knowusuboaky/chatLLM/commits/main)
[](https://github.com/knowusuboaky/chatLLM/issues)
[](https://cranlogs.r-pkg.org/badges/grand-total/chatLLM)
## Overview
**chatLLM** is an R package providing a single, consistent interface to multiple “OpenAI‑compatible” chat APIs (OpenAI, Groq, Anthropic, DeepSeek, Alibaba DashScope, Gemini, Grok and GitHub Models).
Key features:
* 🔄 **Uniform API** across providers
* 🗣 **Multi‑message context** (system/user/assistant roles)
* 🔁 **Retries & backoff** with clear timeout handling
* 🔈 **Verbose control** (`verbose = TRUE/FALSE`)
* ⚙️ **Discover models** via `list_models()`
* 🏗 **Factory interface** for repeated calls
* 🌐 **Custom endpoint** override and advanced tuning
---
## Installation
From CRAN:
```r
install.packages("chatLLM")
```
Development version:
```r
# install.packages("remotes") # if needed
remotes::install_github("knowusuboaky/chatLLM")
```
---
## Setup
Set your API keys or tokens once per session:
```r
Sys.setenv(
OPENAI_API_KEY = "your-openai-key",
GROQ_API_KEY = "your-groq-key",
ANTHROPIC_API_KEY = "your-anthropic-key",
DEEPSEEK_API_KEY = "your-deepseek-key",
DASHSCOPE_API_KEY = "your-dashscope-key",
GH_MODELS_TOKEN = "your-github-models-token",
GEMINI_API_KEY = "your-gemini-key",
XAI_API_KEY = "your-grok-key"
)
```
---
## Usage
### 1. Simple Prompt
```r
response <- call_llm(
prompt = "Who is Messi?",
provider = "openai",
max_tokens = 300
)
cat(response)
```
### 2. Multi‑Message Conversation
```r
conv <- list(
list(role = "system", content = "You are a helpful assistant."),
list(role = "user", content = "Explain recursion in R.")
)
response <- call_llm(
messages = conv,
provider = "openai",
max_tokens = 200,
presence_penalty = 0.2,
frequency_penalty = 0.1,
top_p = 0.95
)
cat(response)
```
### 3. Verbose Off
Suppress informational messages:
```r
res <- call_llm(
prompt = "Tell me a joke",
provider = "openai",
verbose = FALSE
)
cat(res)
```
### 4. Factory Interface
Create a reusable LLM function:
```r
# Build a “GitHub Models” engine with defaults baked in
GitHubLLM <- call_llm(
provider = "github",
max_tokens = 60,
verbose = FALSE
)
# Invoke it like a function:
story <- GitHubLLM("Tell me a short story about libraries.")
cat(story)
```
### 5. Discover Available Models
```r
# All providers at once
all_models <- list_models("all")
names(all_models)
# Only OpenAI models
openai_models <- list_models("openai")
head(openai_models)
```
### 6. Call a Specific Model
Pick from the list and pass it to `call_llm()`:
```r
anthro_models <- list_models("anthropic")
cat(call_llm(
prompt = "Write a haiku about autumn.",
provider = "anthropic",
model = anthro_models[1],
max_tokens = 60
))
```
---
## Troubleshooting
* **Timeouts**: increase `n_tries` / `backoff` or supply a custom `.post_func` with higher `timeout()`.
* **Model Not Found**: use `list_models("")` or consult provider docs.
* **Auth Errors**: verify your API key/token and environment variables.
* **Network Issues**: check VPN/proxy, firewall, or SSL certs.
---
## Contributing & Support
Issues and PRs welcome at
[https://github.com/knowusuboaky/chatLLM](https://github.com/knowusuboaky/chatLLM)
---
## License
MIT © [Kwadwo Daddy Nyame Owusu - Boakye](mailto:kwadwo.owusuboakye@outlook.com)
---
## Acknowledgements
Inspired by **RAGFlowChainR**, powered by **httr** and the R community. Enjoy!
Owner
- Login: knowusuboaky
- Kind: user
- Repositories: 1
- Profile: https://github.com/knowusuboaky
GitHub Events
Total
- Issues event: 1
- Watch event: 2
- Issue comment event: 1
- Push event: 32
- Fork event: 1
- Create event: 3
Last Year
- Issues event: 1
- Watch event: 2
- Issue comment event: 1
- Push event: 32
- Fork event: 1
- Create event: 3
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- arunrajes (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 474 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
- Total maintainers: 1
cran.r-project.org: chatLLM
A Flexible Interface for 'LLM' API Interactions
- Homepage: https://github.com/knowusuboaky/chatLLM
- Documentation: http://cran.r-project.org/web/packages/chatLLM/chatLLM.pdf
- License: MIT + file LICENSE
-
Latest release: 0.1.3
published 11 months ago
Rankings
Dependent packages count: 26.7%
Dependent repos count: 32.9%
Average: 48.8%
Downloads: 86.7%
Maintainers (1)
Last synced:
11 months ago
Dependencies
DESCRIPTION
cran
- httr >= 1.4.0 imports
- jsonlite >= 1.7.2 imports
- future * suggests
- later * suggests
- promises * suggests
- roxygen2 * suggests
- testthat * suggests
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.5.0 composite
- actions/checkout v4 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite