Skip to content
Draft

viz #2582

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
28 changes: 27 additions & 1 deletion engine/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions engine/baml-rpc/src/ui/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod ui_baml_src;
pub mod ui_blobs;
pub mod ui_control_plane_orgs;
pub mod ui_control_plane_projects;
pub mod ui_dashboard;
Expand Down
2 changes: 1 addition & 1 deletion engine/baml-rpc/src/ui/ui_baml_src.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct BamlSourceCode {
pub struct AstNodeDefinition {
pub project_id: String,
pub ast_node_id: String,
#[ts(type = "any")]
#[ts(type = "unknown")]
pub ast_node_definition: serde_json::Value,
pub flattened_dependencies_ast_nodes: Vec<String>,
pub baml_src_node_ids: Vec<String>,
Expand Down
42 changes: 42 additions & 0 deletions engine/baml-rpc/src/ui/ui_blobs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use serde::{Deserialize, Serialize};
use ts_rs::TS;

use crate::ProjectId;

/// Request to fetch blob content
#[derive(Debug, Serialize, Deserialize, TS)]
#[ts(export)]
pub struct GetBlobRequest {
/// The 64-character BLAKE3 hash of the blob
pub blob_hash: String,
/// The project ID that owns this blob
#[ts(type = "string")]
pub project_id: ProjectId,
/// Response format: 'raw' returns binary, 'json' returns base64-encoded content
#[serde(default)]
pub format: BlobFormat,
}

/// Response format for blob content
#[derive(Debug, Serialize, Deserialize, TS, Default)]
#[ts(export)]
#[serde(rename_all = "lowercase")]
pub enum BlobFormat {
/// Return raw binary content with appropriate Content-Type header
#[default]
Raw,
/// Return JSON with base64-encoded content
Json,
}

/// JSON response format for blob content
#[derive(Debug, Serialize, Deserialize, TS)]
#[ts(export)]
pub struct GetBlobResponse {
/// The blob hash
pub blob_hash: String,
/// The content type of the decoded blob (e.g., "image/png")
pub content_type: String,
/// Base64-encoded content (exact same as used in LLM request)
pub base64_content: String,
}
12 changes: 6 additions & 6 deletions engine/baml-rpc/src/ui/ui_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub struct UiFunctionCall {
#[ts(optional)]
pub function_id: Option<UiFunctionIdString>,

#[ts(type = "Record<string, string>")]
#[ts(type = "Record<string, unknown>")]
pub tags: serde_json::Map<String, serde_json::Value>,

#[serde(rename = "start_epoch_ms")]
Expand All @@ -105,7 +105,7 @@ pub struct UiFunctionCall {
pub end_time: Option<EpochMsTimestamp>,
pub status: String,

#[ts(type = "any")]
#[ts(type = "unknown")]
pub baml_options: serde_json::Value,
pub inputs: Vec<UiFunctionInput>,
#[ts(as = "Option<BamlValue>")]
Expand All @@ -130,9 +130,9 @@ pub struct UiLlmRequest {
pub client_name: String,
pub client_provider: String,
// TODO: type this out properly.
#[ts(type = "any")]
#[ts(type = "unknown")]
pub params: serde_json::Value,
#[ts(type = "any")]
#[ts(type = "unknown")]
pub prompt: serde_json::Value,
}

Expand Down Expand Up @@ -186,7 +186,7 @@ pub struct UiHttpRequest {
pub start_time: EpochMsTimestamp,
pub url: String,
pub method: String,
#[ts(type = "Record<string, any> | undefined")]
#[ts(type = "Record<string, string> | undefined")]
pub headers: Option<HashMap<String, String>>,
pub body: String,
}
Expand All @@ -197,7 +197,7 @@ pub struct UiHttpResponse {
#[ts(type = "number")]
pub end_time: EpochMsTimestamp,
pub status_code: u16,
#[ts(type = "Record<string, any>")]
#[ts(type = "Record<string, unknown>")]
pub headers: HashMap<String, serde_json::Value>,
pub body: String,
}
Expand Down
1 change: 1 addition & 0 deletions engine/baml-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ once_cell.workspace = true
time.workspace = true
tempfile = "3.19.0"
sha2 = "0.10.9"
blake3 = "1.8.2"


[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
use baml_rpc::runtime_api::baml_value::{BamlValue, MediaValue, ValueContent};
use base64::{engine::general_purpose, Engine as _};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use blake3;
use tokio::sync::mpsc;

use crate::tracingv2::publisher::publisher::BlobUploaderMessage;
Expand Down Expand Up @@ -82,11 +82,10 @@ impl BlobRefCache {
}
}

/// Generate a hash for a blob
/// Generate a hash for a blob using BLAKE3
pub fn hash_blob(content: &[u8]) -> String {
let mut hasher = Sha256::new();
hasher.update(content);
format!("{:x}", hasher.finalize())
let hash = blake3::hash(content);
hash.to_hex().to_string()
}

/// Store a blob (as base64 string) and associate it with a function_call_id
Expand Down
Loading