debug: log raw upstream events
This commit is contained in:
parent
42118d803e
commit
8e282db13a
1 changed files with 6 additions and 0 deletions
|
|
@ -140,6 +140,7 @@ func handleChatCompletions(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
|
log.Printf("[stream] raw: %q", line)
|
||||||
if !strings.HasPrefix(line, "data: ") {
|
if !strings.HasPrefix(line, "data: ") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -152,8 +153,10 @@ func handleChatCompletions(w http.ResponseWriter, r *http.Request) {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal([]byte(dataStr), &event); err != nil {
|
if err := json.Unmarshal([]byte(dataStr), &event); err != nil {
|
||||||
|
log.Printf("[stream] JSON err: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
log.Printf("[stream] type=%s", event.Type)
|
||||||
|
|
||||||
openAIData := processAnthropicEvent(dataStr, chunkID, req.Model, created)
|
openAIData := processAnthropicEvent(dataStr, chunkID, req.Model, created)
|
||||||
if openAIData != "" {
|
if openAIData != "" {
|
||||||
|
|
@ -176,6 +179,7 @@ func handleChatCompletions(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
|
log.Printf("[accumulate] raw: %q", line)
|
||||||
if !strings.HasPrefix(line, "data: ") {
|
if !strings.HasPrefix(line, "data: ") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -188,8 +192,10 @@ func handleChatCompletions(w http.ResponseWriter, r *http.Request) {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal([]byte(dataStr), &event); err != nil {
|
if err := json.Unmarshal([]byte(dataStr), &event); err != nil {
|
||||||
|
log.Printf("[accumulate] JSON err: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
log.Printf("[accumulate] type=%s data=%.200s", event.Type, dataStr)
|
||||||
|
|
||||||
switch event.Type {
|
switch event.Type {
|
||||||
case "message_start":
|
case "message_start":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue