oxirs_embed/
enterprise_knowledge_product.rs1use crate::Vector;
4use chrono::{DateTime, Utc};
5use serde::{Deserialize, Serialize};
6use std::collections::HashMap;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct ProductEmbedding {
11 pub product_id: String,
13 pub name: String,
15 pub description: String,
17 pub category: String,
19 pub subcategories: Vec<String>,
21 pub features: Vec<ProductFeature>,
23 pub price: f64,
25 pub availability: ProductAvailability,
27 pub sales_metrics: SalesMetrics,
29 pub ratings: CustomerRatings,
31 pub embedding: Vector,
33 pub similar_products: Vec<String>,
35 pub market_position: f64,
37 pub last_updated: DateTime<Utc>,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
43pub struct ProductFeature {
44 pub feature_name: String,
46 pub feature_value: String,
48 pub feature_type: FeatureType,
50 pub importance_score: f64,
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56pub enum FeatureType {
57 Categorical,
58 Numerical,
59 Boolean,
60 Text,
61 List,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
66pub enum ProductAvailability {
67 InStock(u32),
68 OutOfStock,
69 Discontinued,
70 PreOrder(DateTime<Utc>),
71 Limited(u32),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct SalesMetrics {
77 pub units_sold: u64,
79 pub revenue: f64,
81 pub sales_velocity: f64,
83 pub conversion_rate: f64,
85 pub return_rate: f64,
87 pub profit_margin: f64,
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize)]
93pub struct CustomerRatings {
94 pub average_rating: f64,
96 pub review_count: u32,
98 pub rating_distribution: HashMap<u8, u32>,
100 pub sentiment_score: f64,
102}
103
104#[derive(Debug, Clone)]
106pub struct CategoryHierarchy {
107 pub categories: HashMap<String, Category>,
109 pub parent_child: HashMap<String, Vec<String>>,
111 pub category_embeddings: HashMap<String, Vector>,
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117pub struct Category {
118 pub category_id: String,
120 pub name: String,
122 pub parent: Option<String>,
124 pub children: Vec<String>,
126 pub products: Vec<String>,
128 pub attributes: HashMap<String, String>,
130 pub performance: CategoryPerformance,
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136pub struct CategoryPerformance {
137 pub total_sales: f64,
139 pub product_count: u32,
141 pub average_rating: f64,
143 pub growth_rate: f64,
145 pub market_share: f64,
147}