first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use cloud_objects::cloud_object::{
|
||||
GenericCloudObject, GenericServerObject, GenericStringModel, JsonObjectType,
|
||||
};
|
||||
use cloud_objects::ids::GenericStringObjectId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{JsonModel, JsonSerializer};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum AIFact {
|
||||
#[serde(rename = "memory")]
|
||||
Memory(AIMemory),
|
||||
}
|
||||
|
||||
/// A globally unique ID for suggested objects.
|
||||
///
|
||||
/// This is used for telemetry purposes to track and connect both:
|
||||
/// - Suggested objects generated by the AI agent.
|
||||
/// - The corresponding objects stored in the cloud, if the suggestion was accepted.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct SuggestedLoggingId(String);
|
||||
|
||||
impl Display for SuggestedLoggingId {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for SuggestedLoggingId {
|
||||
fn from(value: String) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct AIMemory {
|
||||
#[serde(default)]
|
||||
pub name: Option<String>,
|
||||
pub content: String,
|
||||
// Deprecated: This field is no longer used and will be removed in the future.
|
||||
#[serde(default)]
|
||||
pub is_autogenerated: bool,
|
||||
/// If this rule was created from a suggested rule, record the suggestion's logging_id
|
||||
/// so we can suppress re-surfacing the same suggestion in future responses.
|
||||
#[serde(default)]
|
||||
pub suggested_logging_id: Option<SuggestedLoggingId>,
|
||||
}
|
||||
|
||||
impl AIFact {
|
||||
pub fn is_memory(&self) -> bool {
|
||||
matches!(self, AIFact::Memory { .. })
|
||||
}
|
||||
}
|
||||
|
||||
impl JsonModel for AIFact {
|
||||
fn json_object_type() -> JsonObjectType {
|
||||
JsonObjectType::AIFact
|
||||
}
|
||||
}
|
||||
|
||||
pub type CloudAIFact = GenericCloudObject<GenericStringObjectId, CloudAIFactModel>;
|
||||
pub type CloudAIFactModel = GenericStringModel<AIFact, JsonSerializer>;
|
||||
pub type ServerAIFact = GenericServerObject<GenericStringObjectId, CloudAIFactModel>;
|
||||
Reference in New Issue
Block a user