-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* eval pooler * changed limits * rename vars, add camelCase * lint frontend, fixes build * add evaluation index * expose env var + wip: realtime * updated rrweb-player * improved browser ui * correct time * fixed timeline * v0 realtime evals, also makes supabase client singleton --------- Co-authored-by: Din <[email protected]>
- Loading branch information
1 parent
59bb656
commit 8a1eca2
Showing
30 changed files
with
3,585 additions
and
465 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::{ | ||
db::{self, project_api_keys::ProjectApiKey, DB}, | ||
evaluations::{save_evaluation_scores, utils::EvaluationDatapointResult}, | ||
names::NameGenerator, | ||
routes::types::ResponseResult, | ||
}; | ||
use actix_web::{ | ||
post, | ||
web::{self, Json}, | ||
HttpResponse, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
use uuid::Uuid; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct InitEvalRequest { | ||
pub name: Option<String>, | ||
pub group_name: Option<String>, | ||
} | ||
|
||
#[post("/evals")] | ||
pub async fn init_eval( | ||
req: Json<InitEvalRequest>, | ||
db: web::Data<DB>, | ||
name_generator: web::Data<Arc<NameGenerator>>, | ||
project_api_key: ProjectApiKey, | ||
) -> ResponseResult { | ||
let req = req.into_inner(); | ||
let group_name = req.group_name.unwrap_or_else(|| "default".to_string()); | ||
let project_id = project_api_key.project_id; | ||
|
||
let name = if let Some(name) = req.name { | ||
name | ||
} else { | ||
name_generator.next().await | ||
}; | ||
|
||
let evaluation = | ||
db::evaluations::create_evaluation(&db.pool, &name, project_id, &group_name).await?; | ||
|
||
Ok(HttpResponse::Ok().json(evaluation)) | ||
} | ||
|
||
#[derive(Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct SaveEvalDatapointsRequest { | ||
pub group_name: Option<String>, | ||
pub points: Vec<EvaluationDatapointResult>, | ||
} | ||
|
||
#[post("/evals/{eval_id}/datapoints")] | ||
pub async fn save_eval_datapoints( | ||
eval_id: web::Path<Uuid>, | ||
req: Json<SaveEvalDatapointsRequest>, | ||
db: web::Data<DB>, | ||
clickhouse: web::Data<clickhouse::Client>, | ||
project_api_key: ProjectApiKey, | ||
) -> ResponseResult { | ||
let eval_id = eval_id.into_inner(); | ||
let req = req.into_inner(); | ||
let project_id = project_api_key.project_id; | ||
let points = req.points; | ||
let db = db.into_inner(); | ||
let group_name = req.group_name.unwrap_or("default".to_string()); | ||
let clickhouse = clickhouse.into_inner().as_ref().clone(); | ||
|
||
save_evaluation_scores( | ||
db.clone(), | ||
clickhouse, | ||
points, | ||
eval_id, | ||
project_id, | ||
&group_name, | ||
) | ||
.await?; | ||
|
||
Ok(HttpResponse::Ok().json(eval_id)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.