patch and get file content in DefaultOnTracebackStep
This commit is contained in:
parent
149db20960
commit
f6d940dead
6 changed files with 14 additions and 5 deletions
|
|
@ -85,7 +85,7 @@ class AbstractContinueSDK(ABC):
|
|||
pass
|
||||
|
||||
@abstractmethod
|
||||
def add_chat_context(self, content: str, role: ChatMessageRole = "assistent"):
|
||||
def add_chat_context(self, content: str, role: ChatMessageRole = "assistant"):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ class ContinueSDK(AbstractContinueSDK):
|
|||
def raise_exception(self, message: str, title: str, with_step: Union[Step, None] = None):
|
||||
raise ContinueCustomException(message, title, with_step)
|
||||
|
||||
def add_chat_context(self, content: str, summary: Union[str, None] = None, role: ChatMessageRole = "assistent"):
|
||||
def add_chat_context(self, content: str, summary: Union[str, None] = None, role: ChatMessageRole = "assistant"):
|
||||
self.history.timeline[self.history.current_index].step.chat_context.append(
|
||||
ChatMessage(content=content, role=role, summary=summary))
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
from ..core.main import Step
|
||||
from ..core.sdk import ContinueSDK
|
||||
from .chat import SimpleChatStep
|
||||
|
|
@ -9,6 +10,14 @@ class DefaultOnTracebackStep(Step):
|
|||
hide: bool = True
|
||||
|
||||
async def run(self, sdk: ContinueSDK):
|
||||
# Add context for any files in the traceback that are in the workspace
|
||||
for line in self.output.split("\n"):
|
||||
segs = line.split(" ")
|
||||
for seg in segs:
|
||||
if seg.startswith(os.path.sep) and os.path.exists(seg) and os.path.commonprefix([seg, sdk.ide.workspace_directory]) == sdk.ide.workspace_directory:
|
||||
file_contents = await sdk.ide.readFile(seg)
|
||||
await sdk.add_chat_context(f"The contents of {seg}:\n```\n{file_contents}\n```", "", "user")
|
||||
|
||||
await sdk.run_step(SimpleChatStep(
|
||||
name="Help With Traceback",
|
||||
user_input=f"""I got the following error, can you please help explain how to fix it?\n\n{self.output}"""))
|
||||
|
|
|
|||
4
extension/package-lock.json
generated
4
extension/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.0.44",
|
||||
"version": "0.0.45",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.0.44",
|
||||
"version": "0.0.45",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
"displayName": "Continue",
|
||||
"pricing": "Free",
|
||||
"description": "Refine code 10x faster",
|
||||
"version": "0.0.44",
|
||||
"version": "0.0.45",
|
||||
"publisher": "Continue",
|
||||
"engines": {
|
||||
"vscode": "^1.74.0"
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Reference in a new issue