Skip to content

Commit

Permalink
Added important_stream message to the core - this tells the extension…
Browse files Browse the repository at this point in the history
… that the next stream should be visible to the user (unfolded) and currently, render it as a markdown
  • Loading branch information
Zvonimir Sabljic committed Aug 10, 2024
1 parent 3587763 commit 0fab947
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/agents/bug_hunter.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ async def start_pair_programming(self):
convo = self.generate_iteration_convo_so_far(True)
convo.remove_last_x_messages(1)
convo = convo.template("problem_explanation")
await self.ui.start_important_stream()
initial_explanation = await llm(convo, temperature=0.5)

convo = convo.template("data_about_logs").require_schema(ImportantLogsForDebugging)
Expand Down Expand Up @@ -236,23 +237,27 @@ async def start_pair_programming(self):
elif next_step.button == "question":
user_response = await self.ask_question("Oh, cool, what would you like to know?")
convo = convo.template("ask_a_question", question=user_response.text)
await self.ui.start_important_stream()
llm_answer = await llm(convo, temperature=0.5)
await self.send_message(llm_answer)
elif next_step.button == "tell_me_more":
convo.template("tell_me_more")
await self.ui.start_important_stream()
response = await llm(convo, temperature=0.5)
await self.send_message(response)
elif next_step.button == "other":
# this is the same as "question" - we want to keep an option for users to click to understand if we're missing something with other options
user_response = await self.ask_question("Let me know what you think...")
convo = convo.template("ask_a_question", question=user_response.text)
await self.ui.start_important_stream()
llm_answer = await llm(convo, temperature=0.5)
await self.send_message(llm_answer)
elif next_step.button == "solution_hint":
human_hint_label = "Amazing!!! How do you think we can solve this bug?"
while True:
human_hint = await self.ask_question(human_hint_label)
convo = convo.template("instructions_from_human_hint", human_hint=human_hint.text)
await self.ui.start_important_stream()
llm = self.get_llm(CHECK_LOGS_AGENT_NAME)
human_readable_instructions = await llm(convo, temperature=0.5)
human_approval = await self.ask_question(
Expand All @@ -270,6 +275,7 @@ async def start_pair_programming(self):
break
elif next_step.button == "tell_me_more":
convo.template("tell_me_more")
await self.ui.start_important_stream()
response = await llm(convo, temperature=0.5)
await self.send_message(response)
continue
Expand Down
7 changes: 7 additions & 0 deletions core/ui/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ async def send_project_root(self, path: str):
"""
raise NotImplementedError()

async def start_important_stream(self, path: str):
"""
Tell the extension that next stream should be visible and rendered as markdown
"""
raise NotImplementedError()

async def send_project_stats(self, stats: dict):
"""
Send project statistics to the UI.
Expand Down
3 changes: 3 additions & 0 deletions core/ui/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,8 @@ async def send_features_list(self, features: list[str]):
async def import_project(self, project_dir: str):
pass

async def start_important_stream(self):
pass


__all__ = ["PlainConsoleUI"]
7 changes: 7 additions & 0 deletions core/ui/ipc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class MessageType(str, Enum):
FEATURE_FINISHED = "featureFinished"
GENERATE_DIFF = "generateDiff"
CLOSE_DIFF = "closeDiff"
IMPORTANT_STREAM = "importantStream"


class Message(BaseModel):
Expand Down Expand Up @@ -362,6 +363,12 @@ async def send_project_root(self, path: str):
content=basename(path),
)

async def start_important_stream(self):
await self._send(
MessageType.IMPORTANT_STREAM,
content={},
)

async def send_project_stats(self, stats: dict):
await self._send(
MessageType.PROJECT_STATS,
Expand Down
3 changes: 3 additions & 0 deletions core/ui/virtual.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ async def open_editor(self, file: str, line: Optional[int] = None):
async def send_project_root(self, path: str):
pass

async def start_important_stream(self):
pass

async def send_project_stats(self, stats: dict):
pass

Expand Down

0 comments on commit 0fab947

Please sign in to comment.