mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 10:14:59 +00:00
aider: Add typing simulation to get_input function.
# Context: USER: in this case, have it still print the "> " followed by the inputted line. but write and flush one character at a time, with small random delays in between so it looks like typing ASSISTANT: To achieve this, you can use the `time` module to introduce small random delays and print the characters one by one. Here's the change you need to make in the `get_input` function: ```python aider/getinput.py <<<<<<< ORIGINAL import sys def get_input(history_file, fnames): if not sys.stdin.isatty(): return input() ======= import sys import time import random def get_input(history_file, fnames): if not sys.stdin.isatty(): input_line = input() print("> ", end="") for char in input_line: print(char, end="", flush=True) time.sleep(random.uniform(0.05, 0.2)) print() return input_line >>>>>>> UPDATED ``` This change imports the `time` and `random` modules. When the input is coming from a file, it reads the input line, prints the "> " prompt, and then prints each character in the input line with a small random delay between 0.05 and 0.2 seconds, simulating typing.
This commit is contained in:
parent
c3eb968ec4
commit
659ce00c40
1 changed files with 9 additions and 1 deletions
|
@ -26,10 +26,18 @@ class FileContentCompleter(Completer):
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
import random
|
||||||
|
|
||||||
def get_input(history_file, fnames):
|
def get_input(history_file, fnames):
|
||||||
if not sys.stdin.isatty():
|
if not sys.stdin.isatty():
|
||||||
return input()
|
input_line = input()
|
||||||
|
print("> ", end="")
|
||||||
|
for char in input_line:
|
||||||
|
print(char, end="", flush=True)
|
||||||
|
time.sleep(random.uniform(0.05, 0.2))
|
||||||
|
print()
|
||||||
|
return input_line
|
||||||
inp = ""
|
inp = ""
|
||||||
multiline_input = False
|
multiline_input = False
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue