fix: 💄 don't display entirety of large tracebacks

This commit is contained in:
Nate Sesti 2023-08-23 17:15:09 -07:00
parent 3497f1af95
commit a74eda56cf
3 changed files with 12 additions and 1 deletions

View file

@ -59,6 +59,8 @@ class FileContextProvider(ContextProvider):
async def on_file_saved(filepath: str, contents: str):
item = await self.get_context_item_for_filepath(filepath)
if item is None:
return
await self.update_documents([item], self.sdk.ide.workspace_directory)
async def on_files_created(filepaths: List[str]):

View file

@ -898,6 +898,8 @@ class UserInputStep(Step):
manage_own_chat_context: bool = True
async def describe(self, models: Models) -> Coroutine[str, None, None]:
if self.description is not None:
return self.description
return self.user_input
async def run(

View file

@ -44,9 +44,16 @@ class DefaultOnTracebackStep(Step):
tb = parsed_tb
break
tb_first_last_lines = (
("\n".join(tb.split("\n")[:3]) + "\n...\n" + "\n".join(tb.split("\n")[-3:]))
if len(tb.split("\n")) > 6
else tb
)
await sdk.run_step(
UserInputStep(
user_input=f"""I got the following error, can you please help explain how to fix it?\n\n{tb}"""
description=f"""I got the following error, can you please help explain how to fix it?\n\n{tb_first_last_lines}""",
user_input=f"""I got the following error, can you please help explain how to fix it?\n\n{tb}""",
)
)
await sdk.run_step(SimpleChatStep(name="Help With Traceback"))