(self, text, linebreak=False, blockquote=False, strip=True)
| 1115 | ) |
| 1116 | |
| 1117 | def append_chat_history(self, text, linebreak=False, blockquote=False, strip=True): |
| 1118 | if blockquote: |
| 1119 | if strip: |
| 1120 | text = text.strip() |
| 1121 | text = "> " + text |
| 1122 | if linebreak: |
| 1123 | if strip: |
| 1124 | text = text.rstrip() |
| 1125 | text = text + " \n" |
| 1126 | if not text.endswith("\n"): |
| 1127 | text += "\n" |
| 1128 | if self.chat_history_file is not None: |
| 1129 | try: |
| 1130 | self.chat_history_file.parent.mkdir(parents=True, exist_ok=True) |
| 1131 | with self.chat_history_file.open("a", encoding=self.encoding, errors="ignore") as f: |
| 1132 | f.write(text) |
| 1133 | except (PermissionError, OSError) as err: |
| 1134 | print(f"Warning: Unable to write to chat history file {self.chat_history_file}.") |
| 1135 | print(err) |
| 1136 | self.chat_history_file = None # Disable further attempts to write |
| 1137 | |
| 1138 | def format_files_for_input(self, rel_fnames, rel_read_only_fnames): |
| 1139 | if not self.pretty: |
no outgoing calls
no test coverage detected