Skip to content

Commit

Permalink
don't reset newline/space add on each loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Kennedy committed Mar 24, 2024
1 parent dc98878 commit c051087
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/openai_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ pub async fn stream_completion(
// Spawn a new task for each chunk to process it asynchronously
let worker = tokio::spawn(async move {
let mut first_run = true;
let mut add_newline = false;
let mut add_space = false;
while let Some(chunk) = rx.recv().await {
loop_count += 1;

Expand Down Expand Up @@ -259,8 +261,6 @@ pub async fn stream_completion(
let json_blobs: Vec<&str> = chunk_str.split("\ndata: ").collect();
let mut blob_count = 0;

let mut add_newline = false;
let mut add_space = false;
for json_blob in json_blobs.iter() {
blob_count += 1;
debug!("Json Blob: {}/{} - {}", loop_count, blob_count, json_blob);
Expand Down

0 comments on commit c051087

Please sign in to comment.