Skip to content

Commit

Permalink
Merge pull request #2773 from davidbrai/fix-edit-command-llm-log
Browse files Browse the repository at this point in the history
fix: log llm completition in edit command
  • Loading branch information
sestinj authored Nov 1, 2024
2 parents 2c44b50 + 3094180 commit fc39a60
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions core/llm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,15 +501,20 @@ export abstract class BaseLLM implements ILLM {
}

let completion = "";
for await (const chunk of this._streamComplete(prompt, completionOptions)) {
completion += chunk;
yield chunk;
}

this._logTokensGenerated(completionOptions.model, prompt, completion);
try {
for await (const chunk of this._streamComplete(
prompt,
completionOptions,
)) {
completion += chunk;
yield chunk;
}
} finally {
this._logTokensGenerated(completionOptions.model, prompt, completion);

if (log && this.writeLog) {
await this.writeLog(`Completion:\n\n${completion}\n\n`);
if (log && this.writeLog) {
await this.writeLog(`Completion:\n\n${completion}\n\n`);
}
}

return {
Expand Down

0 comments on commit fc39a60

Please sign in to comment.