MCPcopy Index your code
hub / github.com/AI45Lab/Code / test_extract_person

Function test_extract_person

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

Source from the content-addressed store, hash-verified

77 # ── Test 1: Simple extraction ────────────────────────────────────────────
78
79 def test_extract_person():
80 result = session.tool("generate_object", {
81 "schema": {
82 "type": "object",
83 "required": ["name", "age", "city"],
84 "properties": {
85 "name": {"type": "string"},
86 "age": {"type": "integer"},
87 "city": {"type": "string"},
88 },
89 },
90 "prompt": 'Extract: "Bob Zhang is 32 years old and lives in Beijing."',
91 "schema_name": "person",
92 "mode": "tool",
93 })
94 assert result.exit_code == 0, f"Tool failed: {result.output}"
95 parsed = json.loads(result.output)
96 obj = parsed["object"]
97 assert obj["name"].lower() == "bob zhang", f"name: {obj['name']}"
98 assert obj["age"] == 32, f"age: {obj['age']}"
99 assert "beijing" in obj["city"].lower(), f"city: {obj['city']}"
100 print(f" Result: {json.dumps(obj)}")
101
102 run_test("generate_object: extract person info", test_extract_person)
103

Callers

nothing calls this directly

Calls 1

toolMethod · 0.45

Tested by

no test coverage detected