Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Added in some source comments
Browse files Browse the repository at this point in the history
  • Loading branch information
multipletwigs committed May 10, 2024
1 parent dd98b63 commit 79a764c
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export class GPTAdapter extends BaseAdapter implements StreamableAdapter {
}),
});

// This section of the code is taken from...
/// https://github.com/openai/openai-node/issues/18
const reader = res.body?.getReader();
while (true && reader) {
const { done, value } = await reader.read();
Expand All @@ -110,6 +112,8 @@ export class GPTAdapter extends BaseAdapter implements StreamableAdapter {

for await (const message of linesToMessages) {
const messageObject: any = JSON.parse(message);

// MessageObject is the response from the OpenAI API streams
const messageToYield = messageObject.choices[0].delta.content;
if (messageToYield) yield messageToYield;
}
Expand Down

0 comments on commit 79a764c

Please sign in to comment.