feat: 支持CozeV3

This commit is contained in:
suziheng
2025-01-22 16:43:40 +08:00
parent 6eb4e788c7
commit 533f9853ac
13 changed files with 359 additions and 15 deletions

View File

@@ -1,6 +1,9 @@
package coze
import "github.com/songquanpeng/one-api/relay/adaptor/coze/constant/event"
import (
"github.com/songquanpeng/one-api/relay/adaptor/coze/constant/event"
"strings"
)
func event2StopReason(e *string) string {
if e == nil || *e == event.Message {
@@ -8,3 +11,16 @@ func event2StopReason(e *string) string {
}
return "stop"
}
func splitOnDoubleNewline(data []byte, atEOF bool) (advance int, token []byte, err error) {
if atEOF && len(data) == 0 {
return 0, nil, nil
}
if i := strings.Index(string(data), "\n\n"); i >= 0 {
return i + 1, data[0:i], nil
}
if atEOF {
return len(data), data, nil
}
return 0, nil, nil
}