Skip to content

Commit fab9ef8

Browse files
committed
✨ Add debug logging for LangChain chain input/output
Improves observability by adding debug logging for chain input and output in the commit command. Also reorganizes imports following Python best practices by grouping standard library, third-party, and local imports.
1 parent ed4f33f commit fab9ef8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

aicodebot/commands/commit.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1+
import os
2+
import shutil
3+
import subprocess
4+
import sys
5+
import tempfile
6+
from pathlib import Path
7+
8+
import click
9+
from pydantic import BaseModel, Field
10+
from rich.panel import Panel
11+
112
from aicodebot.coder import Coder
213
from aicodebot.helpers import exec_and_get_output, logger
314
from aicodebot.lm import LanguageModelManager
415
from aicodebot.output import OurMarkdown, get_console
516
from aicodebot.prompts import get_prompt
6-
from pathlib import Path
7-
from pydantic import BaseModel, Field
8-
from rich.panel import Panel
9-
import click, os, shutil, subprocess, sys, tempfile
1017

1118

1219
class CommitMessage(BaseModel):
@@ -97,7 +104,9 @@ def commit(response_token_size, yes, skip_pre_commit, files): # noqa: PLR0915
97104
llm = lmm.model_factory(response_token_size=response_token_size)
98105
# Using Langchain Expression Language (LCEL) for structured output. So chic! 😉
99106
chain = prompt | llm.with_structured_output(CommitMessage)
107+
logger.debug(f"Chain input: {{'diff_context': {diff_context}, 'languages': {languages}}}")
100108
response = chain.invoke({"diff_context": diff_context, "languages": languages})
109+
logger.debug(f"Chain response: {response}")
101110

102111
# Handle both object and dict responses,
103112
# The structured output sometimes returns a dict and sometimes returns an object?!

0 commit comments

Comments
 (0)