Skip to content

Commit

Permalink
Merge pull request #1072 from Pythagora-io/spec-writer-fix
Browse files Browse the repository at this point in the history
Fixed wrong original description initialization
  • Loading branch information
LeonOstrez authored Jul 30, 2024
2 parents 4259df9 + 5595016 commit 933cac7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions core/agents/spec_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,27 @@ async def initialize_spec(self) -> AgentResponse:
# nothing but repeat the question. We reproduce this bug for bug here.
return AgentResponse.done(self)

spec = response.text.strip()
user_description = response.text.strip()

complexity = await self.check_prompt_complexity(spec)
complexity = await self.check_prompt_complexity(user_description)
await telemetry.trace_code_event(
"project-description",
{
"initial_prompt": spec,
"initial_prompt": user_description,
"complexity": complexity,
},
)

if len(spec) < ANALYZE_THRESHOLD and complexity != Complexity.SIMPLE:
spec = await self.analyze_spec(spec)
spec = await self.review_spec(spec)
if len(user_description) < ANALYZE_THRESHOLD and complexity != Complexity.SIMPLE:
initial_spec = await self.analyze_spec(user_description)
reviewed_spec = await self.review_spec(desc=user_description, spec=initial_spec)

self.next_state.specification = self.current_state.specification.clone()
self.next_state.specification.original_description = spec
self.next_state.specification.description = spec
self.next_state.specification.original_description = user_description
self.next_state.specification.description = reviewed_spec
self.next_state.specification.complexity = complexity
telemetry.set("initial_prompt", spec)
telemetry.set("initial_prompt", user_description)
telemetry.set("updated_prompt", reviewed_spec)
telemetry.set("is_complex_app", complexity != Complexity.SIMPLE)

self.next_state.action = SPEC_STEP_NAME
Expand Down Expand Up @@ -203,11 +204,11 @@ async def analyze_spec(self, spec: str) -> str:
n_answers += 1
convo.user(user_response.text)

async def review_spec(self, spec: str) -> str:
convo = AgentConvo(self).template("review_spec", spec=spec)
async def review_spec(self, desc: str, spec: str) -> str:
convo = AgentConvo(self).template("review_spec", desc=desc, spec=spec)
llm = self.get_llm(SPEC_WRITER_AGENT_NAME)
llm_response: str = await llm(convo, temperature=0)
additional_info = llm_response.strip()
if additional_info and len(additional_info) > 6:
spec += "\nAdditional info/examples:\n" + additional_info
spec += "\n\nAdditional info/examples:\n\n" + additional_info
return spec
2 changes: 1 addition & 1 deletion core/prompts/spec-writer/review_spec.prompt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This might include:

Here is the client brief:
---CLIENT-BRIEF-START---
{{ state.specification.description }}
{{ desc }}
---CLIENT-BRIEF-END---

Here is the specification your team came up with:
Expand Down

0 comments on commit 933cac7

Please sign in to comment.