Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/gen-ai/mock-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ and supplies its URL as `${MOCK_SERVER_URL}`.
| `anthropic_agents`, `mistral_agents` | hosted-agent creation |
| `assistants` | OpenAI Assistants, threads and runs |
| `bedrock` | `converse`, `converse-stream`, `invoke` |
| `bedrock_agent`, `bedrock_agentcore` | agent invocation, knowledge-base retrieval/generation (including streaming), and the memory APIs |
| `bedrock_agent`, `bedrock_agentcore` | agent invocation, knowledge-base retrieval/generation (including streaming), the memory APIs, and evaluator lookup and evaluation |
| `cohere` | `/v1` and `/v2` chat and embed |
| `google_genai` | Gemini and Vertex content generation, code execution, and interaction creation/retrieval with Google Search |
| `mistral` | chat completions, FIM and embeddings, under `/mistral/v1/…` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,55 @@ def delete_memory_record(memory_id, record_id):
return _json({"message": f"Memory record {record_id} not found"}, status=404)
_RECORDS[memory_id] = [r for r in store if r["memoryRecordId"] != record_id]
return _json({"memoryRecordId": record_id})


# Evaluations -----------------------------------------------------------------

_EVALUATOR_RATING_SCALE = {
"numerical": [
{"value": 1.0, "label": "Poor", "definition": "The response does not address the request."},
{"value": 3.0, "label": "Fair", "definition": "The response partly addresses the request."},
{"value": 5.0, "label": "Good", "definition": "The response fully addresses the request."},
]
}


@bp.route("/evaluators/<evaluator_id>", methods=["GET"])
def get_evaluator(evaluator_id):
return _json(
{
"evaluatorArn": f"arn:aws:bedrock-agentcore:us-east-1:123456789012:evaluator/{evaluator_id}",
"evaluatorId": evaluator_id,
"evaluatorName": "response_quality",
"evaluatorConfig": {
"llmAsAJudge": {
"instructions": "Rate how well the response addresses the request.",
"ratingScale": _EVALUATOR_RATING_SCALE,
"modelConfig": {"bedrockEvaluatorModelConfig": {"modelId": "mock-judge-model"}},
}
},
"level": "TRACE",
"status": "ACTIVE",
"createdAt": 1735689600.0,
"updatedAt": 1735689600.0,
}
)


@bp.route("/evaluations/evaluate/<evaluator_id>", methods=["POST"])
def evaluate(evaluator_id):
return _json(
{
"evaluationResults": [
{
"evaluatorArn": f"arn:aws:bedrock-agentcore:us-east-1:123456789012:evaluator/{evaluator_id}",
"evaluatorId": evaluator_id,
"evaluatorName": "response_quality",
"explanation": "The response fully addresses the request.",
"value": 5.0,
"label": "Good",
"tokenUsage": {"inputTokens": 120, "outputTokens": 30, "totalTokens": 150},
}
]
}
)
7 changes: 7 additions & 0 deletions tools/gen-ai/mock-server/tests/test_mock_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@
"/api/embed",
{"model": "nomic-embed-text", "input": ["hi", "there"]},
),
("bedrock-agentcore-get-evaluator", "get", "/evaluators/eval-mock-001", None),
(
"bedrock-agentcore-evaluate",
"post",
"/evaluations/evaluate/eval-mock-001",
{"evaluationInput": {"sessionSpans": []}},
),
]

Comment on lines 208 to 209
# Resource-creating endpoints mint a fresh id per call, so only the shape is
Expand Down