Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion dspy/adapters/chat_adapter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
import textwrap
from typing import Any, NamedTuple

import logging
from litellm import ContextWindowExceededError
from pydantic.fields import FieldInfo

Expand Down Expand Up @@ -64,6 +64,11 @@ async def acall(
# On context window exceeded error or already using JSONAdapter, we don't want to retry with a different
# adapter.
raise e
logger = logging.getLogger(__name__)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's defind the logger on the module level

logger.warning(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simply use e without custom formatting

f"Structured output failed with error: {type(e).__name__}: {str(e)[:200]}. "
f"Falling back to JSON mode."
Copy link
Collaborator

@TomeHirata TomeHirata Oct 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call it as JSONAdapter to clarify

)
return await JSONAdapter().acall(lm, lm_kwargs, signature, demos, inputs)

def format_field_description(self, signature: type[Signature]) -> str:
Expand Down