From ca6321cb257ed4f38ec9848712fd559639f2df33 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 4 Feb 2024 07:24:46 +0000 Subject: [PATCH 1/4] chore(doc): auto generate docs --- doc/CopilotChat.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 0b0b8f22..1ff3f1bd 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 03 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 04 ============================================================================== Table of Contents *CopilotChat-table-of-contents* From b8d0a9d0e0824ff3b643a2652202be2a51b37dbc Mon Sep 17 00:00:00 2001 From: "Dung Duc Huynh (Kaka)" <870029+jellydn@users.noreply.github.com> Date: Sun, 4 Feb 2024 15:29:58 +0800 Subject: [PATCH 2/4] feat: show date time and additional information on end separator (#53) * feat: show date time and addition information on end separator * refactor: merge system prompts to one file --- rplugin/python3/handlers/chat_handler.py | 32 ++++++++++++------- .../python3/handlers/inplace_chat_handler.py | 6 ++-- rplugin/python3/handlers/prompts.py | 2 -- rplugin/python3/prompts.py | 2 ++ 4 files changed, 24 insertions(+), 18 deletions(-) delete mode 100644 rplugin/python3/handlers/prompts.py diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/handlers/chat_handler.py index ebcdfac6..75f1a3d7 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/handlers/chat_handler.py @@ -1,6 +1,7 @@ +from datetime import datetime from typing import Optional, cast -import prompts as prompts +import prompts as system_prompts from copilot import Copilot from mypynvim.core.buffer import MyBuffer from mypynvim.core.nvim import MyNvim @@ -52,18 +53,18 @@ def chat( self.nvim.exec_lua('require("CopilotChat.spinner").hide()') if not disable_end_separator: - self._add_end_separator() + self._add_end_separator(model) # private def _construct_system_prompt(self, prompt: str): - system_prompt = prompts.COPILOT_INSTRUCTIONS - if prompt == prompts.FIX_SHORTCUT: - system_prompt = prompts.COPILOT_FIX - elif prompt == prompts.TEST_SHORTCUT: - system_prompt = prompts.COPILOT_TESTS - elif prompt == prompts.EXPLAIN_SHORTCUT: - system_prompt = prompts.COPILOT_EXPLAIN + system_prompt = system_prompts.COPILOT_INSTRUCTIONS + if prompt == system_prompts.FIX_SHORTCUT: + system_prompt = system_prompts.COPILOT_FIX + elif prompt == system_prompts.TEST_SHORTCUT: + system_prompt = system_prompts.COPILOT_TESTS + elif prompt == system_prompts.EXPLAIN_SHORTCUT: + system_prompt = system_prompts.COPILOT_EXPLAIN return system_prompt def _add_start_separator( @@ -204,6 +205,13 @@ def _add_chat_messages( token.split("\n"), ) - def _add_end_separator(self): - end_separator = "\n---\n" - self.buffer.append(end_separator.split("\n")) + def _add_end_separator(self, model: str): + current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + model_info = f"\n#### Answer provided by Copilot (Model: `{model}`) on {current_datetime}." + additional_instructions = ( + "\n> For additional queries, please use the `CopilotChat` command." + ) + disclaimer = "\n> Please be aware that the AI's output may not always be accurate. Always cross-verify the output.\n---\n" + + end_message = model_info + additional_instructions + disclaimer + self.buffer.append(end_message.split("\n")) diff --git a/rplugin/python3/handlers/inplace_chat_handler.py b/rplugin/python3/handlers/inplace_chat_handler.py index d3b36dc2..f0d784f2 100644 --- a/rplugin/python3/handlers/inplace_chat_handler.py +++ b/rplugin/python3/handlers/inplace_chat_handler.py @@ -5,8 +5,6 @@ from mypynvim.ui_components.layout import Box, Layout from mypynvim.ui_components.popup import PopUp -from . import prompts - # Define constants for the models MODEL_GPT4 = "gpt-4" MODEL_GPT35_TURBO = "gpt-3.5-turbo" @@ -243,10 +241,10 @@ def _set_keymaps(self): self.prompt_popup.map("n", "", lambda cb=self._toggle_system_model: cb()) self.prompt_popup.map( - "n", "'", lambda: self._set_prompt(prompts.PROMPT_SIMPLE_DOCSTRING) + "n", "'", lambda: self._set_prompt(system_prompts.PROMPT_SIMPLE_DOCSTRING) ) self.prompt_popup.map( - "n", "s", lambda: self._set_prompt(prompts.PROMPT_SEPARATE) + "n", "s", lambda: self._set_prompt(system_prompts.PROMPT_SEPARATE) ) self.prompt_popup.map( diff --git a/rplugin/python3/handlers/prompts.py b/rplugin/python3/handlers/prompts.py deleted file mode 100644 index f12db7c7..00000000 --- a/rplugin/python3/handlers/prompts.py +++ /dev/null @@ -1,2 +0,0 @@ -PROMPT_SIMPLE_DOCSTRING = "add simple docstring to this code" -PROMPT_SEPARATE = "add comments separating the code into sections" diff --git a/rplugin/python3/prompts.py b/rplugin/python3/prompts.py index 34a857a4..1290cbb0 100644 --- a/rplugin/python3/prompts.py +++ b/rplugin/python3/prompts.py @@ -247,3 +247,5 @@ Your code output should keep the same level of indentation as the user's code. You MUST add whitespace in the beginning of each line as needed to match the user's code. """ +PROMPT_SIMPLE_DOCSTRING = "add simple docstring to this code" +PROMPT_SEPARATE = "add comments separating the code into sections" From 0b917f633eaef621d293f344965e9e0545be9a80 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sun, 4 Feb 2024 15:42:27 +0800 Subject: [PATCH 3/4] fix: handle get remote plugin path on Windows --- lua/CopilotChat/utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/CopilotChat/utils.lua b/lua/CopilotChat/utils.lua index 472c411e..3d83bdc3 100644 --- a/lua/CopilotChat/utils.lua +++ b/lua/CopilotChat/utils.lua @@ -16,7 +16,7 @@ M.get_remote_plugins_path = function() local os = vim.loop.os_uname().sysname if os == 'Linux' or os == 'Darwin' then return '~/.local/share/nvim/rplugin.vim' - elseif os == 'Windows' then + else return '~/AppData/Local/nvim/rplugin.vim' end end From 07cb1de2e225744fb74f6cc46fccadcd1df8466a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 15:59:45 +0800 Subject: [PATCH 4/4] chore(main): release 1.2.0 (#54) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5dba741..3c095c00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [1.2.0](https://github.com/jellydn/CopilotChat.nvim/compare/v1.1.0...v1.2.0) (2024-02-04) + + +### Features + +* show date time and additional information on end separator ([#53](https://github.com/jellydn/CopilotChat.nvim/issues/53)) ([b8d0a9d](https://github.com/jellydn/CopilotChat.nvim/commit/b8d0a9d0e0824ff3b643a2652202be2a51b37dbc)) + + +### Bug Fixes + +* handle get remote plugin path on Windows ([0b917f6](https://github.com/jellydn/CopilotChat.nvim/commit/0b917f633eaef621d293f344965e9e0545be9a80)) + ## [1.1.0](https://github.com/jellydn/CopilotChat.nvim/compare/v1.0.0...v1.1.0) (2024-02-04)