example.py
from learning_commons_evaluators import (
GradeLevelAppropriatenessEvaluator,
GradeLevelAppropriatenessInput,
)
evaluator = GradeLevelAppropriatenessEvaluator(google_api_key="your-google-key")
result = evaluator.evaluate_sync(
GradeLevelAppropriatenessInput(text="The cat's out of the bag now.")
)
Inputs
Inputs must be de-identified. Do not submit students' Personally Identifiable Information (PII) or any regulated or sensitive personal information.
evaluate().
Text Complexity evaluators
- Grade Level Appropriateness
- Others
| Field | Type | Description |
|---|---|---|
text | string | Informational text to evaluate (10-10,000 characters) |
| Field | Type | Description |
|---|---|---|
text | string | Informational text to evaluate (10-10,000 characters) |
grade_level | int | Target student grade (3–12) |
from learning_commons_evaluators import (
VocabularyComplexityEvaluator,
VocabularyComplexityInput,
)
evaluator = VocabularyComplexityEvaluator(
openai_api_key="your-openai-key",
google_api_key="your-google-key",
)
result = evaluator.evaluate_sync(
VocabularyComplexityInput(text="The cat's out of the bag now.", grade_level=5)
)
Graphics evaluators
v1.1.0- Graphics Accuracy
- Graphics Complexity
| Field | Type | Description |
|---|---|---|
image_paths | list[str] | Local path to the image to check, as a one-item list. PNG, JPEG, or WebP, 64 bytes to 5 MB, with width and height each 16–2,560 pixels |
claim | str | What the image should show: a statement about the image, or a question with its expected answer. 1–12,000 characters |
from learning_commons_evaluators import (
GraphicsAccuracyEvaluator,
compose_graphics_accuracy_claim, # Produces the exact wording the evaluator was tested with
)
evaluator = GraphicsAccuracyEvaluator(google_api_key="your-google-key")
result = evaluator.evaluate_sync(
image_paths=["figures/apples.png"],
claim=compose_graphics_accuracy_claim(
"How many apples do all the trees have together?", "9"
),
)
| Field | Type | Description |
|---|---|---|
text | str | Informational text that the graphics accompany. 1–10,000 characters |
grade_level | int | Target student grade, 3–12. Passed as an integer |
image_paths | list[str] | Local paths to the passage’s graphics, one per graphic, in reading order. 1–5 images. PNG, JPEG, or WebP, 64 bytes to 2.5 MB, with width and height each 16–8,000 pixels |
figure_labels | str | None | Optional. Comma-separated labels in the same order as image_paths (e.g., "Figure 1, Figure 2"). Defaults to Image 1, Image 2, and so on |
from learning_commons_evaluators import GraphicsComplexityEvaluator
evaluator = GraphicsComplexityEvaluator(google_api_key="your-google-key")
result = evaluator.evaluate_sync(
text="Beekeepers in the United States report losing hives at rates they have not seen before.",
grade_level=5,
image_paths=["figures/hive-losses.png"],
figure_labels="Figure 1",
)
Feedback evaluators
| Field | Type | Description |
|---|---|---|
student_text | string | Student’s written response. 1–10,000 characters |
feedback_text | string | Teacher or AI feedback to evaluate. 1–10,000 characters |
Academic Standards evaluators
The Academic Standards evaluators have 2 entry points, depending on how the standard is named:evaluate()- By the standard’s CASE UUIDevaluate_by_code()- By the standard’s code
- evaluate()
- evaluate_by_code()
| Field | Type | Description |
|---|---|---|
question | string | Math assessment question to evaluate. 1–10,000 characters |
case_identifier_uuid | string | CASE Network UUID of the math standard — the Knowledge Graph’s caseIdentifierUUID |
from learning_commons_evaluators import MathStandardsAlignmentEvaluator
evaluator = MathStandardsAlignmentEvaluator(
anthropic_api_key="your-anthropic-key",
learning_commons_api_key="your-learning-commons-key",
)
result = evaluator.evaluate_sync(
question="What is 3/4 + 1/8?",
case_identifier_uuid="6ba25656-d7cc-11e8-824f-0242ac160002",
)
| Field | Type | Description |
|---|---|---|
question | string | Math assessment question to evaluate. 1–10,000 characters |
statement_code | string | Math standard code, spelled as its jurisdiction spells it (e.g., "3.MD.C.7.d", "K.CC.A.1"). 1–50 characters |
jurisdiction | Jurisdiction ↗ | Optional. Whose framework the code belongs to (JurisdictionENUM). Defaults to Jurisdiction.MULTI_STATE, which is |
grade_level | string | Optional, "K" through "12". Only consulted when a code names more than one standard, which happens when a framework reuses codes across courses |
import asyncio
from learning_commons_evaluators import MathStandardsAlignmentEvaluator
evaluator = MathStandardsAlignmentEvaluator(
anthropic_api_key="your-anthropic-key",
learning_commons_api_key="your-learning-commons-key",
)
result = asyncio.run(
evaluator.evaluate_by_code(
question="What is 3/4 + 1/8?",
statement_code="5.NF.A.1",
)
)
Durable Skills evaluators
v1.2.0| Field | Type | Description |
|---|---|---|
assignment_text | str | Writing assignment or prompt given to the student. 1–3,000 characters |
source_passages | list[SourcePassage] | Source passages in the order the student received them. 1–5 passages. Fields for each passage are below |
essay_text | str | Student’s essay, verbatim. Spelling and grammar errors can stay in the text. 1–12,000 characters |
source_passages:
| Field | Type | Description |
|---|---|---|
title | str | None | Optional. Passage title, 1–300 characters. Leave it out, or pass None, when the passage has no title |
author | str | None | Optional. Passage author, 1–200 characters. Leave it out, or pass None, when the passage has no author |
text | str | Passage text. 1–9,000 characters |
from learning_commons_evaluators import CriticalThinkingEvaluator
evaluator = CriticalThinkingEvaluator(anthropic_api_key="your-anthropic-key")
result = evaluator.evaluate_sync(
assignment_text="Should our school move the start time from 7:30 to 8:30 a.m.? Write a letter to the school board. Use the source.",
source_passages=[
{
"title": "Teen Sleep and School Start Times",
"author": "Dr. Ortiz",
"text": "Melatonin arrives about two hours later at puberty, so most teenagers cannot fall asleep before about 11 p.m. In one survey, 7 in 10 high school students slept fewer than 8 hours on school nights.",
},
],
essay_text="Dear School Board, the school should start at 8:30. Dr. Ortiz explains that teenagers cannot fall asleep before about 11 p.m., so waking at 6 for a 7:30 start means about seven hours of sleep, which is not enough.",
)
Output
All evaluators return the following fields:| Field | Type | Description |
|---|---|---|
evaluator | string | Registry ID for the evaluator used |
result | Unique to each evaluator See “Output” for each evaluator (e.g., for Grade Level Appropriateness) | Detailed internal analysis data specific to each evaluator |
metadata | EvaluationMetadata ↗ | Includes model used to generate the evaluation, total evaluation processing time in milliseconds, input tokens, and output tokens |
Related topics
Quickstart
Install the SDK and run your first evaluator.
Configuration
Configure evaluators, including API keys and options.
Error handling
Handle configuration, validation, and API errors.