refactor: remove unused purpose parameter from upload and upstream empty output handlers

This commit is contained in:
CJACK committed 2026-04-13 01:59:51 +08:00
1 parent daa636e040
commit d53a2ea7d2
5 files changed
+6 -6

No files matched your search

+1 -1
View File
@@ -131,7 +131,7 @@ func (h *Handler) handleNonStream(w http.ResponseWriter, ctx context.Context, re
stripReferenceMarkers := h.compatStripReferenceMarkers()
finalThinking := cleanVisibleOutput(result.Thinking, stripReferenceMarkers)
finalText := cleanVisibleOutput(result.Text, stripReferenceMarkers)
if writeUpstreamEmptyOutputError(w, finalThinking, finalText, result.ContentFilter) {
if writeUpstreamEmptyOutputError(w, finalText, result.ContentFilter) {
return
}
respBody := openaifmt.BuildChatCompletion(completionID, model, finalPrompt, finalThinking, finalText, toolNames)
+1 -1
View File
@@ -121,7 +121,7 @@ func (h *Handler) handleResponsesNonStream(w http.ResponseWriter, resp *http.Res
stripReferenceMarkers := h.compatStripReferenceMarkers()
sanitizedThinking := cleanVisibleOutput(result.Thinking, stripReferenceMarkers)
sanitizedText := cleanVisibleOutput(result.Text, stripReferenceMarkers)
if writeUpstreamEmptyOutputError(w, sanitizedThinking, sanitizedText, result.ContentFilter) {
if writeUpstreamEmptyOutputError(w, sanitizedText, result.ContentFilter) {
return
}
textParsed := toolcall.ParseStandaloneToolCallsDetailed(sanitizedText, toolNames)
+1 -1
View File
@@ -2,7 +2,7 @@ package openai
import "net/http"
func writeUpstreamEmptyOutputError(w http.ResponseWriter, thinking, text string, contentFilter bool) bool {
func writeUpstreamEmptyOutputError(w http.ResponseWriter, text string, contentFilter bool) bool {
if text != "" {
return false
}
+2 -2
View File
@@ -51,7 +51,7 @@ func (c *Client) UploadFile(ctx context.Context, a *auth.RequestAuth, req Upload
contentType = "application/octet-stream"
}
purpose := strings.TrimSpace(req.Purpose)
body, contentTypeHeader, err := buildUploadMultipartBody(filename, contentType, purpose, req.Data)
body, contentTypeHeader, err := buildUploadMultipartBody(filename, contentType, req.Data)
if err != nil {
return nil, err
}
@@ -142,7 +142,7 @@ func (c *Client) UploadFile(ctx context.Context, a *auth.RequestAuth, req Upload
return nil, errors.New("upload file failed")
}
func buildUploadMultipartBody(filename, contentType, purpose string, data []byte) ([]byte, string, error) {
func buildUploadMultipartBody(filename, contentType string, data []byte) ([]byte, string, error) {
var buf bytes.Buffer
writer := multipart.NewWriter(&buf)
partHeader := textproto.MIMEHeader{}
+1 -1
View File
@@ -15,7 +15,7 @@ import (
)
func TestBuildUploadMultipartBodyOmitsPurposeAndIncludesFilePart(t *testing.T) {
body, contentType, err := buildUploadMultipartBody(`../demo.txt`, "text/plain", "assistants", []byte("hello"))
body, contentType, err := buildUploadMultipartBody(`../demo.txt`, "text/plain", []byte("hello"))
if err != nil {
t.Fatalf("buildUploadMultipartBody error: %v", err)
}