-
Couldn't load subscription status.
- Fork 2.4k
fix: skip JSON fallback when web_search tool is present #8963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
||
|
|
@@ -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__) | ||
| logger.warning( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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." | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
|
||
There was a problem hiding this comment.
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