-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: append assistant message for chat
- Loading branch information
1 parent
104d7b2
commit 17797ed
Showing
6 changed files
with
51 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import readline | ||
import atexit | ||
from .utils.conf import CONF_PATH, MAX_HISTORY | ||
from os import path | ||
|
||
|
||
class History: | ||
def __init__(self, filename=path.join(CONF_PATH, "history")): | ||
self.filename = filename | ||
try: | ||
readline.read_history_file(filename) | ||
readline.set_history_length(MAX_HISTORY) | ||
except FileNotFoundError: | ||
pass | ||
atexit.register(self.save) | ||
|
||
def save(self): | ||
try: | ||
readline.write_history_file(self.filename) | ||
except Exception: | ||
pass | ||
|
||
def add(self, line): | ||
readline.add_history(line) | ||
|
||
def __del__(self): | ||
self.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters