Add serde derives to AST types, enable chrono serde feature
Prep for wiring context_new.rs into the codebase: AstNode, NodeLeaf, NodeBody, Role all derive Serialize/Deserialize for conversation log persistence. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
bb80225942
commit
9fb9c2b2cb
2 changed files with 6 additions and 5 deletions
|
|
@ -39,7 +39,7 @@ uuid = { version = "1", features = ["v4"] }
|
||||||
bincode = "1"
|
bincode = "1"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
glob = "0.3"
|
glob = "0.3"
|
||||||
chrono = "0.4"
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
memchr = "2"
|
memchr = "2"
|
||||||
memmap2 = "0.9"
|
memmap2 = "0.9"
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
// the NodeBody variant. Grammar constraints enforced by construction.
|
// the NodeBody variant. Grammar constraints enforced by construction.
|
||||||
|
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
use serde::{Serialize, Deserialize};
|
||||||
use super::tokenizer;
|
use super::tokenizer;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
@ -37,7 +38,7 @@ use super::tokenizer;
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Branch roles — maps directly to the grammar's message roles.
|
/// Branch roles — maps directly to the grammar's message roles.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum Role {
|
pub enum Role {
|
||||||
System,
|
System,
|
||||||
User,
|
User,
|
||||||
|
|
@ -45,7 +46,7 @@ pub enum Role {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Leaf content — each variant knows how to render itself.
|
/// Leaf content — each variant knows how to render itself.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub enum NodeBody {
|
pub enum NodeBody {
|
||||||
// Children of message branches — rendered without im_start/im_end
|
// Children of message branches — rendered without im_start/im_end
|
||||||
Content(String),
|
Content(String),
|
||||||
|
|
@ -62,7 +63,7 @@ pub enum NodeBody {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A leaf node: typed content with cached token IDs.
|
/// A leaf node: typed content with cached token IDs.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct NodeLeaf {
|
pub struct NodeLeaf {
|
||||||
body: NodeBody,
|
body: NodeBody,
|
||||||
token_ids: Vec<u32>,
|
token_ids: Vec<u32>,
|
||||||
|
|
@ -70,7 +71,7 @@ pub struct NodeLeaf {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A node in the context AST.
|
/// A node in the context AST.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub enum AstNode {
|
pub enum AstNode {
|
||||||
Leaf(NodeLeaf),
|
Leaf(NodeLeaf),
|
||||||
Branch { role: Role, children: Vec<AstNode> },
|
Branch { role: Role, children: Vec<AstNode> },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue