优化chatgpt检查
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"io"
|
||||
stdhttp "net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -879,6 +880,9 @@ func (c *Client) getConversation(ctx context.Context, session tlsclient.HttpClie
|
||||
if err := ensureOK(resp.StatusCode, body, "conversation_get"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if dir := os.Getenv("CHATGPT_DEBUG_DUMP"); dir != "" {
|
||||
_ = os.WriteFile(filepath.Join(dir, fmt.Sprintf("conv-%s-%d.json", conversationID, time.Now().UnixMilli())), body, 0o644)
|
||||
}
|
||||
var payload map[string]any
|
||||
if err := json.Unmarshal(body, &payload); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -157,8 +157,12 @@ func conversationEndedWithoutImage(conversation map[string]any) bool {
|
||||
}
|
||||
if role == "assistant" {
|
||||
if content, _ := message["content"].(map[string]any); content != nil {
|
||||
if ct := stringValue(content["content_type"]); ct != "" && ct != "text" {
|
||||
return false // code/multimodal turn — generation underway
|
||||
// Only tool-invoking content types mean generation is underway.
|
||||
// Context nodes (model_editable_context, thoughts, …) also appear
|
||||
// on refused turns and must NOT suppress the detection.
|
||||
switch stringValue(content["content_type"]) {
|
||||
case "code", "multimodal_text":
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user