Skip to content

Commit 54f879a

Browse files
committed
chore(chatops-lark): add debug logs for MCP and LLM client initialization
1 parent dfc2881 commit 54f879a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

chatops-lark/pkg/events/handler/ask.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ func processAskRequest(ctx context.Context, question string) (string, error) {
142142
}
143143

144144
func setupAskCtx(ctx context.Context, config map[string]any, _ *CommandSender) context.Context {
145-
log.Info().Msg("debug")
146145
// Initialize LLM client
147146
var client openai.Client
148147
{
148+
log.Debug().Msg("initializing LLM client")
149149
llmCfg := config[cfgKeyAskLlmCfg]
150150
switch v := llmCfg.(type) {
151151
case map[string]any:
@@ -159,25 +159,28 @@ func setupAskCtx(ctx context.Context, config map[string]any, _ *CommandSender) c
159159
default:
160160
client = openai.NewClient()
161161
}
162+
163+
log.Debug().Msg("initialized LLM client")
162164
}
163165

164166
// Initialize LLM tools
165167
var mcpClients []mcpclient.MCPClient
166168
var toolDeclarations []openai.ChatCompletionToolParam
167169
{
168170
mcpCfg := config[cfgKeyAskLlmMcpServers]
169-
log.Info().Any("mcpCfg", mcpCfg).Msg("start to initialize MCP client")
170171
switch v := mcpCfg.(type) {
171172
case map[string]any:
172173
for name, cfg := range v {
173174
url := cfg.(map[string]any)["base_url"].(string)
175+
log.Debug().Str("name", name).Str("url", url).Msg("initializing MCP SSE client")
174176
client, declarations, err := initializeMCPClient(ctx, name, url)
175177
if err != nil {
176178
log.Err(err).Str("name", name).Str("url", url).Msg("failed to initialize MCP SSE client")
177179
continue
178180
}
179181
mcpClients = append(mcpClients, client)
180182
toolDeclarations = append(toolDeclarations, declarations...)
183+
log.Debug().Str("name", name).Str("url", url).Msg("initialized MCP SSE client")
181184
}
182185
}
183186
}

chatops-lark/pkg/events/handler/ask_mcp.go

-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ func callMcpTool(ctx context.Context, client client.MCPClient, name string, args
102102
func initializeMCPClient(ctx context.Context, name, url string) (client.MCPClient, []openai.ChatCompletionToolParam, error) {
103103
// Create a logger with the provided name and URL
104104
logger := log.With().Str("name", name).Str("url", url).Logger()
105-
logger.Debug().Msg("start to initialize MCP client")
106105

107106
// Create a new SSE MCP client
108107
c, err := newSSEMcpClient(ctx, url)
@@ -149,7 +148,6 @@ func initializeMCPClient(ctx context.Context, name, url string) (client.MCPClien
149148
llmToolDeclaration = append(llmToolDeclaration, toolParam)
150149
}
151150

152-
logger.Debug().Msg("done initializing MCP client")
153151
return c, llmToolDeclaration, nil
154152
}
155153

0 commit comments

Comments
 (0)