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:
@@ -107,14 +107,17 @@ type ChatConfig struct {
|
||||
|
||||
// NewChat 创建聊天实例
|
||||
func NewChat(config *ChatConfig, ollamaService *ollama.OllamaService) (Chat, error) {
|
||||
var c Chat
|
||||
var err error
|
||||
switch strings.ToLower(string(config.Source)) {
|
||||
case string(types.ModelSourceLocal):
|
||||
return NewOllamaChat(config, ollamaService)
|
||||
c, err = NewOllamaChat(config, ollamaService)
|
||||
case string(types.ModelSourceRemote):
|
||||
return NewRemoteChat(config)
|
||||
c, err = NewRemoteChat(config)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported chat model source: %s", config.Source)
|
||||
}
|
||||
return wrapChatDebug(c, err)
|
||||
}
|
||||
|
||||
// NewRemoteChat 根据 provider 创建远程聊天实例
|
||||
|
||||
Reference in New Issue
Block a user