|
20 | 20 | to do so, it needs to be able to store and query past conversations in a database.
|
21 | 21 | """
|
22 | 22 | # The above may be used as a prompt for the agent.
|
23 |
| - |
24 | 23 | import atexit
|
25 | 24 | import errno
|
26 | 25 | import importlib.metadata
|
|
44 | 43 | from .llm import init_llm, reply
|
45 | 44 | from .logmanager import LogManager, _conversations
|
46 | 45 | from .message import Message
|
47 |
| -from .prompts import initial_prompt_single_message |
| 46 | +from .prompts import get_prompt |
48 | 47 | from .tabcomplete import register_tabcomplete
|
49 | 48 | from .tools import execute_msg, init_tools
|
50 | 49 | from .util import epoch_to_age, generate_unique_name
|
@@ -166,29 +165,27 @@ def main(
|
166 | 165 | if no_confirm:
|
167 | 166 | logger.warning("Skipping all confirmation prompts.")
|
168 | 167 |
|
169 |
| - if prompt_system in ["full", "short"]: |
170 |
| - promptmsgs = [initial_prompt_single_message(short=prompt_system == "short")] |
171 |
| - else: |
172 |
| - promptmsgs = [Message("system", prompt_system)] |
173 |
| - |
174 |
| - # we need to run this before checking stdin, since the interactive doesn't work with the switch back to interactive mode |
175 |
| - logfile = get_logfile( |
176 |
| - name, interactive=(not prompts and interactive) and sys.stdin.isatty() |
177 |
| - ) |
178 |
| - print(f"Using logdir {logfile.parent}") |
179 |
| - log = LogManager.load(logfile, initial_msgs=promptmsgs, show_hidden=show_hidden) |
| 168 | + # get initial system prompt |
| 169 | + prompt_msgs = [get_prompt(prompt_system)] |
180 | 170 |
|
181 |
| - # if stdin is not a tty, we're getting piped input |
| 171 | + # if stdin is not a tty, we're getting piped input, which we should include in the prompt |
182 | 172 | if not sys.stdin.isatty():
|
183 | 173 | # fetch prompt from stdin
|
184 | 174 | prompt_stdin = _read_stdin()
|
185 | 175 | if prompt_stdin:
|
186 |
| - promptmsgs += [Message("system", prompt_stdin)] |
| 176 | + prompt_msgs += [Message("system", f"```stdin\n{prompt_stdin}\n```")] |
187 | 177 |
|
188 | 178 | # Attempt to switch to interactive mode
|
189 | 179 | sys.stdin.close()
|
190 | 180 | sys.stdin = open("/dev/tty")
|
191 | 181 |
|
| 182 | + # we need to run this before checking stdin, since the interactive doesn't work with the switch back to interactive mode |
| 183 | + logfile = get_logfile( |
| 184 | + name, interactive=(not prompts and interactive) and sys.stdin.isatty() |
| 185 | + ) |
| 186 | + print(f"Using logdir {logfile.parent}") |
| 187 | + log = LogManager.load(logfile, initial_msgs=prompt_msgs, show_hidden=show_hidden) |
| 188 | + |
192 | 189 | # print log
|
193 | 190 | log.print()
|
194 | 191 | print("--- ^^^ past messages ^^^ ---")
|
|
0 commit comments