mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 13:23:15 +00:00
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:
@@ -140,8 +140,8 @@ def gemini_send_message_to_model(
|
|||||||
"""
|
"""
|
||||||
model_kwargs = {}
|
model_kwargs = {}
|
||||||
|
|
||||||
# This caused unwanted behavior and terminates response early for gemini 1.5 series. Monitor for flakiness with 2.0 series.
|
# 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 model in ["gemini-2.0-flash"]:
|
if response_type == "json_object" and not model.startswith("gemini-1.5"):
|
||||||
model_kwargs["response_mime_type"] = "application/json"
|
model_kwargs["response_mime_type"] = "application/json"
|
||||||
if response_schema:
|
if response_schema:
|
||||||
model_kwargs["response_schema"] = response_schema
|
model_kwargs["response_schema"] = response_schema
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ def gemini_completion_with_backoff(
|
|||||||
|
|
||||||
# format model response schema
|
# format model response schema
|
||||||
response_schema = None
|
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"])
|
response_schema = clean_response_schema(model_kwargs["response_schema"])
|
||||||
|
|
||||||
seed = int(os.getenv("KHOJ_LLM_SEED")) if os.getenv("KHOJ_LLM_SEED") else None
|
seed = int(os.getenv("KHOJ_LLM_SEED")) if os.getenv("KHOJ_LLM_SEED") else None
|
||||||
|
|||||||
Reference in New Issue
Block a user