Skip to content

Commit c4a83ff

Browse files
jxnlclaude
andcommitted
fix(tests): fix Gemini mode and GenAI decimal validators
1. test_gemini/test_multimodal_content.py: Changed GENAI_JSON (non-existent) to GENAI_TOOLS (correct mode for google-genai provider) 2. test_genai/test_decimal.py: Updated decimal validators to handle float/int inputs in addition to strings, since GenAI returns numeric values as floats These fixes resolve AttributeError and flaky decimal validation issues. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5163860 commit c4a83ff

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

tests/llm/test_gemini/test_multimodal_content.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Description(BaseModel):
1414

1515
def test_audio_compatability_list():
1616
client = instructor.from_provider(
17-
model="google/gemini-2.5-flash", mode=instructor.Mode.GENAI_JSON
17+
model="google/gemini-2.5-flash", mode=instructor.Mode.GENAI_TOOLS
1818
)
1919

2020
# For now, we'll skip file operations since the new API might handle them differently
@@ -35,7 +35,7 @@ def test_audio_compatability_list():
3535

3636
def test_audio_compatability_multiple_messages():
3737
client = instructor.from_provider(
38-
model="google/gemini-2.5-flash", mode=instructor.Mode.GENAI_JSON
38+
model="google/gemini-2.5-flash", mode=instructor.Mode.GENAI_TOOLS
3939
)
4040

4141
# For now, we'll skip file operations since the new API might handle them differently

tests/llm/test_genai/test_decimal.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class Receipt(BaseModel):
1414
@field_validator("price", "total", mode="before")
1515
@classmethod
1616
def parse_decimals(cls, v):
17-
if isinstance(v, str):
18-
return Decimal(v)
17+
if isinstance(v, (str, float, int)):
18+
return Decimal(str(v))
1919
return v
2020

2121

@@ -26,8 +26,8 @@ class Invoice(BaseModel):
2626
@field_validator("grand_total", mode="before")
2727
@classmethod
2828
def parse_grand_total(cls, v):
29-
if isinstance(v, str):
30-
return Decimal(v)
29+
if isinstance(v, (str, float, int)):
30+
return Decimal(str(v))
3131
return v
3232

3333

@@ -103,8 +103,8 @@ class SimpleProduct(BaseModel):
103103
@field_validator("price", mode="before")
104104
@classmethod
105105
def parse_price(cls, v):
106-
if isinstance(v, str):
107-
return Decimal(v)
106+
if isinstance(v, (str, float, int)):
107+
return Decimal(str(v))
108108
return v
109109

110110

0 commit comments

Comments
 (0)