Skip to content

Commit

Permalink
Added new feature request in deep focus pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
matija-ilijas committed Jul 25, 2024
1 parent ab2dc00 commit 82e0c5c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 27 deletions.
5 changes: 3 additions & 2 deletions core/agents/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ def create_agent(self, prev_response: Optional[AgentResponse]) -> BaseAgent:
return Importer(self.state_manager, self.ui, prev_response=prev_response)
if prev_response.type == ResponseType.EXTERNAL_DOCS_REQUIRED:
return ExternalDocumentation(self.state_manager, self.ui, prev_response=prev_response)
if prev_response.type == ResponseType.NEW_FEATURE_REQUESTED:
return SpecWriter(self.state_manager, self.ui, prev_response=prev_response)
if not state.specification.description:
if state.files:
# The project has been imported, but not analyzed yet
Expand Down Expand Up @@ -253,6 +251,9 @@ def create_agent(self, prev_response: Optional[AgentResponse]) -> BaseAgent:
elif current_iteration_status == IterationStatus.PROBLEM_SOLVER:
# Call Problem Solver if the user said "I'm stuck in a loop"
return ProblemSolver(self.state_manager, self.ui)
elif current_iteration_status == IterationStatus.NEW_FEATURE_REQUESTED:
# Call Spec Writer to add the "change" requested by the user to project specification
return SpecWriter(self.state_manager, self.ui)

# We have just finished the task, call Troubleshooter to ask the user to review
return Troubleshooter(self.state_manager, self.ui)
Expand Down
3 changes: 0 additions & 3 deletions core/agents/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ class ResponseType(str, Enum):
EXTERNAL_DOCS_REQUIRED = "external-docs-required"
"""We need to fetch external docs for a task."""

NEW_FEATURE_REQUESTED = "new-feature-requested"
"""User wants to add a new feature to project specification."""


class AgentResponse:
type: ResponseType = ResponseType.DONE
Expand Down
28 changes: 8 additions & 20 deletions core/agents/spec_writer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from core.agents.base import BaseAgent
from core.agents.convo import AgentConvo
from core.agents.response import AgentResponse, ResponseType
from core.agents.response import AgentResponse
from core.db.models.project_state import IterationStatus
from core.db.models import Complexity
from core.llm.parser import StringParser
from core.log import get_logger
Expand All @@ -26,7 +27,8 @@ class SpecWriter(BaseAgent):
display_name = "Spec Writer"

async def run(self) -> AgentResponse:
if self.prev_response and self.prev_response.type == ResponseType.NEW_FEATURE_REQUESTED:
current_iteration = self.current_state.current_iteration
if current_iteration is not None and current_iteration["status"] == IterationStatus.NEW_FEATURE_REQUESTED:
return await self.update_spec()
else:
return await self.initialize_spec()
Expand Down Expand Up @@ -79,25 +81,10 @@ async def initialize_spec(self) -> AgentResponse:
telemetry.set("is_complex_app", complexity != Complexity.SIMPLE)

self.next_state.action = SPEC_STEP_NAME
return AgentResponse.new_feature_requested(self)
return AgentResponse.done(self)

async def update_spec(self) -> AgentResponse:
response = await self.ask_question(
"Describe the new feature you want to add",
allow_empty=False,
buttons={
# FIXME: must be lowercase becase VSCode doesn't recognize it otherwise. Needs a fix in the extension
"cancel": "cancel",
},
)
if response.cancelled:
return AgentResponse.error(self, "No feature description")

if response.button == "cancel":
return AgentResponse.error(self, "No feature description")

feature_description = response.text.strip()

feature_description = self.current_state.current_iteration["description"]
await self.send_message("Adding new feature to project specification ...")
llm = self.get_llm()
convo = AgentConvo(self).template("add_new_feature", feature_description=feature_description)
Expand All @@ -111,7 +98,8 @@ async def update_spec(self) -> AgentResponse:
"initial_prompt", updated_spec
) # TODO Check if a separate telemetry variable needed for updated spec

self.next_state.action = SPEC_STEP_NAME
self.next_state.current_iteration["status"] = IterationStatus.FIND_SOLUTION
self.next_state.flag_iterations_as_modified()
return AgentResponse.done(self)

async def check_prompt_complexity(self, prompt: str) -> str:
Expand Down
4 changes: 2 additions & 2 deletions core/agents/troubleshooter.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async def create_iteration(self) -> AgentResponse:
return await self.complete_task()

user_feedback = bug_report or change_description
user_feedback_qa = await self.generate_bug_report(run_command, user_instructions, user_feedback)
user_feedback_qa = None # await self.generate_bug_report(run_command, user_instructions, user_feedback)

if is_loop:
if last_iteration["alternative_solutions"]:
Expand All @@ -102,7 +102,7 @@ async def create_iteration(self) -> AgentResponse:
else:
# should be - elif change_description is not None: - but to prevent bugs with the extension
# this might be caused if we show the input field instead of buttons
iteration_status = IterationStatus.FIND_SOLUTION
iteration_status = IterationStatus.NEW_FEATURE_REQUESTED

self.next_state.iterations = self.current_state.iterations + [
{
Expand Down
1 change: 1 addition & 0 deletions core/db/models/project_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class IterationStatus:
IMPLEMENT_SOLUTION = "implement_solution"
FIND_SOLUTION = "find_solution"
PROBLEM_SOLVER = "problem_solver"
NEW_FEATURE_REQUESTED = "new_feature_requested"
DONE = "done"


Expand Down

0 comments on commit 82e0c5c

Please sign in to comment.