-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace roles.yaml
with roles/<name>.md
#804
Comments
We provide a Python script to convert import yaml
import os
def convert(yaml_file, saved_dir):
with open(yaml_file, 'r', encoding='utf-8') as f:
yaml_content = f.read()
data = yaml.safe_load(yaml_content)
os.makedirs(saved_dir, exist_ok=True)
for item in data:
if 'name' not in item or 'prompt' not in item:
continue # Skip items that do not have the necessary fields
name = item.pop('name').replace(':', '#')
prompt = item.pop('prompt')
markdown_file = os.path.join(saved_dir, f"{name}.md")
metadata = ''
if item:
metadata = '---\n' + yaml.dump(item) + '---\n\n'
with open(markdown_file, 'w', encoding='utf-8') as f:
f.write(metadata + prompt)
convert("roles.yaml", "roles")
|
Confirm if there are any parameters that don't support |
Thank you for the script. However, please remind the viewers that this script requires the PyYAML library to be installed in order to work ( https://pypi.org/project/PyYAML/ ). Since PyYaml is not included in the Python standard library by default, if you want to run this script from the command line, you will often need to enter the following commands: cd <aichat-config-dir>
python -m venv .venv
source .venv/bin/activate # if you use bash or zsh, if you are using Fish use "source .venv/bin/activate.fish"
pip install pyyaml
python convert.py
deactivate
rm -rf .venv |
Would be nice to have a link to this included when not finding a role for the next few versions, took me a while to get here after my existing roles unexpectedly stopped working |
aichat could also offer to automatically run the migration small issue, this role is not correctly converted: - name: convert:json:yaml
prompt: convert __ARG1__ below to __ARG2__ |
Instead of using a central
roles.yaml
file to store all the roles, we can use a dedicated roles folder. Each file within this folder would represent a single role, with the filename corresponding to the role's name.Benefits
REPL
.role <name>
: Create a new role if one doesn't exist.edit role
: Edit the current role.save role
: Save the current role to fileOptions
The text was updated successfully, but these errors were encountered: