trading_agent.terminal.prompt_history
¶
The prompts typed in the terminal program, recalled with Up and Down and searched with Ctrl+R.
Each prompt is one JSON string per line, so prompts with several lines are kept whole. The newest 1000 are kept.
Typical usage example:
history = PromptHistory(Path('~/.local/state/trading-agent/history').expanduser()) history.add('/status') history.previous('') # '/status'
PromptHistory
¶
The typed prompts, oldest first, with a cursor for Up and Down.
Reads the saved prompts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
Path | None
|
Where prompts are kept, or None to keep them only in memory. |
required |
Source code in src/trading_agent/terminal/prompt_history.py
add
¶
Records a sent prompt, unless it repeats the newest one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
The prompt. |
required |
Source code in src/trading_agent/terminal/prompt_history.py
previous
¶
Moves one prompt back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current
|
str
|
What is in the input box now; kept as the draft when leaving it. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The older prompt, or None at the oldest. |
Source code in src/trading_agent/terminal/prompt_history.py
next
¶
Moves one prompt forward.
Returns:
| Type | Description |
|---|---|
str | None
|
The newer prompt, the draft after the newest, or None when not browsing. |
Source code in src/trading_agent/terminal/prompt_history.py
search
¶
The prompts that contain some text, newest first, each once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
words
|
str
|
The text to look for, ignoring case. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
The matching prompts. |