|
| 1 | +from datetime import datetime |
1 | 2 | from typing import Optional, cast |
2 | 3 |
|
3 | | -import prompts as prompts |
| 4 | +import prompts as system_prompts |
4 | 5 | from copilot import Copilot |
5 | 6 | from mypynvim.core.buffer import MyBuffer |
6 | 7 | from mypynvim.core.nvim import MyNvim |
@@ -52,18 +53,18 @@ def chat( |
52 | 53 | self.nvim.exec_lua('require("CopilotChat.spinner").hide()') |
53 | 54 |
|
54 | 55 | if not disable_end_separator: |
55 | | - self._add_end_separator() |
| 56 | + self._add_end_separator(model) |
56 | 57 |
|
57 | 58 | # private |
58 | 59 |
|
59 | 60 | def _construct_system_prompt(self, prompt: str): |
60 | | - system_prompt = prompts.COPILOT_INSTRUCTIONS |
61 | | - if prompt == prompts.FIX_SHORTCUT: |
62 | | - system_prompt = prompts.COPILOT_FIX |
63 | | - elif prompt == prompts.TEST_SHORTCUT: |
64 | | - system_prompt = prompts.COPILOT_TESTS |
65 | | - elif prompt == prompts.EXPLAIN_SHORTCUT: |
66 | | - system_prompt = prompts.COPILOT_EXPLAIN |
| 61 | + system_prompt = system_prompts.COPILOT_INSTRUCTIONS |
| 62 | + if prompt == system_prompts.FIX_SHORTCUT: |
| 63 | + system_prompt = system_prompts.COPILOT_FIX |
| 64 | + elif prompt == system_prompts.TEST_SHORTCUT: |
| 65 | + system_prompt = system_prompts.COPILOT_TESTS |
| 66 | + elif prompt == system_prompts.EXPLAIN_SHORTCUT: |
| 67 | + system_prompt = system_prompts.COPILOT_EXPLAIN |
67 | 68 | return system_prompt |
68 | 69 |
|
69 | 70 | def _add_start_separator( |
@@ -204,6 +205,13 @@ def _add_chat_messages( |
204 | 205 | token.split("\n"), |
205 | 206 | ) |
206 | 207 |
|
207 | | - def _add_end_separator(self): |
208 | | - end_separator = "\n---\n" |
209 | | - self.buffer.append(end_separator.split("\n")) |
| 208 | + def _add_end_separator(self, model: str): |
| 209 | + current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") |
| 210 | + model_info = f"\n#### Answer provided by Copilot (Model: `{model}`) on {current_datetime}." |
| 211 | + additional_instructions = ( |
| 212 | + "\n> For additional queries, please use the `CopilotChat` command." |
| 213 | + ) |
| 214 | + disclaimer = "\n> Please be aware that the AI's output may not always be accurate. Always cross-verify the output.\n---\n" |
| 215 | + |
| 216 | + end_message = model_info + additional_instructions + disclaimer |
| 217 | + self.buffer.append(end_message.split("\n")) |
0 commit comments