| Title: | Client for the 'PnotP' Platform |
|---|---|
| Description: | Access the 'PnotP' platform <https://pnotp.ai> from R and 'RStudio'. One account API key drives data-compliant large language model chat, where every response carries a retention receipt; model training with pause, resume and cancel; model deployments and live inference; and hosted agents. Includes 'RStudio' addins to chat with the language model from the IDE, and a bridge to 'ellmer' for tool calling and streaming. |
| Authors: | Vicente Alonso Gallardo Montalva [aut, cre], PnotP [cph, fnd] |
| Maintainer: | Vicente Alonso Gallardo Montalva <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-13 23:49:05 UTC |
| Source: | https://github.com/cran/pnotp |
Draws each numeric per-epoch metric (train_loss, val_accuracy,
val_rmse, ...) against the epoch, one panel per metric.
## S3 method for class 'pnotp_job_progress' plot(x, ...)## S3 method for class 'pnotp_job_progress' plot(x, ...)
x |
A |
... |
Passed to |
x, invisibly.
pnotp_me() – who the key belongs to; the quickest "is my key
working?" check.
pnotp_credits() – credit balance and auto-refill state.
pnotp_capabilities() – which platform features are switched on.
pnotp_me(client = NULL) pnotp_credits(client = NULL) pnotp_capabilities(client = NULL)pnotp_me(client = NULL) pnotp_credits(client = NULL) pnotp_capabilities(client = NULL)
client |
A |
The API response, as a list.
## Not run: pnotp_me()$email pnotp_credits()$balance_usd ## End(Not run)## Not run: pnotp_me()$email pnotp_credits()$balance_usd ## End(Not run)
Available from the 'RStudio' Addins menu once the package is installed (bind them to keys under Tools -> Modify Keyboard Shortcuts):
pnotp_addin_chat() pnotp_addin_explain() pnotp_addin_set_key()pnotp_addin_chat() pnotp_addin_explain() pnotp_addin_set_key()
Chat with PnotP (pnotp_addin_chat()) – a chat with the
data-compliant LLM in the Viewer pane. Text selected in the editor is
pre-filled as context. Each answer shows its receipt line. "Insert
answer" writes the last answer on the line after your selection,
never over it: its code blocks if it has any, otherwise the answer as
# comments, so the script still runs. The conversation lives only in
this R session.
Explain selection with PnotP (pnotp_addin_explain()) – sends the
selected code and prints an explanation in the console.
Set PnotP API key (pnotp_addin_set_key()) – asks for the key
(masked), sets it for the session and checks it against the API.
The chat needs the 'shiny' and 'miniUI' packages.
pnotp_addin_chat() returns the last pnotp_chat_response
(invisibly) when you press Done; pnotp_addin_explain() returns the
response invisibly.
A data-compliant run keeps a single final_answer event, which is
preferred; otherwise the answer is the content of the last brain_turn.
pnotp_agent_answer(run, client = NULL)pnotp_agent_answer(run, client = NULL)
run |
A |
client |
A |
The answer as a string, or NULL if the run has none yet.
Starts a run of the agent's current version. Follow it with
pnotp_wait(), pnotp_progress(), pnotp_agent_steps() and
pnotp_agent_answer().
pnotp_agent_run( agent, input, budget_usd = NULL, wait = FALSE, ..., client = NULL )pnotp_agent_run( agent, input, budget_usd = NULL, wait = FALSE, ..., client = NULL )
agent |
An agent id or object. |
input |
The question: a string (sent as |
budget_usd |
Maximum spend for this run, in USD. |
wait |
If |
... |
Passed to |
client |
A |
A pnotp_agent_run.
One row per brain turn or tool call, with its cost and latency.
pnotp_agent_steps(run, client = NULL)pnotp_agent_steps(run, client = NULL)
run |
A |
client |
A |
The API response; a list of steps comes back as a data.frame.
A hosted agent is a brain (a reasoning model) driving a bounded
tool-calling loop over the tools you attach, run on PnotP and metered
against your credits. Create it, publish an immutable version with its
model and tool allowlist, then run it with pnotp_agent_run().
pnotp_agents(client = NULL) pnotp_agent(agent, client = NULL) pnotp_agent_create(name, client = NULL) pnotp_agent_publish( agent, model = "pnotp-compliant", system_prompt = "", tools = character(), budget_usd = NULL, client = NULL )pnotp_agents(client = NULL) pnotp_agent(agent, client = NULL) pnotp_agent_create(name, client = NULL) pnotp_agent_publish( agent, model = "pnotp-compliant", system_prompt = "", tools = character(), budget_usd = NULL, client = NULL )
client |
A |
agent |
An agent id or object. |
name |
Agent name. |
model |
The brain, e.g. |
system_prompt |
The system prompt. |
tools |
Character vector of tool names to allow. |
budget_usd |
Default per-run budget, in USD. |
With model = "pnotp-compliant" a run keeps no question, no reasoning and
no loop state: only metered metadata and the encrypted final answer,
held for 24 hours.
pnotp_agents() returns a data.frame; the others the API
response as a list.
## Not run: a <- pnotp_agent_create("Advisor") pnotp_agent_publish(a, model = "pnotp-compliant", tools = "programs_db") run <- pnotp_agent_run(a, "Which programs fit someone who loves maths?", wait = TRUE) pnotp_agent_answer(run) ## End(Not run)## Not run: a <- pnotp_agent_create("Advisor") pnotp_agent_publish(a, model = "pnotp-compliant", tools = "programs_db") run <- pnotp_agent_run(a, "Which programs fit someone who loves maths?", wait = TRUE) pnotp_agent_answer(run) ## End(Not run)
Manage the pnotp_sk_... keys that authenticate this package. The raw
key is returned only once, by pnotp_api_key_create().
pnotp_api_keys(client = NULL) pnotp_api_key_create(name = "API key", client = NULL) pnotp_api_key_revoke(key, client = NULL)pnotp_api_keys(client = NULL) pnotp_api_key_create(name = "API key", client = NULL) pnotp_api_key_revoke(key, client = NULL)
client |
A |
name |
A label for the new key. |
key |
A key id or object (not the raw key). |
pnotp_api_keys() returns a data.frame; the others the API
response.
Builders for the visual architecture graph pnotp_model_create()
expects, so the package is usable end to end without hand-writing nodes
and edges. Any hand-built graph (a nested list) works too.
pnotp_arch_image_classifier(num_classes = 2, channels = 3, size = 224) pnotp_arch_tabular_classifier(n_features, num_classes = 2)pnotp_arch_image_classifier(num_classes = 2, channels = 3, size = 224) pnotp_arch_tabular_classifier(n_features, num_classes = 2)
num_classes |
Number of classes. |
channels |
Image channels. |
size |
Image side length, in pixels. |
n_features |
Number of input features (columns, excluding the target). |
A nested list.
str(pnotp_arch_tabular_classifier(n_features = 4, num_classes = 3), max.level = 2)str(pnotp_arch_tabular_classifier(n_features = 4, num_classes = 3), max.level = 2)
Calls POST /v1/llm/chat. PnotP itself stores neither the prompt nor the
completion; the returned receipt is the durable audit artifact. Whether
the whole path is zero-retention depends on the rail that served the
call, and the receipt says so: read receipt$zero_retention and
receipt$retention_basis rather than assuming it.
pnotp_chat( x, max_tokens = 256, temperature = 0.7, model = NULL, tools = NULL, tool_choice = NULL, file = NULL, image = NULL, audio = NULL, client = NULL )pnotp_chat( x, max_tokens = 256, temperature = 0.7, model = NULL, tools = NULL, tool_choice = NULL, file = NULL, image = NULL, audio = NULL, client = NULL )
x |
The conversation: a single string (one user turn), a list of
messages ( |
max_tokens |
Maximum tokens to generate (1 to 8192). |
temperature |
Sampling temperature (0 to 2). |
model |
A public model id (see |
tools |
Tool definitions, e.g. from |
tool_choice |
OpenAI-style tool choice ( |
file |
A document to attach (PDF, txt, md, csv, json...): a path, a raw vector, or a base64 string. Parsed to text server-side. |
image |
An image to attach: a path, a raw vector, a base64 string,
or a |
audio |
Accepted for parity with the Python SDK; the API answers 422 until audio is enabled. |
client |
A |
Calls are metered per token against your credits; an empty balance raises
pnotp_insufficient_credits_error. See pnotp_llm_pricing() for rates.
For multi-turn tool calling and streaming, pnotp_ellmer_chat() drives
the same models through 'ellmer'.
A pnotp_chat_response: a list with completion, usage,
model, receipt and, when the model called a tool, tool_calls.
as.character() gives the completion text.
## Not run: out <- pnotp_chat("In one sentence, what is a p-value?") out out$receipt$zero_retention pnotp_chat(data.frame( role = c("system", "user"), content = c("Answer in Spanish.", "What does dplyr::across() do?") )) pnotp_chat("What is in this plot?", image = "figure.png") ## End(Not run)## Not run: out <- pnotp_chat("In one sentence, what is a p-value?") out out$receipt$zero_retention pnotp_chat(data.frame( role = c("system", "user"), content = c("Answer in Spanish.", "What does dplyr::across() do?") )) pnotp_chat("What is in this plot?", image = "figure.png") ## End(Not run)
A client holds the account API key, the API base URL and the request
timeout. You rarely need one: every function takes client = NULL, which
builds a client from the environment at call time, so a key set with
pnotp_set_key() (or in ~/.Renviron) is picked up without restarting.
pnotp_client(api_key = NULL, base_url = NULL, timeout = 60)pnotp_client(api_key = NULL, base_url = NULL, timeout = 60)
api_key |
Account API key ( |
base_url |
API base URL, ending in |
timeout |
Request timeout, in seconds. |
A client created without a key can still call the public endpoints, such
as pnotp_llm_pricing(). Authenticated calls fail with a pnotp_error
that says how to set one.
An object of class pnotp_client. Printing it masks the key.
cl <- pnotp_client(api_key = "pnotp_sk_example", base_url = "http://localhost:8000/v1") clcl <- pnotp_client(api_key = "pnotp_sk_example", base_url = "http://localhost:8000/v1") cl
CPU (free) and each GPU tier with its price. Pass a choice to
pnotp_train(compute = , gpu = ).
pnotp_compute_options(client = NULL)pnotp_compute_options(client = NULL)
client |
A |
A list.
pnotp_deploy_upload() deploys a TorchScript .pt checkpoint.
pnotp_deploy_open_source() deploys a catalog model (see
pnotp_open_source_models()) with no training and no upload; extra
arguments set its default inference parameters.
pnotp_deploy_upload( project, name, checkpoint, compliant = FALSE, client = NULL ) pnotp_deploy_open_source( project, model_id, name = NULL, compliant = FALSE, ..., client = NULL )pnotp_deploy_upload( project, name, checkpoint, compliant = FALSE, client = NULL ) pnotp_deploy_open_source( project, model_id, name = NULL, compliant = FALSE, ..., client = NULL )
project |
A project id or object. |
name |
Deployment name. |
checkpoint |
Path to a TorchScript |
compliant |
Request zero-retention (data-compliant) inference. |
client |
A |
model_id |
Catalog model id, e.g. |
... |
Default inference parameters, validated server-side against
the catalog spec (e.g. |
compliant = TRUE makes the endpoint data-compliant: the platform never
persists request inputs, keeps error text out of monitoring, and every
pnotp_predict() response carries a compliance receipt. It is a
platform capability: when it is not enabled the call fails with a 409
(pnotp_api_error); check first with pnotp_compliance_available().
The API response: for an upload, list(deployment = , board = ).
Pass it straight to pnotp_predict().
## Not run: dep <- pnotp_deploy_upload(p, "prod", "model.pt", compliant = TRUE) pnotp_predict(dep, "xray.jpg") det <- pnotp_deploy_open_source(p, "yolox_s", confidence_threshold = 0.4) ## End(Not run)## Not run: dep <- pnotp_deploy_upload(p, "prod", "model.pt", compliant = TRUE) pnotp_predict(dep, "xray.jpg") det <- pnotp_deploy_open_source(p, "yolox_s", confidence_threshold = 0.4) ## End(Not run)
Mint, list and revoke pnp_... keys that let an external consumer call
one deployment with pnotp_predict(). The raw key is returned only once,
by pnotp_deployment_key_create().
pnotp_deployment_keys(deployment, client = NULL) pnotp_deployment_key_create(deployment, client = NULL) pnotp_deployment_key_revoke(deployment, key_id, client = NULL)pnotp_deployment_keys(deployment, client = NULL) pnotp_deployment_key_create(deployment, client = NULL) pnotp_deployment_key_revoke(deployment, key_id, client = NULL)
deployment |
A deployment id or object. |
client |
A |
key_id |
The key's id (not the key itself). |
The API response, as a list.
Manage deployments
pnotp_deployments(project, client = NULL) pnotp_deployment(deployment, client = NULL) pnotp_deployment_stats(deployment, window = "24h", client = NULL) pnotp_deployment_pause(deployment, client = NULL) pnotp_deployment_resume(deployment, client = NULL) pnotp_deployment_delete(deployment, client = NULL) pnotp_deployment_set_compliant(deployment, compliant = TRUE, client = NULL) pnotp_compliance_available(client = NULL) pnotp_private_available(client = NULL)pnotp_deployments(project, client = NULL) pnotp_deployment(deployment, client = NULL) pnotp_deployment_stats(deployment, window = "24h", client = NULL) pnotp_deployment_pause(deployment, client = NULL) pnotp_deployment_resume(deployment, client = NULL) pnotp_deployment_delete(deployment, client = NULL) pnotp_deployment_set_compliant(deployment, compliant = TRUE, client = NULL) pnotp_compliance_available(client = NULL) pnotp_private_available(client = NULL)
project |
A project id or object. |
client |
A |
deployment |
A deployment id or object. |
window |
Stats window, e.g. |
compliant |
|
pnotp_deployments() returns a data.frame; the others the API
response as a list. pnotp_compliance_available() and
pnotp_private_available() return TRUE/FALSE, and FALSE when
the capability probe itself fails.
Returns an 'ellmer' chat object pointed at PnotP's OpenAI-compatible
endpoint (POST /v1/chat/completions), authenticated with your account
key. Everything 'ellmer' does then works against PnotP: multi-turn chat,
streaming, tool calling with R functions (chat$register_tool()), and
structured output (chat$chat_structured()).
pnotp_ellmer_chat( model = "pnotp-compliant", system_prompt = NULL, ..., client = NULL )pnotp_ellmer_chat( model = "pnotp-compliant", system_prompt = NULL, ..., client = NULL )
model |
A public model id (see |
system_prompt |
Optional system prompt. |
... |
Passed on to |
client |
A |
The same retention terms as pnotp_chat() apply: PnotP stores neither
prompt nor completion. 'ellmer' keeps the conversation in your R session
only. The per-call receipt the endpoint adds to its response is not
surfaced by 'ellmer'; use pnotp_chat() when you need to keep receipts.
An 'ellmer' Chat object.
## Not run: chat <- pnotp_ellmer_chat(system_prompt = "You are a terse R expert.") chat$chat("How do I pivot a data.frame longer?") # Tool calling with an R function chat$register_tool(ellmer::tool( function() format(Sys.time()), name = "now", description = "Current date and time." )) chat$chat("What time is it?") ## End(Not run)## Not run: chat <- pnotp_ellmer_chat(system_prompt = "You are a terse R expert.") chat$chat("How do I pivot a data.frame longer?") # Tool calling with an R function chat$register_tool(ellmer::tool( function() format(Sys.time()), name = "now", description = "Current date and time." )) chat$chat("What time is it?") ## End(Not run)
Every condition raised by the package inherits from pnotp_error. HTTP
failures inherit from pnotp_api_error and carry the fields the backend
publishes, so you never have to parse the message text:
status – the HTTP status code.
detail – the backend's detail (a string, or a list for validation
errors).
code – a stable enum on LLM endpoints, e.g.
"context_length_exceeded", "rate_limit_exceeded", "model_warming";
NULL when the endpoint does not publish one.
retryable – FALSE means retrying cannot succeed; NULL if unknown.
param – for parameter errors, the offending field.
info – the full error object (e.g. max_context, tokens_in).
| Class | When |
pnotp_auth_error |
401 / 403: missing, invalid or revoked key, or not your resource |
pnotp_insufficient_credits_error |
402: the account is out of credits |
pnotp_not_found_error |
404: the resource does not exist (or you cannot see it) |
pnotp_api_error |
any other non-2xx response |
pnotp_connection_error |
the API could not be reached |
pnotp_timeout_error |
pnotp_wait() ran out of time
|
## Not run: tryCatch( pnotp_chat("hello"), pnotp_insufficient_credits_error = function(e) message("Add credits in Studio"), pnotp_api_error = function(e) if (isTRUE(e$retryable)) message("retry later") ) ## End(Not run)## Not run: tryCatch( pnotp_chat("hello"), pnotp_insufficient_credits_error = function(e) message("Add credits in Studio"), pnotp_api_error = function(e) if (isTRUE(e$retryable)) message("retry later") ) ## End(Not run)
Is a PnotP API key available?
pnotp_has_key(client = NULL)pnotp_has_key(client = NULL)
client |
A |
TRUE when the client (by default, the environment) has a key.
List, fetch and control training jobs. Pausing or cancelling a running job is cooperative: the job stops at its next epoch boundary.
pnotp_jobs(client = NULL) pnotp_job(job, client = NULL) pnotp_job_pause(job, client = NULL) pnotp_job_resume(job, client = NULL) pnotp_job_cancel(job, client = NULL)pnotp_jobs(client = NULL) pnotp_job(job, client = NULL) pnotp_job_pause(job, client = NULL) pnotp_job_resume(job, client = NULL) pnotp_job_cancel(job, client = NULL)
client |
A |
job |
A job id or a |
pnotp_jobs() returns a data.frame; the others a pnotp_job.
Calls the OpenAI-compatible GET /v1/models (authenticated).
pnotp_llm_models(client = NULL)pnotp_llm_models(client = NULL)
client |
A |
A data.frame with one row per model: id, description,
vision, default, self_hosted, ...
Calls GET /v1/llm/pricing, which needs no API key. Rates are per
million tokens; metering_enabled says whether calls are billed today.
pnotp_llm_pricing(client = NULL)pnotp_llm_pricing(client = NULL)
client |
A |
A pnotp_pricing list (the raw response). Its print method shows
one row per model in USD per million tokens.
pnotp_llm_pricing()pnotp_llm_pricing()
A model record is a versioned model definition: an architecture graph, a
dataset reference and a training method. Train it with pnotp_train().
pnotp_models(project, client = NULL) pnotp_model(model, client = NULL) pnotp_model_create( project, name, architecture, description = "", dataset_reference = NULL, training_method = NULL, client = NULL ) pnotp_model_add_version( model, architecture, dataset_reference = NULL, training_method = NULL, client = NULL ) pnotp_model_versions(model, client = NULL)pnotp_models(project, client = NULL) pnotp_model(model, client = NULL) pnotp_model_create( project, name, architecture, description = "", dataset_reference = NULL, training_method = NULL, client = NULL ) pnotp_model_add_version( model, architecture, dataset_reference = NULL, training_method = NULL, client = NULL ) pnotp_model_versions(model, client = NULL)
project |
A project id or object. |
client |
A |
model |
A model record id or object. |
name |
Model name. |
architecture |
The architecture graph, e.g. from
|
description |
Free-text description. |
dataset_reference, training_method
|
Optional named lists, stored on the version. |
pnotp_model_create() and pnotp_model() return a
pnotp_model_record; pnotp_models() and pnotp_model_versions()
return data.frames; pnotp_model_add_version() returns the version.
## Not run: m <- pnotp_model_create(p, "cnn-v1", pnotp_arch_image_classifier(num_classes = 2)) pnotp_models(p) ## End(Not run)## Not run: m <- pnotp_model_create(p, "cnn-v1", pnotp_arch_image_classifier(num_classes = 2)) pnotp_models(p) ## End(Not run)
Each entry carries its inference parameter spec and an available flag.
The API answers 404 while the catalog is switched off.
pnotp_open_source_models(client = NULL)pnotp_open_source_models(client = NULL)
client |
A |
A data.frame.
Uploads file to POST /v1/deployments/{id}/predict. By default the
call uses your account key. Pass a per-deployment key (pnp_...) as
api_key to call as an external consumer; no account key is needed then.
pnotp_predict(deployment, file, ..., api_key = NULL, client = NULL)pnotp_predict(deployment, file, ..., api_key = NULL, client = NULL)
deployment |
A deployment id, or the object returned by
|
file |
Path to the input file (e.g. an image), or a raw vector. |
... |
Per-request inference parameter overrides for catalog
deployments, e.g. |
api_key |
A per-deployment key, used instead of the account key. |
client |
A |
On a compliant deployment the response carries a compliance block
(compliant, retention, deployment_id, timestamp); keep it as the
audit artifact.
Private (MPC) inference is not available from R yet; see the README.
The prediction, as a list (e.g. predictions, class_names).
## Not run: pnotp_predict("dep_123", "xray.jpg") pnotp_predict(dep, "street.jpg", confidence_threshold = 0.5) pnotp_predict(dep, "xray.jpg", api_key = Sys.getenv("PNOTP_DEPLOYMENT_KEY")) ## End(Not run)## Not run: pnotp_predict("dep_123", "xray.jpg") pnotp_predict(dep, "street.jpg", confidence_threshold = 0.5) pnotp_predict(dep, "xray.jpg", api_key = Sys.getenv("PNOTP_DEPLOYMENT_KEY")) ## End(Not run)
A project groups model records and deployments.
pnotp_projects(client = NULL) pnotp_project(project, client = NULL) pnotp_project_create( name, task_type = "binary_image_classification", description = "", architecture = NULL, ..., client = NULL )pnotp_projects(client = NULL) pnotp_project(project, client = NULL) pnotp_project_create( name, task_type = "binary_image_classification", description = "", architecture = NULL, ..., client = NULL )
client |
A |
project |
A project id, or an object returned by these functions. |
name |
Project name. |
task_type |
Task type, e.g. |
description |
Free-text description. |
architecture |
Optional base architecture id (e.g. |
... |
Extra fields sent with the create request. |
pnotp_projects() returns a data.frame; the others return the
project as a list.
## Not run: p <- pnotp_project_create("Chest X-ray", task_type = "binary_image_classification") pnotp_projects() pnotp_project(p) ## End(Not run)## Not run: p <- pnotp_project_create("Chest X-ray", task_type = "binary_image_classification") pnotp_projects() pnotp_project(p) ## End(Not run)
The low-level escape hatch every other function is built on. It sends the
account key both as Authorization: Bearer (the management API) and as
X-API-Key (inference), so one key authenticates every route, and turns
any HTTP error into a typed condition (see pnotp_errors).
pnotp_request( method, path, query = NULL, body = NULL, multipart = NULL, auth = TRUE, api_key = NULL, client = NULL )pnotp_request( method, path, query = NULL, body = NULL, multipart = NULL, auth = TRUE, api_key = NULL, client = NULL )
method |
HTTP method, e.g. |
path |
Route relative to the base URL, e.g. |
query |
Named list of query parameters. |
body |
A list, sent as a JSON body. Length-one vectors become JSON
scalars; wrap a vector in |
multipart |
Named list of multipart fields: strings, or
|
auth |
Send the API key? |
api_key |
Use this key instead of the client's for this call (used
for per-deployment |
client |
A |
The parsed JSON body as a list, a raw vector for non-JSON
responses, or NULL for an empty body.
## Not run: pnotp_request("GET", "platform/capabilities") ## End(Not run)## Not run: pnotp_request("GET", "platform/capabilities") ## End(Not run)
Stores the key in the PNOTP_API_KEY environment variable of the current
session. Called with no argument in an interactive session, it asks for
the key without echoing it (a masked dialog in 'RStudio').
pnotp_set_key(api_key = NULL)pnotp_set_key(api_key = NULL)
api_key |
An account API key ( |
To keep the key across sessions, add PNOTP_API_KEY=pnotp_sk_... to
~/.Renviron, for example with usethis::edit_r_environ(). This function
never writes that file itself.
TRUE, invisibly.
## Not run: pnotp_set_key() # asks, masked pnotp_set_key("pnotp_sk_...") ## End(Not run)## Not run: pnotp_set_key() # asks, masked pnotp_set_key("pnotp_sk_...") ## End(Not run)
Asks a question in plain English about the platform, your deployments, or an error you just hit. Toby needs an API key and credits.
pnotp_toby(question, history = NULL, client = NULL)pnotp_toby(question, history = NULL, client = NULL)
question |
Your question. |
history |
A previous |
client |
A |
Like the Python SDK's pnotp.help.toby(), this never raises: without a
key, without credits, or without a network, it returns an offline answer
(offline = TRUE) that says why and points at the local help.
Toby is told the question comes from this R package. Its built-in code
reference is the Python SDK's, so check function names against the R
help (?pnotp_chat) when it shows code.
A pnotp_toby_answer: a list with text, offline, reason,
proposed_action, and messages (the conversation so far, to pass as
history).
## Not run: a <- pnotp_toby("How do I deploy a model and call it?") a pnotp_toby("And how do I make it data-compliant?", history = a) tryCatch(pnotp_chat("hi"), pnotp_error = function(e) pnotp_toby(conditionMessage(e))) ## End(Not run)## Not run: a <- pnotp_toby("How do I deploy a model and call it?") a pnotp_toby("And how do I make it data-compliant?", history = a) tryCatch(pnotp_chat("hi"), pnotp_error = function(e) pnotp_toby(conditionMessage(e))) ## End(Not run)
Builds an OpenAI-style function tool for pnotp_chat(). It takes care of
the two JSON shapes R gets wrong by default: an empty properties is sent
as {} (not []), and required is always an array, even with one name.
pnotp_tool(name, description, properties = list(), required = character())pnotp_tool(name, description, properties = list(), required = character())
name |
Function name. |
description |
What the tool does; the model reads this. |
properties |
Named list of JSON Schema properties, e.g.
|
required |
Character vector of required property names. |
A list ready to pass in tools = list(...).
weather <- pnotp_tool( "get_weather", "Current weather for a city.", properties = list(city = list(type = "string")), required = "city" ) str(weather)weather <- pnotp_tool( "get_weather", "Current weather for a city.", properties = list(city = list(type = "string")), required = "city" ) str(weather)
Submits a training run for a model record. Image models train on a .zip
of class-named folders; tabular models train on a CSV, and you can pass a
data.frame directly (it is written to a temporary CSV, uploaded, and
deleted). Modality is detected from the model's architecture.
pnotp_train( model, dataset, version_id = NULL, epochs = 3, batch_size = 16, lr = 0.001, image_size = 64, target_column = "target", compute = NULL, gpu = NULL, wait = FALSE, client = NULL )pnotp_train( model, dataset, version_id = NULL, epochs = 3, batch_size = 16, lr = 0.001, image_size = 64, target_column = "target", compute = NULL, gpu = NULL, wait = FALSE, client = NULL )
model |
A model record id or object (from |
dataset |
A path to a |
version_id |
Version to train; |
epochs, batch_size, lr, image_size
|
Training hyperparameters. |
target_column |
For tabular data, the column holding the labels. |
compute |
|
gpu |
GPU tier, e.g. |
wait |
If |
client |
A |
A pnotp_job.
## Not run: m <- pnotp_model_create(p, "iris", pnotp_arch_tabular_classifier(n_features = 4, num_classes = 3)) job <- pnotp_train(m, iris, target_column = "Species", epochs = 20) job <- pnotp_wait(job) plot(pnotp_progress(job)) ## End(Not run)## Not run: m <- pnotp_model_create(p, "iris", pnotp_arch_tabular_classifier(n_features = 4, num_classes = 3)) job <- pnotp_train(m, iris, target_column = "Species", epochs = 20) job <- pnotp_wait(job) plot(pnotp_progress(job)) ## End(Not run)
Generics for training jobs (pnotp_train()) and hosted agent runs
(pnotp_agent_run()).
## S3 method for class 'pnotp_agent_run' pnotp_wait( x, poll_interval = 1, timeout = 120, on_progress = NULL, quiet = FALSE, client = NULL, ... ) ## S3 method for class 'pnotp_agent_run' pnotp_refresh(x, client = NULL, ...) ## S3 method for class 'pnotp_agent_run' pnotp_progress(x, client = NULL, ...) pnotp_wait(x, ...) pnotp_refresh(x, ...) pnotp_progress(x, ...) ## S3 method for class 'pnotp_job' pnotp_wait( x, poll_interval = 2, timeout = NULL, on_progress = NULL, quiet = FALSE, client = NULL, ... ) ## S3 method for class 'pnotp_job' pnotp_refresh(x, client = NULL, ...) ## S3 method for class 'pnotp_job' pnotp_progress(x, client = NULL, ...)## S3 method for class 'pnotp_agent_run' pnotp_wait( x, poll_interval = 1, timeout = 120, on_progress = NULL, quiet = FALSE, client = NULL, ... ) ## S3 method for class 'pnotp_agent_run' pnotp_refresh(x, client = NULL, ...) ## S3 method for class 'pnotp_agent_run' pnotp_progress(x, client = NULL, ...) pnotp_wait(x, ...) pnotp_refresh(x, ...) pnotp_progress(x, ...) ## S3 method for class 'pnotp_job' pnotp_wait( x, poll_interval = 2, timeout = NULL, on_progress = NULL, quiet = FALSE, client = NULL, ... ) ## S3 method for class 'pnotp_job' pnotp_refresh(x, client = NULL, ...) ## S3 method for class 'pnotp_job' pnotp_progress(x, client = NULL, ...)
x |
A |
poll_interval |
Seconds between polls. |
timeout |
Give up after this many seconds ( |
on_progress |
Optional function called with the refreshed object after every poll. |
quiet |
Suppress status messages. |
client |
A |
... |
Unused. |
pnotp_refresh() re-fetches the object.
pnotp_wait() polls until the status is succeeded, failed or
cancelled, reporting status changes. Press Esc to stop waiting; the
job itself keeps running.
pnotp_progress() returns the live progress snapshot. For a training
job, epochs is a data.frame with one row per finished epoch, and
plot() draws its metrics.
The refreshed object (pnotp_wait(), pnotp_refresh()), or a
progress list (pnotp_progress()).