33 lines
1.5 KiB
C++
33 lines
1.5 KiB
C++
// Route: POST /agent/optimize/simulate (simulated user vs a model agent, scored)
|
|
#include "support/GoogleRig.hpp"
|
|
|
|
using namespace molo::example::test;
|
|
|
|
int main() {
|
|
const char* json = "application/json";
|
|
GoogleRig keyed;
|
|
Fixture f(keyed.client);
|
|
const std::string ok =
|
|
"\"instruction\":\"help\",\"starting_prompt\":\"hi\",\"plan\":\"ask for a refund\"";
|
|
check(f.client->post("/agent/optimize/simulate", "{" + ok + ",\"max_turns\":13}", json).status == 422,
|
|
"max_turns over 12 is 422");
|
|
check(f.client->post("/agent/optimize/simulate", "{" + ok + ",\"max_turns\":0}", json).status == 422,
|
|
"max_turns 0 is 422");
|
|
check(f.client->post("/agent/optimize/simulate",
|
|
"{\"instruction\":\"help\",\"starting_prompt\":\"hi\"}", json).status == 422,
|
|
"missing plan is 422");
|
|
check(f.client->post("/agent/optimize/simulate", "{\"plan\":\"p\",\"starting_prompt\":\"hi\"}", json)
|
|
.status == 422,
|
|
"missing instruction is 422");
|
|
check(keyed.mock->send_count() == 0, "rejected input never reached Google");
|
|
check(f.client->get("/agent/optimize/simulate").status == 405, "get is 405");
|
|
|
|
GoogleRig none(false);
|
|
Fixture g(none.client);
|
|
auto res = g.client->post("/agent/optimize/simulate", "{" + ok + "}", json);
|
|
check(res.status == 503 && contains(res.body, "google_not_configured"),
|
|
"no credential is a loud 503");
|
|
check(none.mock->send_count() == 0, "no network without a credential");
|
|
return finish("agent/optimize/simulate");
|
|
}
|