Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
refactor: merge system prompts to one file
Browse files Browse the repository at this point in the history
  • Loading branch information
jellydn committed Feb 4, 2024
1 parent c8a3012 commit 2acecd4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
16 changes: 8 additions & 8 deletions rplugin/python3/handlers/chat_handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +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
Expand Down Expand Up @@ -58,13 +58,13 @@ def chat(
# 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(
Expand Down
6 changes: 2 additions & 4 deletions rplugin/python3/handlers/inplace_chat_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -243,10 +241,10 @@ def _set_keymaps(self):
self.prompt_popup.map("n", "<C-m>", 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(
Expand Down
2 changes: 0 additions & 2 deletions rplugin/python3/handlers/prompts.py

This file was deleted.

2 changes: 2 additions & 0 deletions rplugin/python3/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 2acecd4

Please sign in to comment.