feat(clients): bedrock: SigV4 signer, Converse, event streams, guardrails, agents, KB, batch
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// Routes: GET /ai/bedrock (page), /status, /calls (no credential needed)
|
||||
#include <cstdlib>
|
||||
|
||||
#include "support/Assert.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
setenv("MOLO_ENV_FILES", "off", 1);
|
||||
for (const char* v : {"AWS_BEARER_TOKEN_BEDROCK", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN", "AWS_REGION", "AWS_DEFAULT_REGION"})
|
||||
unsetenv(v);
|
||||
Fixture f;
|
||||
auto page = f.client->get("/ai/bedrock");
|
||||
check(page.status == 200, "page 200");
|
||||
check(contains(page.headers.get("Content-Type"), "text/html"), "html");
|
||||
check(contains(page.body, "Amazon Bedrock") && contains(page.body, "viewport"), "title and mobile viewport");
|
||||
check(contains(page.body, "/embedded/ai_bedrock.js"), "script wired");
|
||||
check(contains(page.body, "<select"), "route picker is a dropdown, not a button row");
|
||||
check(f.client->post("/ai/bedrock", "{}", "application/json").status == 405, "post page is 405");
|
||||
|
||||
auto script = f.client->get("/embedded/ai_bedrock.js");
|
||||
check(script.status == 200 && contains(script.body, "/ai/bedrock/"), "script is embedded");
|
||||
|
||||
auto st = f.client->get("/ai/bedrock/status");
|
||||
check(st.status == 200 && contains(st.body, "\"configured\":false"), "status without a credential");
|
||||
check(contains(st.body, "\"auth_mode\":\"none\"") && contains(st.body, "\"region\":\"us-east-1\""), "status names mode and default region");
|
||||
check(contains(st.body, "AWS_BEARER_TOKEN_BEDROCK") && contains(st.body, "AWS_ACCESS_KEY_ID") &&
|
||||
contains(st.body, "AWS_SECRET_ACCESS_KEY") && contains(st.body, "AWS_SESSION_TOKEN") && contains(st.body, "AWS_REGION"),
|
||||
"status names the credential env vars");
|
||||
check(contains(st.body, "bedrock-runtime.us-east-1.amazonaws.com") && contains(st.body, "bedrock.us-east-1.amazonaws.com") &&
|
||||
contains(st.body, "bedrock-agent-runtime.us-east-1.amazonaws.com"),
|
||||
"status lists the three hosts");
|
||||
check(f.client->post("/ai/bedrock/status", "{}", "application/json").status == 405, "post status is 405");
|
||||
|
||||
auto calls = f.client->get("/ai/bedrock/calls");
|
||||
check(calls.status == 200 && contains(calls.body, "Converse") && contains(calls.body, "/model/{modelId}/converse-stream") &&
|
||||
contains(calls.body, "ApplyGuardrail") && contains(calls.body, "/knowledgebases/{knowledgeBaseId}/retrieve") &&
|
||||
contains(calls.body, "CreateModelInvocationJob"),
|
||||
"call table listed");
|
||||
check(contains(calls.body, "\"bearer_ok\":false"), "agent runtime marked as SigV4 only");
|
||||
return finish("ai/bedrock/page");
|
||||
}
|
||||
Reference in New Issue
Block a user