-
Notifications
You must be signed in to change notification settings - Fork 322
Role Guide
sigoden edited this page Jun 3, 2024
·
19 revisions
Roles in AIChat define how the LLM will respond to your input. Each role consists of four fields:
-
name
: A unique identifier for the role (e.g., "shell", "translator"). -
prompt
: Instructions and context provided to the LLM. -
temperature
: (Optional) Controls the creativity and randomness of the LLM's response. -
top_p
: (Optional) Alternative way to control LLM's output diversity, affecting the probability distribution of tokens.
Here's a basic example:
- name: shell
prompt: >
I want you to act as a linux shell expert.
I want you to answer only with code.
Do not write explanations.
There are three types of prompts in AIChat:
- Contains
__INPUT__
placeholder, which gets replaced with your input. - Ideal for concise, input-driven replies.
- name: emoji
prompt: convert __INPUT__ to emoji
Running aichat -r emoji angry
would generate messages:
[
{"role": "user", "content": "convert angry to emoji"}
]
- Does not include
__INPUT__
. - Sets a general context for the LLM's behavior.
- name: emoji
prompt: convert my words to emoji
Running aichat -r emoji angry
would generate messages:
[
{"role": "system", "content": "convert my words to emoji"},
{"role": "user", "content": "angry"}
]
- An extension of the system prompt, offering more precise instructions.
- Uses
### INPUT:
and### OUTPUT:
to denote user and assistant messages.
- name: code
prompt: |-
Provide only code without comments or explanations.
### INPUT:
async sleep in js
### OUTPUT:
```javascript
async function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
Running aichat -r code echo server in node.js
would generate messages:
[
{"role": "system", "content": "Provide only code without comments or explanations."},
{"role": "user", "content": "async sleep in js"},
{"role": "assistant", "content": "```javascript\nasync function timeout(ms) {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n```"},
{"role": "user", "content": "echo server in node.js"}
]
ole arguments can be employed to supply extra parameters to the prompt.
- name: convert:json:yaml
prompt: convert __ARG1__ below to __ARG2__
:json:yaml
represents role args
. It contains two arguments:
- arg1
json
will replace__ARG1__
in the prompt - arg2
yaml
will replace__ARG2__
in the prompt
If we run aichat -r convert:json:yaml
, the prompt will be
convert json below to yaml
If we run aichat -r convert:yaml:toml
, the prompt will be
convert yaml below to toml
Different role args will generate different prompts.