Files
Enterprise-Knowledge-Base/internal/models/rerank/logging.go
T
wizardchen 5fe1ccd4f9 feat: enhance multimodal support and image handling
- Updated configuration to improve handling of multimodal queries, including clearer guidelines for when to use [NO_SEARCH] in responses.
- Enhanced the user interface to include dedicated sections for multimodal configuration, allowing users to manage image uploads and related settings more effectively.
- Added localization support for new multimodal features in both English and Chinese, improving accessibility for a broader audience.
- Implemented backend changes to support image analysis and extraction of OCR text, enriching the interaction experience for users.

These enhancements significantly improve the application's capability to process and respond to multimodal queries, fostering a more interactive and user-friendly environment.
2026-03-16 02:26:47 +08:00

43 lines
995 B
Go

package rerank
import (
"encoding/json"
"fmt"
"strings"
"unicode/utf8"
)
const (
maxLogDocuments = 3
maxLogTextRunes = 120
)
func buildRerankRequestDebug(model, endpoint, query string, documents []string) string {
previews := make([]string, 0, maxLogDocuments)
for i, doc := range documents {
if i >= maxLogDocuments {
break
}
previews = append(previews, compactForLog(doc, maxLogTextRunes))
}
previewJSON, _ := json.Marshal(previews)
return fmt.Sprintf(
"rerank request endpoint=%s model=%s query_preview=%q query_runes=%d documents=%d preview_docs=%s",
endpoint,
model,
compactForLog(query, maxLogTextRunes),
utf8.RuneCountInString(query),
len(documents),
string(previewJSON),
)
}
func compactForLog(text string, maxRunes int) string {
normalized := strings.Join(strings.Fields(strings.TrimSpace(text)), " ")
if utf8.RuneCountInString(normalized) <= maxRunes {
return normalized
}
return string([]rune(normalized)[:maxRunes]) + "...(truncated)"
}