Skip to content

Commit

Permalink
refactor: reuse createTextEvent() in createAckEvent() (#109)
Browse files Browse the repository at this point in the history
### What are you trying to accomplish?

A refactoring opportunity: after reading `createAckEvent()` and
`createTextEvent`'s definitions, I noticed that the only difference was
that the former passes in an empty string for its content.

### What approach did you choose and why?

I chose to update the body to use `createTextEvent()` directly, passing
an empty string for its `message` argument. Ran tests locally and in CI
to verify this works 👍

### What should reviewers focus on?

Nothing I haven't mentioned 😉
  • Loading branch information
francisfuzz authored Sep 23, 2024
1 parent ecf55b9 commit ab12443
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@

/** @type {import('..').CreateAckEventInterface} */
export function createAckEvent() {
const data = {
choices: [
{
index: 0,
delta: { content: ``, role: "assistant" },
},
],
};
return `data: ${JSON.stringify(data)}\n\n`;
return createTextEvent("");
}

/** @type {import('..').CreateTextEventInterface} */
Expand Down

0 comments on commit ab12443

Please sign in to comment.