Skip to content

Commit

Permalink
add trace events for project creation and specification
Browse files Browse the repository at this point in the history
  • Loading branch information
senko committed Jun 11, 2024
1 parent 515ccee commit a4b920d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/agents/spec_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ async def run(self) -> AgentResponse:
spec = response.text

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

if len(spec) < ANALYZE_THRESHOLD and complexity != Complexity.SIMPLE:
spec = await self.analyze_spec(spec)
spec = await self.review_spec(spec)
Expand Down Expand Up @@ -111,6 +119,8 @@ async def analyze_spec(self, spec: str) -> str:

llm = self.get_llm()
convo = AgentConvo(self).template("ask_questions").user(spec)
n_questions = 0
n_answers = 0

while True:
response: str = await llm(convo)
Expand All @@ -125,12 +135,21 @@ async def analyze_spec(self, spec: str) -> str:
buttons={"continue": "continue"},
)
if confirm.cancelled or confirm.button == "continue" or confirm.text == "":
await self.telemetry.trace_code_event(
"spec-writer-questions",
{
"num_questions": n_questions,
"num_answers": n_answers,
"new_spec": spec,
},
)
return spec
convo.user(confirm.text)

else:
convo.assistant(response)

n_questions += 1
user_response = await self.ask_question(
response,
buttons={"skip": "Skip questions"},
Expand All @@ -143,6 +162,7 @@ async def analyze_spec(self, spec: str) -> str:
response: str = await llm(convo)
return response

n_answers += 1
convo.user(user_response.text)

async def review_spec(self, spec: str) -> str:
Expand Down
1 change: 1 addition & 0 deletions core/state/state_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ async def create_project(self, name: str, folder_name: Optional[str] = None) ->
f'with default branch "{branch.name}" (id={branch.id}) '
f"and initial state id={state.id} (step_index={state.step_index})"
)
await telemetry.trace_code_event("create-project", {"name": name})

self.current_session = session
self.current_state = state
Expand Down

0 comments on commit a4b920d

Please sign in to comment.