Skip to content
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions crates/lance-context-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@ pub struct AddRolloutRequest {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub payload_checksum: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub artifact_type: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<Value>,
}

Expand Down Expand Up @@ -741,6 +743,10 @@ pub struct RolloutRecordDto {
pub payload_size: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub payload_checksum: Option<String>,
/// User-defined semantic artifact category (e.g. `"excel_grade_screenshot"`),
/// orthogonal to `content_type`. A first-class, filterable column.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub artifact_type: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<Value>,
}
Expand Down
2 changes: 2 additions & 0 deletions crates/lance-context-core/src/api_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ fn rollout_record_from_add_request(r: &AddRolloutRequest) -> RolloutRecord {
binary_payload: r.binary_payload.clone(),
payload_size: r.payload_size,
payload_checksum: r.payload_checksum.clone(),
artifact_type: r.artifact_type.clone(),
metadata: r.metadata.clone(),
}
}
Expand Down Expand Up @@ -497,6 +498,7 @@ fn rollout_record_to_dto(r: RolloutRecord) -> RolloutRecordDto {
binary_payload: r.binary_payload,
payload_size: r.payload_size,
payload_checksum: r.payload_checksum,
artifact_type: r.artifact_type,
metadata: r.metadata,
}
}
Expand Down
10 changes: 9 additions & 1 deletion crates/lance-context-core/src/rollout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,16 @@ pub struct RolloutRecord {
pub binary_payload: Option<Vec<u8>>,
pub payload_size: Option<i64>,
pub payload_checksum: Option<String>,
/// User-defined semantic category of an artifact, e.g.
/// `"excel_grade_screenshot"`. Orthogonal to `content_type`, which is the
/// transport/media type (e.g. `"image/png"`): `content_type` says how to
/// decode the bytes, `artifact_type` says what the artifact *means*. A
/// first-class column so it can be filtered / grouped-by / projected
/// without materializing the free-form `metadata` JSON.
pub artifact_type: Option<String>,
/// Harness metadata — the open-ended escape hatch, for genuinely
/// unstructured fields only (e.g. an artifact's `filename` / `artifact_type`).
/// unstructured fields only (e.g. an artifact's `filename`). Semantic
/// categories that you filter/group-by belong in `artifact_type` instead.
pub metadata: Option<Value>,
}

Expand Down
14 changes: 13 additions & 1 deletion crates/lance-context-core/src/rollout_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ impl RolloutStore {
let mut binary_payload_builder = LargeBinaryBuilder::new();
let mut payload_size_builder = Int64Builder::new();
let mut payload_checksum_builder = StringBuilder::new();
let mut artifact_type_builder = StringBuilder::new();
let mut metadata_builder = LargeStringBuilder::new();

for record in records {
Expand Down Expand Up @@ -482,6 +483,7 @@ impl RolloutStore {
}
payload_size_builder.append_option(record.payload_size);
payload_checksum_builder.append_option(record.payload_checksum.as_deref());
artifact_type_builder.append_option(record.artifact_type.as_deref());
match &record.metadata {
Some(metadata) => metadata_builder.append_value(metadata.to_string()),
None => metadata_builder.append_null(),
Expand Down Expand Up @@ -589,6 +591,10 @@ impl RolloutStore {
"payload_checksum".to_string(),
Arc::new(payload_checksum_builder.finish()),
);
arrays_by_name.insert(
"artifact_type".to_string(),
Arc::new(artifact_type_builder.finish()),
);
if include_metadata {
arrays_by_name.insert("metadata".to_string(), Arc::new(metadata_builder.finish()));
}
Expand Down Expand Up @@ -682,6 +688,7 @@ pub fn rollout_schema() -> Schema {
binary_field,
Field::new("payload_size", DataType::Int64, true),
Field::new("payload_checksum", DataType::Utf8, true),
Field::new("artifact_type", DataType::Utf8, true),
Field::new("metadata", DataType::LargeUtf8, true),
];

Expand Down Expand Up @@ -767,6 +774,7 @@ fn batch_to_rollout_records(batch: &RecordBatch) -> LanceResult<Vec<RolloutRecor
let binary_payload_array = column_as_optional::<LargeBinaryArray>(batch, "binary_payload");
let payload_size_array = column_as_optional::<Int64Array>(batch, "payload_size");
let payload_checksum_array = column_as_optional::<StringArray>(batch, "payload_checksum");
let artifact_type_array = column_as_optional::<StringArray>(batch, "artifact_type");
let metadata_array = column_as_optional::<LargeStringArray>(batch, "metadata");

let mut results = Vec::with_capacity(batch.num_rows());
Expand Down Expand Up @@ -855,6 +863,7 @@ fn batch_to_rollout_records(batch: &RecordBatch) -> LanceResult<Vec<RolloutRecor
}
}),
payload_checksum: optional_string(payload_checksum_array, row),
artifact_type: optional_string(artifact_type_array, row),
metadata,
});
}
Expand Down Expand Up @@ -997,6 +1006,7 @@ mod tests {
binary_payload: None,
payload_size: None,
payload_checksum: None,
artifact_type: None,
metadata: Some(json!({"harness": "verifiers"})),
}
}
Expand Down Expand Up @@ -1032,7 +1042,8 @@ mod tests {
binary_payload: Some(bytes.to_vec()),
payload_size: Some(bytes.len() as i64),
payload_checksum: Some("sha256:cafef00d".to_string()),
metadata: Some(json!({"filename": "trace.bin", "artifact_type": "trace"})),
artifact_type: Some("excel_grade_screenshot".to_string()),
metadata: Some(json!({"filename": "trace.bin"})),
}
}

Expand Down Expand Up @@ -1074,6 +1085,7 @@ mod tests {
// round-trip.
assert_eq!(actual.payload_size, expected.payload_size);
assert_eq!(actual.payload_checksum, expected.payload_checksum);
assert_eq!(actual.artifact_type, expected.artifact_type);
assert_eq!(actual.metadata, expected.metadata);
}

Expand Down
2 changes: 2 additions & 0 deletions crates/lance-context-server/src/routes/rollouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ fn rollout_record_from_add_request(r: &AddRolloutRequest) -> RolloutRecord {
binary_payload: r.binary_payload.clone(),
payload_size: r.payload_size,
payload_checksum: r.payload_checksum.clone(),
artifact_type: r.artifact_type.clone(),
metadata: r.metadata.clone(),
}
}
Expand Down Expand Up @@ -482,6 +483,7 @@ fn rollout_record_to_dto(r: RolloutRecord) -> RolloutRecordDto {
binary_payload: r.binary_payload,
payload_size: r.payload_size,
payload_checksum: r.payload_checksum,
artifact_type: r.artifact_type,
metadata: r.metadata,
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/lance-context/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ pub use lance_context_core::{
pub use lance_context_api::{
AddRecordRequest, AddRecordsResponse, AddRolloutRequest, AddRolloutsResponse, CompactRequest,
CompactResponse, CompactStatsResponse, ContextError, ContextResult, ContextStoreApi,
DeleteRecordResponse, RecordDto, RelationshipDto, RetrieveRequest, RetrieveResponse,
RetrieveResultDto, RolloutRecordDto, RolloutStoreApi, SearchResultDto, UpsertRecordRequest,
UpsertRecordResponse,
CreateRolloutStoreRequest, DeleteRecordResponse, RecordDto, RelationshipDto, RetrieveRequest,
RetrieveResponse, RetrieveResultDto, RolloutRecordDto, RolloutStoreApi, SearchResultDto,
UpsertRecordRequest, UpsertRecordResponse,
};

#[cfg(feature = "remote")]
Expand Down
1 change: 1 addition & 0 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ crate-type = ["cdylib"]

[dependencies]
chrono = { version = "0.4", default-features = false, features = ["clock"] }
lance-context = { path = "../crates/lance-context", features = ["remote"] }
lance-context-api = { path = "../crates/lance-context-api" }
lance-context-client = { path = "../crates/lance-context-client" }
lance-context-core = { path = "../crates/lance-context-core" }
Expand Down
4 changes: 4 additions & 0 deletions python/python/lance_context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
ContextNamespace,
EmbeddingProvider,
RemoteContext,
RemoteRolloutStore,
RolloutStore,
__version__,
)
from .embeddings import ( # pyright: ignore[reportMissingImports]
Expand All @@ -19,5 +21,7 @@
"EmbeddingProvider",
"MultiModalEmbeddingProvider",
"RemoteContext",
"RemoteRolloutStore",
"RolloutStore",
"__version__",
]
Loading
Loading