Free chart summaries; password login off by default
- New analysis kind 'summary' (migration 0005): saving a chart queues a
free 3-4 sentence summary written by SUMMARY_MODEL (default Sonnet
5.5, about 1 cent; Haiku was tested too but chose weaker highlights).
POST /v1/charts/{id}/summary returns it and re-queues a failed one.
- The chart page shows it in a "Röviden" card and polls until ready.
- PASSWORD_LOGIN (default false): register, login and password reset
answer 403; only Google (later Apple, Facebook) logins remain.
- Prompt v2: Hungarian names for elements and modalities (an English
"Fire" slipped into a summary); worker compare-models --summary.
- The worker also reads a lower-case openrouter_api_key.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -115,8 +115,13 @@ struct Response {
|
||||
|
||||
impl TestApp {
|
||||
async fn new(pool: PgPool) -> Self {
|
||||
Self::with_config(pool, |_| {}).await
|
||||
}
|
||||
|
||||
async fn with_config(pool: PgPool, change: impl FnOnce(&mut Config)) -> Self {
|
||||
let fake = fake_services().await;
|
||||
let config = Config::for_tests(String::new(), fake.clone(), format!("{fake}/jwks"));
|
||||
let mut config = Config::for_tests(String::new(), fake.clone(), format!("{fake}/jwks"));
|
||||
change(&mut config);
|
||||
Self { router: routes::router(Arc::new(AppState::new(pool.clone(), config))), pool }
|
||||
}
|
||||
|
||||
@@ -458,6 +463,17 @@ async fn analyses_spend_credits_and_reuse_results(pool: PgPool) {
|
||||
let chart = app.chart(&anna, "Saját", true, "1990-03-15").await;
|
||||
let uri = format!("/v1/charts/{}/analyses", chart["id"].as_str().unwrap());
|
||||
|
||||
// saving the chart queued the free short summary
|
||||
let list = app.get(&uri, Some(&anna)).await.body;
|
||||
let summary = &list["analyses"][0];
|
||||
assert_eq!(
|
||||
(summary["kind"].as_str(), summary["status"].as_str(), summary["model"].as_str(), &summary["credits_charged"]),
|
||||
(Some("summary"), Some("pending"), Some("anthropic/claude-summary"), &json!(0))
|
||||
);
|
||||
let r = app.call("POST", &format!("/v1/charts/{}/summary", chart["id"].as_str().unwrap()), Some(&anna), None).await;
|
||||
assert_eq!((r.status, &r.body["id"]), (StatusCode::OK, &summary["id"]));
|
||||
assert_eq!(app.get("/v1/credits", Some(&anna)).await.body["balance"], 2);
|
||||
|
||||
let r = app.call("POST", &uri, Some(&anna), None).await;
|
||||
assert_eq!(r.status, StatusCode::ACCEPTED, "{}", r.body);
|
||||
assert_eq!((r.body["status"].as_str(), r.body["language"].as_str()), (Some("pending"), Some("hu")));
|
||||
@@ -493,7 +509,22 @@ async fn analyses_spend_credits_and_reuse_results(pool: PgPool) {
|
||||
assert_eq!(app.get("/v1/credits", Some(&bela)).await.body["balance"], 2);
|
||||
|
||||
assert_eq!(app.get(&format!("/v1/analyses/{first}"), Some(&bela)).await.status, StatusCode::NOT_FOUND);
|
||||
assert_eq!(app.get(&uri, Some(&anna)).await.body["analyses"].as_array().unwrap().len(), 2);
|
||||
assert_eq!(app.get(&uri, Some(&anna)).await.body["analyses"].as_array().unwrap().len(), 3); // 2 + summary
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
async fn password_login_can_be_disabled(pool: PgPool) {
|
||||
let app = TestApp::with_config(pool, |c| c.password_login = false).await;
|
||||
assert_eq!(app.get("/v1/config", None).await.body["password_login"], false);
|
||||
let r = app
|
||||
.post("/v1/auth/register", None, json!({"email": "anna@example.com", "password": "titkos-jelszo-123"}))
|
||||
.await;
|
||||
assert_eq!(r.status, StatusCode::FORBIDDEN);
|
||||
let r =
|
||||
app.post("/v1/auth/login", None, json!({"email": "anna@example.com", "password": "titkos-jelszo-123"})).await;
|
||||
assert_eq!(r.status, StatusCode::FORBIDDEN);
|
||||
let r = app.post("/v1/auth/password-reset", None, json!({"email": "anna@example.com"})).await;
|
||||
assert_eq!(r.status, StatusCode::FORBIDDEN);
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
|
||||
Reference in New Issue
Block a user