|
5 | 5 | ) |
6 | 6 | from pydantic import BaseModel, Field, ValidationError |
7 | 7 |
|
8 | | -from mistralai.client.models import ResponseFormat, JSONSchema |
9 | | -from mistralai.client.types.basemodel import Unset |
10 | | - |
11 | 8 | import unittest |
12 | 9 |
|
13 | 10 |
|
@@ -55,15 +52,14 @@ class MathDemonstration(BaseModel): |
55 | 52 | mathdemo_strict_schema["$defs"]["Explanation"]["additionalProperties"] = False # type: ignore |
56 | 53 | mathdemo_strict_schema["additionalProperties"] = False |
57 | 54 |
|
58 | | -mathdemo_response_format = ResponseFormat( |
59 | | - type="json_schema", |
60 | | - json_schema=JSONSchema( |
61 | | - name="MathDemonstration", |
62 | | - schema_definition=mathdemo_strict_schema, |
63 | | - description=Unset(), |
64 | | - strict=True, |
65 | | - ), |
66 | | -) |
| 55 | +mathdemo_response_format = { |
| 56 | + "type": "json_schema", |
| 57 | + "json_schema": { |
| 58 | + "name": "MathDemonstration", |
| 59 | + "schema": mathdemo_strict_schema, |
| 60 | + "strict": True, |
| 61 | + }, |
| 62 | +} |
67 | 63 |
|
68 | 64 |
|
69 | 65 | class TestResponseFormat(unittest.TestCase): |
@@ -220,10 +216,10 @@ class ModelWithConstraints(BaseModel): |
220 | 216 | # Should not raise ValueError |
221 | 217 | result = response_format_from_pydantic_model(ModelWithConstraints) |
222 | 218 |
|
223 | | - # Verify it returns a valid ResponseFormat |
224 | | - self.assertIsInstance(result, ResponseFormat) |
225 | | - self.assertEqual(result.type, "json_schema") |
226 | | - self.assertIsNotNone(result.json_schema) |
| 219 | + # Verify it returns a valid response format dict |
| 220 | + self.assertIsInstance(result, dict) |
| 221 | + self.assertEqual(result.get("type"), "json_schema") |
| 222 | + self.assertIsNotNone(result.get("json_schema")) |
227 | 223 |
|
228 | 224 | def test_rec_strict_json_schema_with_invalid_type(self): |
229 | 225 | """Test that rec_strict_json_schema raises ValueError for truly invalid types.""" |
|
0 commit comments