| 104 | # ── Test 2: Enum classification ────────────────────────────────────────── |
| 105 | |
| 106 | def test_sentiment(): |
| 107 | result = session.tool("generate_object", { |
| 108 | "schema": { |
| 109 | "type": "object", |
| 110 | "required": ["sentiment"], |
| 111 | "properties": { |
| 112 | "sentiment": {"type": "string", "enum": ["positive", "negative", "neutral"]}, |
| 113 | }, |
| 114 | }, |
| 115 | "prompt": 'Classify: "I absolutely love this new feature, it works perfectly!"', |
| 116 | "schema_name": "sentiment", |
| 117 | }) |
| 118 | assert result.exit_code == 0, f"Tool failed: {result.output}" |
| 119 | parsed = json.loads(result.output) |
| 120 | obj = parsed["object"] |
| 121 | assert obj["sentiment"] == "positive", f"sentiment: {obj['sentiment']}" |
| 122 | print(f" Result: sentiment={obj['sentiment']}") |
| 123 | |
| 124 | run_test("generate_object: sentiment classification", test_sentiment) |
| 125 | |