wander
is a simple Python library that makes it easier to incorporate external data into LLM prompt.
You can install wander
with pip
pip install wander
You need to have Python version 3.10 or above to use this library.
Assuming you have an markdown text with a special block !shell
.
text = """\
Today is:
```!shell
date
```\
"""
Using wander
to render it.
from wander import Renderer
from wander.plugins import ShellPlugin
renderer = Renderer(plugins=[ShellPlugin()])
renderer.render(text)
Output:
Today is:
Wed May 17 16:48:09 +08 2023
To write your own plugin, simply inherit the Plugin
class and do the following:
- Specify
plugin_name
property. This will be the name of the directive used in your special block. - Specify
parser
property, which is anargparse.ArgumentParser
object to define what CLI-like arguments are accepted after the directive name - Implement
run
async method. It must takes anargs
argument holding all the values of the command arguments defined in your parser as well ascontent
argument holding all texts in the block.
You can find an example in shell.py.