diff --git a/internal/adapter/openai/file_refs.go b/internal/adapter/openai/file_refs.go index 6f31ee6..adf49e1 100644 --- a/internal/adapter/openai/file_refs.go +++ b/internal/adapter/openai/file_refs.go @@ -52,8 +52,18 @@ func appendOpenAIRefFileIDs(out *[]string, seen map[string]struct{}, raw any) { addOpenAIRefFileID(out, seen, fileID) } } + // Recurse into potential containers. Note: we do NOT recurse into 'content' or 'input' + // if they are plain strings (handled by the top-level switch), but they are usually + // nested inside the map branch anyway. + // To be safe, we only recurse into these known container keys. for _, key := range []string{"ref_file_ids", "file_ids", "attachments", "messages", "input", "content", "files", "items", "data", "source"} { if nested, ok := x[key]; ok { + // If it's a message content that is a string, we must NOT treat it as an ID. + if key == "content" || key == "input" { + if _, ok := nested.(string); ok { + continue + } + } appendOpenAIRefFileIDs(out, seen, nested) } } diff --git a/internal/deepseek/client_completion.go b/internal/deepseek/client_completion.go index cab2cab..c27a88f 100644 --- a/internal/deepseek/client_completion.go +++ b/internal/deepseek/client_completion.go @@ -51,6 +51,7 @@ func (c *Client) streamPost(ctx context.Context, doer trans.Doer, url string, he if err != nil { return nil, err } + headers = c.jsonHeaders(headers) clients := c.requestClientsFromContext(ctx) req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(b)) if err != nil { diff --git a/internal/deepseek/constants.go b/internal/deepseek/constants.go index 961c3cf..577725f 100644 --- a/internal/deepseek/constants.go +++ b/internal/deepseek/constants.go @@ -25,6 +25,7 @@ var defaultBaseHeaders = map[string]string{ "Host": "chat.deepseek.com", "User-Agent": "DeepSeek/1.8.0 Android/35", "Accept": "application/json", + "Content-Type": "application/json", "x-client-platform": "android", "x-client-version": "1.8.0", "x-client-locale": "zh_CN",