feat(logger): implement LLM debug logging functionality
- Added a new logger for LLM calls, enabling detailed logging of model interactions, including request and response data. - Introduced configuration options for enabling and specifying the log directory for LLM debug logs. - Implemented cleanup for old log files to manage disk space effectively. - Wrapped existing chat implementations to log calls when debug logging is enabled, enhancing traceability for model interactions.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/models/provider"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
)
|
||||
@@ -91,6 +92,14 @@ type RerankerConfig struct {
|
||||
|
||||
// NewReranker creates a reranker based on the configuration
|
||||
func NewReranker(config *RerankerConfig) (Reranker, error) {
|
||||
r, err := newReranker(config)
|
||||
if err != nil || !logger.LLMDebugEnabled() {
|
||||
return r, err
|
||||
}
|
||||
return &debugReranker{inner: r}, nil
|
||||
}
|
||||
|
||||
func newReranker(config *RerankerConfig) (Reranker, error) {
|
||||
// Use provider field if set, otherwise detect from URL using provider registry
|
||||
providerName := provider.ProviderName(config.Provider)
|
||||
if providerName == "" {
|
||||
|
||||
Reference in New Issue
Block a user