Fix handling unset response_schema being passed to gemini models

Use of `is_none_or_empty' doesn't work well with classes, which
response_schema can get set to.
This commit is contained in:
Debanjum
2025-04-10 19:44:34 +05:30
parent 5b248e8515
commit 1eb092010c
2 changed files with 3 additions and 3 deletions

View File

@@ -140,8 +140,8 @@ def gemini_send_message_to_model(
"""
model_kwargs = {}
# This caused unwanted behavior and terminates response early for gemini 1.5 series. Monitor for flakiness with 2.0 series.
if response_type == "json_object" and model in ["gemini-2.0-flash"]:
# Monitor for flakiness in 1.5+ models. This would cause unwanted behavior and terminate response early in 1.5 models.
if response_type == "json_object" and not model.startswith("gemini-1.5"):
model_kwargs["response_mime_type"] = "application/json"
if response_schema:
model_kwargs["response_schema"] = response_schema

View File

@@ -89,7 +89,7 @@ def gemini_completion_with_backoff(
# format model response schema
response_schema = None
if model_kwargs and not is_none_or_empty(model_kwargs.get("response_schema")):
if model_kwargs and model_kwargs.get("response_schema"):
response_schema = clean_response_schema(model_kwargs["response_schema"])
seed = int(os.getenv("KHOJ_LLM_SEED")) if os.getenv("KHOJ_LLM_SEED") else None