MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_sentiment

Function test_sentiment

sdk/python/examples/test_generate_object.py:106–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

toolMethod · 0.45

Tested by

no test coverage detected