Skip to content

Commit

Permalink
feat: CopilotChatReset command
Browse files Browse the repository at this point in the history
  • Loading branch information
gptlang committed Feb 14, 2024
1 parent 59931fd commit a5d9808
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 25 deletions.
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ repos:
rev: "23.10.0"
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: "5.12.0"
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: "6.1.0"
hooks:
Expand Down
13 changes: 5 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@

## [1.2.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.1.0...v1.2.0) (2024-02-13)


### Features

* restructure for pynvim 0.4.3 backwards compatibility ([#45](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/45)) ([52350c7](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/52350c78dbcfcb3acabf3478276ad9a87ebbfd26))
- restructure for pynvim 0.4.3 backwards compatibility ([#45](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/45)) ([52350c7](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/52350c78dbcfcb3acabf3478276ad9a87ebbfd26))

## [1.1.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.1...v1.1.0) (2024-02-10)


### Features

* **chat_handler:** show extra info only once ([589a453](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/589a4538d648c8723d839ca963a47a6176be3c78))
* Environment variables for proxy (HTTPS_PROXY and ALL_PROXY) ([043e731](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/043e731005278649dbdf1d5866c6e3c7719f1202))
* Proxy support ([19a8088](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/19a8088c171cb956fd553200b77c8dbbe76707b6))

- **chat_handler:** show extra info only once ([589a453](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/589a4538d648c8723d839ca963a47a6176be3c78))
- Environment variables for proxy (HTTPS_PROXY and ALL_PROXY) ([043e731](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/043e731005278649dbdf1d5866c6e3c7719f1202))
- Proxy support ([19a8088](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/19a8088c171cb956fd553200b77c8dbbe76707b6))

### Bug Fixes

* Wacky indentation in readme ([c5bf963](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/c5bf963f4702a8a94aa97de2e6205796cb381ae5))
- Wacky indentation in readme ([c5bf963](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/c5bf963f4702a8a94aa97de2e6205796cb381ae5))

## [1.0.1](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.0...v1.0.1) (2024-02-08)

Expand Down
7 changes: 5 additions & 2 deletions rplugin/python3/CopilotChat/copilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import uuid
from typing import Dict, List

import dotenv
import CopilotChat.prompts as prompts
import requests
import CopilotChat.typings as typings
import CopilotChat.utilities as utilities
import dotenv
import requests
from prompt_toolkit import PromptSession
from prompt_toolkit.history import InMemoryHistory

Expand Down Expand Up @@ -90,6 +90,9 @@ def authenticate(self):

self.token = self.session.get(url, headers=headers).json()

def reset(self):
self.chat_history = []

def ask(
self,
system_prompt: str,
Expand Down
5 changes: 5 additions & 0 deletions rplugin/python3/CopilotChat/copilot_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def copilot_agent_cmd(self, args: list[str]):
code = self.nvim.eval("getreg('\"')")
self.vsplit_chat_handler.chat(args[0], file_type, code)

@pynvim.command("CopilotChatReset")
def copilot_agent_reset_cmd(self):
if self.vsplit_chat_handler:
self.vsplit_chat_handler.copilot.reset()

@pynvim.command("CopilotChatVisual", nargs="1", range="")
def copilot_agent_visual_cmd(self, args: list[str], range: list[int]):
self.init_vsplit_chat_handler()
Expand Down
2 changes: 1 addition & 1 deletion rplugin/python3/CopilotChat/handlers/chat_handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import time
from datetime import datetime
from typing import Optional, cast
import os

import CopilotChat.prompts as system_prompts
from CopilotChat.copilot import Copilot
Expand Down
3 changes: 2 additions & 1 deletion rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from CopilotChat.copilot import Copilot
from CopilotChat.handlers.chat_handler import ChatHandler
from CopilotChat.mypynvim.core.buffer import MyBuffer
from CopilotChat.mypynvim.core.nvim import MyNvim
Expand All @@ -6,7 +7,7 @@
class VSplitChatHandler(ChatHandler):
def __init__(self, nvim: MyNvim):
self.nvim: MyNvim = nvim
self.copilot = None
self.copilot: Copilot = None
self.buffer: MyBuffer = MyBuffer.new(
self.nvim,
{
Expand Down
5 changes: 2 additions & 3 deletions rplugin/python3/CopilotChat/mypynvim/core/nvim.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from typing import Iterable, Union

from pynvim import Nvim
from pynvim.api.nvim import Current

from CopilotChat.mypynvim.core.autocmdmapper import AutocmdMapper
from CopilotChat.mypynvim.core.buffer import MyBuffer
from CopilotChat.mypynvim.core.keymapper import Keymapper
from CopilotChat.mypynvim.core.window import MyWindow
from pynvim import Nvim
from pynvim.api.nvim import Current


class MyNvim(Nvim):
Expand Down
3 changes: 1 addition & 2 deletions rplugin/python3/CopilotChat/mypynvim/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

from typing import TYPE_CHECKING

from pynvim.api import Window

from CopilotChat.mypynvim.core.buffer import MyBuffer
from pynvim.api import Window

if TYPE_CHECKING:
from CopilotChat.mypynvim.core.nvim import MyNvim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Callable, Literal, Optional, Union, cast

from CopilotChat.mypynvim.core.nvim import MyNvim

from CopilotChat.mypynvim.ui_components.calculator import Calculator
from CopilotChat.mypynvim.ui_components.popup import PopUp
from CopilotChat.mypynvim.ui_components.types import PopUpConfiguration, Relative
Expand Down
8 changes: 5 additions & 3 deletions rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

from CopilotChat.mypynvim.ui_components.layout import Layout


from CopilotChat.mypynvim.core.buffer import MyBuffer
from CopilotChat.mypynvim.core.window import MyWindow

from CopilotChat.mypynvim.ui_components.calculator import Calculator
from CopilotChat.mypynvim.ui_components.types import PaddingKeys, PopUpConfiguration, Relative
from CopilotChat.mypynvim.ui_components.types import (
PaddingKeys,
PopUpConfiguration,
Relative,
)


@dataclass
Expand Down

0 comments on commit a5d9808

Please sign in to comment.