fix: stream return EOF when openai return error (#184)
* fix: stream return EOF when openai return error * perf: add error accumulator * fix: golangci-lint * fix: unmarshal error possibly null * fix: error accumulator * test: error accumulator use interface and add test code * test: error accumulator add test code * refactor: use stream reader to re-use stream code * refactor: stream reader use generics
This commit is contained in:
15
unmarshaler.go
Normal file
15
unmarshaler.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package openai
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type unmarshaler interface {
|
||||
unmarshal(data []byte, v any) error
|
||||
}
|
||||
|
||||
type jsonUnmarshaler struct{}
|
||||
|
||||
func (jm *jsonUnmarshaler) unmarshal(data []byte, v any) error {
|
||||
return json.Unmarshal(data, v)
|
||||
}
|
||||
Reference in New Issue
Block a user