Larkdown: Rmarkdown as LLM Interface
Larkdown Link to heading
Overview Link to heading
Larkdown is an R package I wrote to integrate AI into my personal creative workflows. It turns Rmarkdown and Rstudio into an interface for large language models (LLMs). It uses the LangChain Python library under the hood, so the “AI” that we interact with could take a variety of forms.
Use Cases Link to heading
- AI Conversations without ChatGPT: Use any model you want via LangChain and use Rstudio as the chat window.
- Custom AI Personas: Hit up
chaz_persona()
to create bespoke AI personas tailored to specific topics. - Multi-language Code Execution: Write and execute code in various programming languages within Rmarkdown.
- Rstudio Integration: Larkdown uses the
rstudioapi
package to send currently-opened file contents to the python parser and on to the LLM endpoint, among other things. It’s easy to bind keyboard shortcuts to R functions in Rstudio, and coupled with Larkdown this makes for super-quick interaction with arbitrary AI agents.
Features Link to heading
- Document Creation:
new_larkdown()
: Create new Larkdown documents.journal()
: Generate daily notebook Larkdown documents.
- Message Conversion:
knit_to_messages()
: Convert a Larkdown document into a list of LangChain messages.
- API Interaction:
knit_and_stream_current()
: Parse the document, send it to the API, and stream back the response with a keyboard shortcut and Rstudio addin.
- Custom Personas:
chaz_persona()
: Create a custom personality for specific conversational topics.
- Document Search:
ld_search()
: Search through an index of existing Larkdown documents.
Installation Link to heading
To install Larkdown, follow the instructions provided in the README.
devtools::install_github("markwh/larkdown")
library(larkdown)
Configure the LangServe endpoint:
register_endpoint("your_endpoint_url")
Caveats Link to heading
Larkdown is…probably not yet ready for wide release, and I’m not sure it ever will be. It’s made for and motivated by my own purposes, so that’s doesn’t bode well. On the other hand, if I continue to find it useful and preferable to other tools I will likely continue to improve it, so who knows?
License Link to heading
Larkdown is released under the MIT License.