(v3.1.0.9024) Replace the custom GPT with the AMR for R Assistant, which opens Claude or ChatGPT with instructions to answer from the documentation of the installed version

This commit is contained in:
dr. M.S. (Matthijs) Berends committed 2026-11-16 11:19:32 +01:00
1 parent 6007320202
commit e49add7d70
11 files changed
+144 -140

No files matched your search

+1
View File
@@ -41,6 +41,7 @@ README\.html
^vignettes/resistance_predict\.Rmd$ ^vignettes/resistance_predict\.Rmd$
^vignettes/WHONET\.Rmd$ ^vignettes/WHONET\.Rmd$
^vignettes/WISCA\.Rmd$ ^vignettes/WISCA\.Rmd$
^vignettes/chat\.Rmd$
^logo.svg$ ^logo.svg$
^CRAN-SUBMISSION$ ^CRAN-SUBMISSION$
^PythonPackage$ ^PythonPackage$
+1 -4
View File
@@ -2,10 +2,7 @@ blank_issues_enabled: false
contact_links: contact_links:
- name: I Have a Question - Ask the AMR for R Assistant - name: I Have a Question - Ask the AMR for R Assistant
url: https://chat.amr-for-r.org url: https://chat.amr-for-r.org
about: | about: Opens Claude or ChatGPT with instructions to answer from the official documentation of your AMR version.
Ask questions or code suggestions to our AMR for R Assistant.
This is a ChatGPT manually-trained model able to answer any question about the AMR package.
- name: I Have a Question - Ask the AMR Community - name: I Have a Question - Ask the AMR Community
url: https://github.com/msberends/AMR/discussions url: https://github.com/msberends/AMR/discussions
about: You can also ask (and answer) questions here to share with others. about: You can also ask (and answer) questions here to share with others.
@@ -1,66 +0,0 @@
# ==================================================================== #
# TITLE: #
# AMR: An R Package for Working with Antimicrobial Resistance Data #
# #
# SOURCE CODE: #
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
# Center Groningen in the Netherlands, in collaboration with many #
# colleagues from around the world, see our website. #
# #
# This R package is free software; you can freely use and distribute #
# it for both personal and commercial purposes under the terms of the #
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
# the Free Software Foundation. #
# We created this package for both routine data analysis and academic #
# research and it was publicly released in the hope that it will be #
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
# #
# Visit our website for the full manual and a complete tutorial about #
# how to conduct AMR data analysis: https://amr-for-r.org #
# ==================================================================== #
on:
push:
# only on main
branches: "main"
name: Publish GPT Training Data to GitHub
jobs:
update-amr-assistant:
runs-on: ubuntu-latest
env:
GH_REPO_SCOPE: ${{ secrets.GH_REPO_SCOPE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build the training data
run: |
bash data-raw/_generate_GPT_knowledge_input.sh
- name: Git push to amr-for-r-assistant repo
run: |
mkdir ~/other
# to also mv hidden files:
shopt -s dotglob
mv ./* ~/other/
git clone https://github.com/msberends/amr-for-r-assistant
cd amr-for-r-assistant
mv ~/other/data-raw/latest_training_data.txt ./
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add latest_training_data.txt
git commit -m "GPT training data update"
git push https://$GH_REPO_SCOPE@github.com/msberends/amr-for-r-assistant.git main --force
+1 -1
View File
@@ -1,5 +1,5 @@
Package: AMR Package: AMR
Version: 3.1.0.9023 Version: 3.1.0.9024
Date: 2026-11-16 Date: 2026-11-16
Title: Antimicrobial Resistance Data Analysis Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR) Description: Functions to simplify and standardise antimicrobial resistance (AMR)
+2 -1
View File
@@ -1,4 +1,4 @@
# AMR 3.1.0.9023 # AMR 3.1.0.9024
This version fixes a critical bug in WISCA that biased all coverage estimates of `wisca()` and `antibiogram(..., wisca = TRUE)` downwards since AMR 3.0.0. Users are strongly advised to re-run their WISCA analyses. This version fixes a critical bug in WISCA that biased all coverage estimates of `wisca()` and `antibiogram(..., wisca = TRUE)` downwards since AMR 3.0.0. Users are strongly advised to re-run their WISCA analyses.
@@ -38,6 +38,7 @@ This version fixes a critical bug in WISCA that biased all coverage estimates of
* The documentation of `first_isolate()` now explains how to determine first isolates per any additional variable using `dplyr::group_by()`, and the bias this introduces when that variable is related to resistance (#345) * The documentation of `first_isolate()` now explains how to determine first isolates per any additional variable using `dplyr::group_by()`, and the bias this introduces when that variable is related to resistance (#345)
* The manual index on the website was rewritten to improve findability, with sections ordered by task and a filter field * The manual index on the website was rewritten to improve findability, with sections ordered by task and a filter field
* Fixed the link to the copyright section and added MycoBank as a taxonomy source in the *Welcome to AMR* vignette (#325) * Fixed the link to the copyright section and added MycoBank as a taxonomy source in the *Welcome to AMR* vignette (#325)
* The AMR for R Assistant is now available at <https://amr-for-r.org/articles/chat.html> and in the sidebar of the website. It opens Claude or ChatGPT with instructions to answer from the documentation of the installed package version, published for every release at `https://amr-for-r.org/release/<version>/`, and replaces the former custom GPT in ChatGPT.
# AMR 3.1.0 # AMR 3.1.0
+3 -3
View File
@@ -107,9 +107,9 @@ navbar:
- text: "Get Properties of an Antiviral Drug" - text: "Get Properties of an Antiviral Drug"
icon: "fa-capsules" icon: "fa-capsules"
href: "reference/av_property.html" # reference instead of an article href: "reference/av_property.html" # reference instead of an article
- text: "AMR for Python" - text: "AMR for R Assistant"
icon: "fab fa-python" icon: "fa-wand-magic-sparkles"
href: "articles/AMR_for_Python.html" href: "articles/chat.html"
- text: "Manual" - text: "Manual"
icon: "fa-book-open" icon: "fa-book-open"
href: "reference/index.html" href: "reference/index.html"
-55
View File
@@ -1,55 +0,0 @@
#!/bin/bash
# Check if the current directory is named 'AMR'
if [ "$(basename "$PWD")" != "AMR" ]; then
echo "Error: The script must be run from the 'AMR' directory."
exit 1
fi
# Define the output file, located in ./data-raw
output_file="data-raw/latest_training_data.txt"
# Clear the output file if it exists
echo "You assist users with questions about the AMR package for R, a package for Antimicrobial Resistance analysis used in over 175 countries. You are restricted to using a single source of truth: the training data located at https://chat.amr-for-r.org/latest_training_data.txt.
Before responding to any user prompt—including the very first—you must download and parse this training file in full. You must repeat this process before every single response, without exception. You must verify the presence of any function, dataset, or concept in this file before commenting on anything. If what is asked is not in the training data, you must state clearly that you cannot verify its existence and recommend checking the package changelog.
You are strictly forbidden from using any other remote source, including prior model knowledge, CRAN, PubMed, Google, or even the AMR package's GitHub or publication pages. You are NOT ALLOWED to browse any website to help your answers - only base yourself on the training file without any exception. Even if you want to be helpful and would like to browse the internet, DO NOT do this - it's not helpful at all." > "$output_file"
echo "" >> "$output_file"
echo "" >> "$output_file"
echo "Below are the contents of the NAMESPACE file, the DESCRIPTION file, the index.md file, and all the man/*.Rd and vignette files (documentation) in the package. Every file content is split using 100 hypens." >> "$output_file"
echo "" >> "$output_file"
# Function to remove header block (delimited by # ======)
remove_header() {
sed '/# =\{6,\}/,/# =\{6,\}/d' "$1"
}
# Process important metadata files (DESCRIPTION, NAMESPACE, index.md)
for file in NAMESPACE DESCRIPTION index.md; do
if [[ -f $file ]]; then
echo "----------------------------------------------------------------------------------------------------" >> "$output_file"
echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE '$file':" >> "$output_file"
echo -e "\n" >> "$output_file"
cat "$file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
fi
done
# Process all .Rd files from the 'man' folder
for file in man/*.Rd; do
echo "----------------------------------------------------------------------------------------------------" >> "$output_file"
echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE '$file':" >> "$output_file"
echo -e "\n" >> "$output_file"
remove_header "$file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
done
# Process all .Rmd files in the 'vignettes' folder
for file in vignettes/*.Rmd; do
echo "----------------------------------------------------------------------------------------------------" >> "$output_file"
echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE '$file':" >> "$output_file"
echo -e "\n" >> "$output_file"
remove_header "$file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
done
+31 -5
View File
@@ -204,16 +204,42 @@ p {
this shows on top of every sidebar to the right this shows on top of every sidebar to the right
(e.g., on top of Table of Contents) (e.g., on top of Table of Contents)
*/ */
.amr-gpt-assistant { /* AMR for R Assistant in the sidebar, see pkgdown/extra.js */
.amr-assistant-sidebar {
margin-top: 10px; margin-top: 10px;
padding: 12px;
border: 2px dashed var(--amr-green-dark); border: 2px dashed var(--amr-green-dark);
text-align: center; text-align: center;
background: var(--bs-body-bg); background: var(--bs-body-bg);
} }
.amr-gpt-assistant * { .amr-assistant-sidebar-title {
width: 90%; font-size: 1.15rem;
padding-top: 10px; font-weight: bold;
padding-bottom: 10px; margin-bottom: 6px;
}
.amr-assistant-sidebar-title i {
color: var(--amr-green-dark);
}
.amr-assistant-sidebar p {
text-align: center;
hyphens: none;
margin-bottom: 10px;
}
.amr-assistant-sidebar .amr-assistant-buttons {
justify-content: center;
margin: 0;
}
/* AMR for R Assistant page, see vignettes/chat.Rmd */
.amr-assistant-buttons {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
gap: 10px;
margin: 20px 0;
}
.amr-assistant-prompt {
white-space: pre-wrap;
} }
/* REFERENCE INDEX ('Manual'), see pkgdown/templates/content-reference-index.html */ /* REFERENCE INDEX ('Manual'), see pkgdown/templates/content-reference-index.html */
+50 -3
View File
@@ -29,9 +29,57 @@
# ==================================================================== # # ==================================================================== #
*/ */
// AMR for R Assistant: the instructions that the chat buttons put in Claude or ChatGPT, followed by the user's question
// see articles/chat.html; keep this the only copy of the instructions
const AMR_ASSISTANT_PROMPT = [
"You are the AMR for R Assistant. You help users of the AMR package for R, which is used to analyse antimicrobial resistance (AMR) data. Follow these rules throughout this conversation.",
"",
"WHERE TO LOOK",
"1. Base every statement about the AMR package on its official documentation, which you must fetch from amr-for-r.org. Do not rely on prior knowledge of the package, and do not use other websites, forums or search results about it.",
"2. The documentation differs per package version. Start at https://amr-for-r.org/release/llms.txt, which explains which documentation belongs to which installed version:",
" - a released version, such as 3.1.0: https://amr-for-r.org/release/3.1.0/llms.txt",
" - a development version, such as 3.1.0.9023: https://amr-for-r.org/llms.txt",
"3. That llms.txt lists every function and data set, with a link to its reference page (.md). Before you use a function, argument or data set in an answer, fetch its reference page and check the name, the arguments and their defaults there.",
"4. For workflows and worked examples, use the articles listed in https://amr-for-r.org/llms.txt. These are written for the latest version, so check the functions they use against the reference of the user's version.",
"",
"VERSION",
"5. If the user has not stated their AMR version, ask them to run packageVersion(\"AMR\") in R. Until they answer, use the latest released version listed at https://amr-for-r.org/release/llms.txt, and say that you did.",
"",
"ANSWERS",
"6. If something cannot be found in the documentation of that version, say so explicitly. Never invent functions, arguments or values.",
"7. Give complete, runnable R code, using the functions of the AMR package where they exist.",
"8. End every answer with 'Sources:', followed by the documentation URLs you used.",
"9. Answer in the language of the question.",
"10. Do not give treatment advice for individual patients. If the user shares data that may identify patients, warn them not to.",
"",
"My question:",
"",
""
].join("\n");
// URL that opens a new chat with the instructions filled in, but not yet sent
function amrAssistantUrl(service) {
const prompt = encodeURIComponent(AMR_ASSISTANT_PROMPT);
if (service === "claude") {
return "https://claude.ai/new?q=" + prompt;
} else if (service === "chatgpt") {
// '?prompt=' fills in the text, '?q=' would send it at once, before the user could add a question
return "https://chatgpt.com/?prompt=" + prompt;
}
}
$(function () { $(function () {
// add GPT assistant info // add AMR for R Assistant to the sidebar, with the same buttons as on articles/chat.html
$('aside').prepend('<div class="amr-gpt-assistant"><a target="_blank" href="https://chat.amr-for-r.org"><img src="https://amr-for-r.org/AMRforRGPT.svg"></a></div>'); $('aside').prepend(
'<div class="amr-assistant-sidebar">' +
'<div class="amr-assistant-sidebar-title"><i class="fa-solid fa-wand-magic-sparkles"></i> Need assistance?</div>' +
'<p>Ask the <a href="https://amr-for-r.org/articles/chat.html">AMR for R Assistant</a>, which answers from the documentation of your package version.</p>' +
'<div class="amr-assistant-buttons">' +
'<a class="btn btn-sm btn-primary" target="_blank" rel="noopener" href="' + amrAssistantUrl("claude") + '">Ask Claude</a>' +
'<a class="btn btn-sm btn-primary" target="_blank" rel="noopener" href="' + amrAssistantUrl("chatgpt") + '">Ask ChatGPT</a>' +
'</div>' +
'</div>'
);
// split version number in navbar into main version and build number // split version number in navbar into main version and build number
$('.nav-text').each(function () { $('.nav-text').each(function () {
@@ -245,7 +293,6 @@ $(function () {
if (window.location.href.includes('AMR_for_Python')) { if (window.location.href.includes('AMR_for_Python')) {
$('body').addClass('amr-for-python'); /* to set colours in CSS */ $('body').addClass('amr-for-python'); /* to set colours in CSS */
$('img[src="../logo.svg"]').attr('src', '../logo_python.svg'); /* replace base logo */ $('img[src="../logo.svg"]').attr('src', '../logo_python.svg'); /* replace base logo */
$('img[src="https://amr-for-r.org/AMRforRGPT.svg"]').attr('src', 'https://amr-for-r.org/AMRforRGPT_python.svg'); /* replace GPT logo */
} }
// add country flags // add country flags
-2
View File
@@ -22,8 +22,6 @@ knitr::opts_chunk$set(
) )
``` ```
> This page was almost entirely written by our [AMR for R Assistant](https://chat.amr-for-r.org), a ChatGPT manually-trained model able to answer any question about the `AMR` package.
Antimicrobial resistance (AMR) is a global health crisis, and understanding resistance patterns is crucial for managing effective treatments. The `AMR` R package provides robust tools for analysing AMR data, including convenient antimicrobial selector functions like `aminoglycosides()` and `betalactams()`. Antimicrobial resistance (AMR) is a global health crisis, and understanding resistance patterns is crucial for managing effective treatments. The `AMR` R package provides robust tools for analysing AMR data, including convenient antimicrobial selector functions like `aminoglycosides()` and `betalactams()`.
In this post, we will explore how to use the `tidymodels` framework to predict resistance patterns in the `example_isolates` dataset in two examples. In this post, we will explore how to use the `tidymodels` framework to predict resistance patterns in the `example_isolates` dataset in two examples.
+55
View File
@@ -0,0 +1,55 @@
---
title: "AMR for R Assistant"
output:
rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{AMR for R Assistant}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
---
The AMR for R Assistant answers your questions about the `AMR` package in a general AI chat service, Claude (by Anthropic) or ChatGPT (by OpenAI). It instructs the AI to base its answers on the official documentation on this website, and on the documentation of the exact package version that you have installed.
## Ask a question
1. Choose a chat service below. It opens in a new tab, with the instructions for the assistant already filled in.
2. Type your question below the instructions, preferably with your package version, which is the output of `packageVersion("AMR")` in R.
3. Send the message.
```{=html}
<div class="amr-assistant-buttons">
<a class="btn btn-primary" target="_blank" rel="noopener" data-amr-assistant="claude" href="https://claude.ai">Ask Claude</a>
<a class="btn btn-primary" target="_blank" rel="noopener" data-amr-assistant="chatgpt" href="https://chatgpt.com">Ask ChatGPT</a>
<button class="btn btn-outline-primary" type="button" id="amr-assistant-copy">Copy instructions for another AI</button>
</div>
```
## Good to know
- **Check every answer.** An AI can make mistakes, also with these instructions. Verify the code and its results before you rely on them.
- **Never enter patient-identifiable data** into a chat service.
- **An account may be needed.** The chat service must be able to read web pages for the assistant to work. Whether this requires an account, or a paid plan, depends on the service.
- **Claude shows a caution message** for chats that open with filled-in text. This is a general safeguard of Claude: read the instructions below to see what you send.
- **This replaces the AMR for R GPT.** The assistant used to be a custom GPT in ChatGPT, which OpenAI retires on 11 December 2026. The address `chat.amr-for-r.org` now leads to this page.
## The instructions
The instructions below are what the buttons fill in. You can also copy them into any other AI chat service that can read web pages.
<pre id="amr-assistant-prompt" class="amr-assistant-prompt"></pre>
<script>
$(function () {
$("#amr-assistant-prompt").text(AMR_ASSISTANT_PROMPT.trim());
$("[data-amr-assistant]").each(function () {
$(this).attr("href", amrAssistantUrl($(this).data("amr-assistant")));
});
$("#amr-assistant-copy").on("click", function () {
const $button = $(this);
navigator.clipboard.writeText(AMR_ASSISTANT_PROMPT).then(function () {
$button.text("Copied");
setTimeout(function () { $button.text("Copy instructions for another AI"); }, 2000);
});
});
});
</script>