Skip to content

Commit 1dfe2a0

Browse files
author
sagitchu
committed
fix: add gem logs
1 parent 56552c5 commit 1dfe2a0

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

app/server/chat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,11 @@ async def create_chat_completion(
699699
detail="At least one message is required in the conversation.",
700700
)
701701

702+
logger.info(f"[DEBUG_GEM] Received request.model: {request.model}")
703+
702704
gem_id, gem, public_model, actual_model = _resolve_gem_from_model_or_400(request.model)
705+
logger.info(f"[DEBUG_GEM] Resolved: gem_id={gem_id}, actual_model={actual_model}")
706+
703707
if gem:
704708
_apply_gem_overrides(request, gem)
705709
if gem.system_prompt:
@@ -755,6 +759,7 @@ async def create_chat_completion(
755759
# Start a new session and concat messages into a single string
756760
try:
757761
client = await pool.acquire()
762+
logger.info(f"[DEBUG_GEM] Initializing new chat session with model={model}")
758763
session = client.start_chat(model=model)
759764
messages_to_send = _prepare_messages_for_model(
760765
request.messages, request.tools, request.tool_choice, extra_instructions

app/services/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ def __init__(self, client_id: str, **kwargs):
4545
super().__init__(**kwargs)
4646
self.id = client_id
4747

48+
def start_chat(self, **kwargs) -> Any:
49+
model = kwargs.get("model")
50+
logger.info(f"[DEBUG_GEM] GeminiClientWrapper.start_chat intercepted. model={model}, kwargs={kwargs}")
51+
return super().start_chat(**kwargs)
52+
4853
async def init(
4954
self,
5055
timeout: float = cast(float, _UNSET),
@@ -86,6 +91,7 @@ async def process_message(
8691
"""
8792
Process a single message and return model input.
8893
"""
94+
logger.debug(f"[DEBUG_GEM] Processing message: role={message.role}, content_type={type(message.content)}")
8995
files: list[Path | str] = []
9096
text_fragments: list[str] = []
9197

0 commit comments

Comments
 (0)