Skip to content

Custom REPL Prompt

sigoden edited this page Aug 1, 2024 · 6 revisions

The prompts can display information about the current context, such as the active role, session, RAG, or agent.

States & Showcases

STATE SHOWCASE
none
role
session
agent
rag
session+role
session+rag
session+role+rag
agent+session
agent+rag
agent+session+rag

Configuration

Edit the left_prompt and right_prompt configuration items to customize the REPL's left and right prompts.

The default configuration:

# REPL left prompt
left_prompt: '{color.green}{?session {?agent {agent}>}{session}{?role /}}{!session {?agent {agent}>}}{role}{?rag @{rag}}{color.cyan}{?session )}{!session >}{color.reset} '
# REPL right prompt
right_prompt: '{color.purple}{?session {?consume_tokens {consume_tokens}({consume_percent}%)}{!consume_tokens {consume_tokens}}}{color.reset}'

Syntaxes

The prompt template comprises plain text and {...}.

The syntax of {...} is:

  • {var} - Replace with value of var
  • {?var <template>} - Eval template when var is evaluated as true
  • {!var <template>} - Eval template when var is evaluated as false

Variables

# Model
model: openai:gpt-4
client_name: openai
model_name: gpt-4
max_input_tokens: 4096

# Config
temperature: 1.0
top_p: 0.9
dry_run: true
stream: false
save: true
wrap: 120

role: coder

# Session
session: temp
dirty: false
consume_tokens: 200
consume_percent: 1%
user_messages_len: 0

rag: temp

agent: todo-sh

# ANSI COLORS
color.reset:
color.black:
color.dark_gray:
color.red:
color.light_red:
color.green:
color.light_green:
color.yellow:
color.light_yellow:
color.blue:
color.light_blue:
color.purple:
color.light_purple:
color.magenta:
color.light_magenta:
color.cyan:
color.light_cyan:
color.white:
color.light_gray:
Clone this wiki locally