MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / _validate_book

Function _validate_book

scripts/server-test-structured.py:398–416  ·  view source on GitHub ↗
(parsed)

Source from the content-addressed store, hash-verified

396
397
398def _validate_book(parsed):
399 required = {"title", "author", "year", "genre", "page_count"}
400 missing = required - parsed.keys()
401 if missing:
402 return False, f"Missing fields: {missing}"
403 if not isinstance(parsed["title"], str) or not parsed["title"]:
404 return False, "title must be a non-empty string"
405 if not isinstance(parsed["author"], str) or "herbert" not in parsed["author"].lower():
406 return False, f"author unexpected: {parsed['author']!r}"
407 if not isinstance(parsed["year"], int) or parsed["year"] != 1965:
408 return False, f"year should be 1965, got {parsed['year']!r}"
409 if parsed["genre"] not in {
410 "fiction", "non-fiction", "fantasy", "sci-fi", "mystery",
411 "biography", "history", "other",
412 }:
413 return False, f"genre not in enum: {parsed['genre']!r}"
414 if not isinstance(parsed["page_count"], int) or parsed["page_count"] <= 0:
415 return False, f"page_count should be positive int: {parsed['page_count']!r}"
416 return True, f"Book: {parsed['title']} ({parsed['year']}) / {parsed['genre']}"
417
418
419# ---- Test 2: Sentiment classification (always / enum-constrained) ----

Callers 1

Calls 1

keysMethod · 0.80

Tested by

no test coverage detected