use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Context {
pub history: Vec<String>,
pub preferences: HashMap<String, f64>,
pub session_id: String,
pub environment: HashMap<String, serde_json::Value>,
pub timestamp: i64,
}
impl Context {
pub fn new(session_id: String) -> Self {
Self {
session_id,
timestamp: chrono::Utc::now().timestamp(),
..Default::default()
}
}
pub fn add_message(&mut self, message: String) {
self.history.push(message);
self.timestamp = chrono::Utc::now().timestamp();
}
pub fn set_preference(&mut self, key: String, value: f64) {
self.preferences.insert(key, value);
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentState {
pub goals: Vec<Goal>,
pub beliefs: HashMap<String, Belief>,
pub intentions: Vec<Intention>,
pub policies: Vec<Policy>,
pub confidence: f64,
}
impl Default for AgentState {
fn default() -> Self {
Self {
goals: Vec::new(),
beliefs: HashMap::new(),
intentions: Vec::new(),
policies: Vec::new(),
confidence: 1.0,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Goal {
pub id: String,
pub description: String,
pub priority: f64,
pub achieved: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Belief {
pub proposition: String,
pub confidence: f64,
pub evidence: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Intention {
pub goal_id: String,
pub action_sequence: Vec<String>,
pub committed: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Policy {
pub condition: String,
pub action: String,
pub expected_reward: f64,
pub usage_count: u64,
}
pub type Reward = f64;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StreamMessage {
pub content: String,
pub metadata: HashMap<String, serde_json::Value>,
pub timestamp: i64,
pub sender: String,
}
impl StreamMessage {
pub fn new(content: String, sender: String) -> Self {
Self {
content,
sender,
timestamp: chrono::Utc::now().timestamp(),
metadata: HashMap::new(),
}
}
}