Skip to content

Commit

Permalink
Edit comment & logs
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Dec 3, 2024
1 parent d3ae541 commit 04fa9a2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backend/api/src/on-create-comment-on-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,12 @@ Only return the JSON, nothing else.`

try {
const response = await promptClaude(prompt)
log('Clarification response:', response)
log('Clarification response:', {
question: contract.question,
contractId: contract.id,
slug: contract.slug,
response,
})
const clarification = JSON.parse(response) as ClarificationResponse

if (clarification.isClarification && clarification.description) {
Expand All @@ -240,6 +245,7 @@ Only return the JSON, nothing else.`
const appendDescription = anythingToRichText({
markdown: markdownToAppend,
})
// Create deep copy of the old description to update history correctly
const oldDescription = cloneDeep(contract.description)
let newDescription: JSONContent | undefined

Expand All @@ -248,7 +254,6 @@ Only return the JSON, nothing else.`
markdown: `${oldDescription}${appendDescription}`,
})
} else {
// Create deep copy of the old description to update history correctly
oldDescription.content?.push(...(appendDescription?.content ?? []))
newDescription = oldDescription
}
Expand All @@ -269,6 +274,7 @@ Only return the JSON, nothing else.`
)
track(editorID, 'ai clarification added', {
contractId: contract.id,
slug: contract.slug,
question: contract.question,
})
}
Expand Down

0 comments on commit 04fa9a2

Please sign in to comment.