Only check for docs if the user wants to run the task.

This commit is contained in:
Goran Peretin
2024-07-03 15:29:41 +00:00
parent de8ae619ae
commit 4cc3834a68
3 changed files with 24 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ from core.agents.base import BaseAgent
from core.agents.convo import AgentConvo
from core.agents.response import AgentResponse, ResponseType
from core.db.models.project_state import TaskStatus
from core.db.models.specification import Complexity
from core.llm.parser import JSONParser
from core.log import get_logger
from core.telemetry import telemetry
@@ -77,10 +78,17 @@ class Developer(BaseAgent):
# By default, we want to ask the user if they want to run the task,
# except in certain cases (such as they've just edited it).
if not self.current_state.current_task.get("run_always", False):
# The check for docs is here to prevent us from asking the user whether we should
# run the task twice - we'll only ask if we haven't yet checked for docs.
if not self.current_state.current_task.get("run_always", False) and self.current_state.docs is None:
if not await self.ask_to_execute_task():
return AgentResponse.done(self)
if self.current_state.docs is None and self.current_state.specification.complexity != Complexity.SIMPLE:
# We check for external docs here, to make sure we only fetch the docs
# if the task is actually being done.
return AgentResponse.external_docs_required(self)
return await self.breakdown_current_task()
async def breakdown_current_iteration(self, review_feedback: Optional[str] = None) -> AgentResponse:
@@ -205,6 +213,12 @@ class Developer(BaseAgent):
)
return AgentResponse.done(self)
async def get_external_docs(self):
# TODO: hook into external docs here
# TODO: make sure to add the docs both in current_state (so it can be used right)
# away in the task breakdown, and next_state, so it's stored in the database
pass
async def get_relevant_files(
self, user_feedback: Optional[str] = None, solution_description: Optional[str] = None
) -> AgentResponse:

View File

@@ -19,7 +19,6 @@ from core.agents.tech_lead import TechLead
from core.agents.tech_writer import TechnicalWriter
from core.agents.troubleshooter import Troubleshooter
from core.db.models.project_state import TaskStatus
from core.db.models.specification import Complexity
from core.log import get_logger
from core.telemetry import telemetry
from core.ui.base import ProjectStage
@@ -180,6 +179,8 @@ class Orchestrator(BaseAgent):
return Developer(self.state_manager, self.ui, prev_response=prev_response)
if prev_response.type == ResponseType.IMPORT_PROJECT:
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 not state.specification.description:
if state.files:
@@ -199,9 +200,6 @@ class Orchestrator(BaseAgent):
# Ask the Tech Lead to break down the initial project or feature into tasks and apply project templates
return TechLead(self.state_manager, self.ui, process_manager=self.process_manager)
if state.current_task and state.docs is None and state.specification.complexity != Complexity.SIMPLE:
return ExternalDocumentation(self.state_manager, self.ui)
# Current task status must be checked before Developer is called because we might want
# to skip it instead of breaking it down
current_task_status = state.current_task.get("status") if state.current_task else None

View File

@@ -42,6 +42,9 @@ class ResponseType(str, Enum):
IMPORT_PROJECT = "import-project"
"""User wants to import an existing project."""
EXTERNAL_DOCS_REQUIRED = "external-docs-required"
"""We need to fetch external docs for a task."""
class AgentResponse:
type: ResponseType = ResponseType.DONE
@@ -137,3 +140,7 @@ class AgentResponse:
@staticmethod
def import_project(agent: "BaseAgent") -> "AgentResponse":
return AgentResponse(type=ResponseType.IMPORT_PROJECT, agent=agent)
@staticmethod
def external_docs_required(agent: "BaseAgent") -> "AgentResponse":
return AgentResponse(type=ResponseType.EXTERNAL_DOCS_REQUIRED, agent=agent)