Skip to content

Commit

Permalink
address comments for edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinmvrk committed Nov 8, 2024
1 parent c08602f commit 1ce7211
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/stream/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ func ParseFile(filename string) error {
continue // skip lines without "data: "
}

// Handle special cases
if line == "[DONE]" {
break // stop processing if we encounter [DONE]
}
if line == "" {
continue // skip empty data lines
}

// Parse the JSON line into our `Data` struct
var data Data
err := json.Unmarshal([]byte(line), &data)
Expand Down

0 comments on commit 1ce7211

Please sign in to comment.