Add serde defaults for backward compatibility
- Add default values for interpreted_content (empty string) - Add default values for priority_score (0.5) - This allows loading old memory.json files without these fields Existing data is now compatible with new code structure.
This commit is contained in:
@@ -10,13 +10,24 @@ use crate::ai_interpreter::AIInterpreter;
|
|||||||
pub struct Memory {
|
pub struct Memory {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub content: String,
|
pub content: String,
|
||||||
|
#[serde(default = "default_interpreted_content")]
|
||||||
pub interpreted_content: String, // AI解釈後のコンテンツ
|
pub interpreted_content: String, // AI解釈後のコンテンツ
|
||||||
|
#[serde(default = "default_priority_score")]
|
||||||
pub priority_score: f32, // 心理判定スコア (0.0-1.0)
|
pub priority_score: f32, // 心理判定スコア (0.0-1.0)
|
||||||
|
#[serde(default)]
|
||||||
pub user_context: Option<String>, // ユーザー固有性
|
pub user_context: Option<String>, // ユーザー固有性
|
||||||
pub created_at: DateTime<Utc>,
|
pub created_at: DateTime<Utc>,
|
||||||
pub updated_at: DateTime<Utc>,
|
pub updated_at: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_interpreted_content() -> String {
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_priority_score() -> f32 {
|
||||||
|
0.5
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct Conversation {
|
pub struct Conversation {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
|
|||||||
Reference in New Issue
Block a user