Added initial add feature functionality

pull/1058/head
matija-ilijas 2 years ago
parent 56624d70f3
commit 376ed5fdaf

@ -182,7 +182,8 @@ class Orchestrator(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

@ -45,6 +45,9 @@ 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
@ -144,3 +147,7 @@ class AgentResponse:
@staticmethod
def external_docs_required(agent: "BaseAgent") -> "AgentResponse":
return AgentResponse(type=ResponseType.EXTERNAL_DOCS_REQUIRED, agent=agent)
@staticmethod
def new_feature_requested(agent: "BaseAgent") -> "AgentResponse":
return AgentResponse(type=ResponseType.NEW_FEATURE_REQUESTED, agent=agent)

@ -1,6 +1,6 @@
from core.agents.base import BaseAgent
from core.agents.convo import AgentConvo
from core.agents.response import AgentResponse
from core.agents.response import AgentResponse, ResponseType
from core.db.models import Complexity
from core.llm.parser import StringParser
from core.log import get_logger
@ -26,6 +26,12 @@ 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:
return await self.update_spec()
else:
return await self.initialize_spec()
async def initialize_spec(self) -> AgentResponse:
response = await self.ask_question(
"Describe your app in as much detail as possible",
allow_empty=False,
@ -72,6 +78,39 @@ class SpecWriter(BaseAgent):
telemetry.set("initial_prompt", spec)
telemetry.set("is_complex_app", complexity != Complexity.SIMPLE)
self.next_state.action = SPEC_STEP_NAME
return AgentResponse.new_feature_requested(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()
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)
llm_response: str = await llm(convo, temperature=0, parser=StringParser())
updated_spec = llm_response.strip()
self.next_state.specification = self.current_state.specification.clone()
self.next_state.specification.description = updated_spec
telemetry.set(
"initial_prompt", updated_spec
) # TODO Check if a separate telemetry variable needed for updated spec
self.next_state.action = SPEC_STEP_NAME
return AgentResponse.done(self)

@ -0,0 +1,21 @@
Your team has taken the client brief and turned it into a project specification.
Afterwards the client added a description for a new feature to be added to the project specification.
Your job is to update the project specification so that it contains the new feature information but does not lack any of the information from the original project specification.
This might include:
* details on how the app should work
* information which 3rd party packages or APIs to use or avoid
* concrete examples of API requests/responses, library usage, or other external documentation
Here is the client brief:
---PROJECT-SPECIFICATION-START---
{{ state.specification.description }}
---PROJECT-SPECIFICATION-END---
Here is the specification your team came up with:
---FEATURE-DESCRIPTION-START---
{{ feature_description }}
---FEATURE-DESCRIPTION-END---
In your response, output the new updated project specification.
If there is no feature description, just output the original project specification.
Loading…
Cancel
Save