cache_llm_call | R Documentation |
A memoised version of call_llm
to avoid repeated identical requests.
config |
An |
messages |
A list of message objects or character vector for embeddings. |
verbose |
Logical. If TRUE, prints the full API response (passed to |
json |
Logical. If TRUE, returns raw JSON (passed to |
- Requires the memoise
package. Add memoise
to your
package's DESCRIPTION.
- Clearing the cache can be done via memoise::forget(cache_llm_call)
or by restarting your R session.
The (memoised) response object from call_llm
.
## Not run:
# Using cache_llm_call:
response1 <- cache_llm_call(my_config, list(list(role="user", content="Hello!")))
# Subsequent identical calls won't hit the API unless we clear the cache.
response2 <- cache_llm_call(my_config, list(list(role="user", content="Hello!")))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.