Some checks failed
BotServer CI / build (push) Failing after 1m34s
Split 20+ files over 1000 lines into focused subdirectories for better maintainability and code organization. All changes maintain backward compatibility through re-export wrappers. Major splits: - attendance/llm_assist.rs (2074→7 modules) - basic/keywords/face_api.rs → face_api/ (7 modules) - basic/keywords/file_operations.rs → file_ops/ (8 modules) - basic/keywords/hear_talk.rs → hearing/ (6 modules) - channels/wechat.rs → wechat/ (10 modules) - channels/youtube.rs → youtube/ (5 modules) - contacts/mod.rs → contacts_api/ (6 modules) - core/bootstrap/mod.rs → bootstrap/ (5 modules) - core/shared/admin.rs → admin_*.rs (5 modules) - designer/canvas.rs → canvas_api/ (6 modules) - designer/mod.rs → designer_api/ (6 modules) - docs/handlers.rs → handlers_api/ (11 modules) - drive/mod.rs → drive_handlers.rs, drive_types.rs - learn/mod.rs → types.rs - main.rs → main_module/ (7 modules) - meet/webinar.rs → webinar_api/ (8 modules) - paper/mod.rs → (10 modules) - security/auth.rs → auth_api/ (7 modules) - security/passkey.rs → (4 modules) - sources/mod.rs → sources_api/ (5 modules) - tasks/mod.rs → task_api/ (5 modules) Stats: 38,040 deletions, 1,315 additions across 318 files Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
105 lines
4.1 KiB
Rust
105 lines
4.1 KiB
Rust
//! Face API BASIC Keyword Executors
|
|
//!
|
|
//! This module contains functions to execute Face API keywords from BASIC code.
|
|
|
|
use super::results::{FaceAnalysisResult, FaceDetectionResult, FaceVerificationResult};
|
|
use super::service::FaceApiService;
|
|
use super::types::{AnalysisOptions, DetectionOptions, FaceAttributeType, VerificationOptions};
|
|
|
|
// ============================================================================
|
|
// BASIC Keyword Executor
|
|
// ============================================================================
|
|
|
|
/// Execute DETECT FACES keyword
|
|
pub async fn execute_detect_faces(
|
|
service: &FaceApiService,
|
|
image_url: &str,
|
|
options: Option<DetectionOptions>,
|
|
) -> Result<FaceDetectionResult, super::error::FaceApiError> {
|
|
let image = super::types::ImageSource::Url(image_url.to_string());
|
|
let opts = options.unwrap_or_default();
|
|
service.detect_faces(&image, &opts).await
|
|
}
|
|
|
|
/// Execute VERIFY FACE keyword
|
|
pub async fn execute_verify_face(
|
|
service: &FaceApiService,
|
|
face1_url: &str,
|
|
face2_url: &str,
|
|
options: Option<VerificationOptions>,
|
|
) -> Result<FaceVerificationResult, super::error::FaceApiError> {
|
|
let face1 = super::types::FaceSource::Image(super::types::ImageSource::Url(face1_url.to_string()));
|
|
let face2 = super::types::FaceSource::Image(super::types::ImageSource::Url(face2_url.to_string()));
|
|
let opts = options.unwrap_or_default();
|
|
service.verify_faces(&face1, &face2, &opts).await
|
|
}
|
|
|
|
/// Execute ANALYZE FACE keyword
|
|
pub async fn execute_analyze_face(
|
|
service: &FaceApiService,
|
|
image_url: &str,
|
|
attributes: Option<Vec<FaceAttributeType>>,
|
|
options: Option<AnalysisOptions>,
|
|
) -> Result<FaceAnalysisResult, super::error::FaceApiError> {
|
|
let source = super::types::FaceSource::Image(super::types::ImageSource::Url(image_url.to_string()));
|
|
let attrs = attributes.unwrap_or_else(|| vec![
|
|
FaceAttributeType::Age,
|
|
FaceAttributeType::Gender,
|
|
FaceAttributeType::Emotion,
|
|
FaceAttributeType::Smile,
|
|
]);
|
|
let opts: AnalysisOptions = options.unwrap_or_default();
|
|
service.analyze_face(&source, &attrs, &opts).await
|
|
}
|
|
|
|
/// Convert detection result to BASIC-friendly format
|
|
pub fn detection_to_basic_value(result: &FaceDetectionResult) -> serde_json::Value {
|
|
serde_json::json!({
|
|
"success": result.success,
|
|
"face_count": result.face_count,
|
|
"faces": result.faces.iter().map(|f| {
|
|
serde_json::json!({
|
|
"id": f.id.to_string(),
|
|
"bounds": {
|
|
"left": f.bounding_box.left,
|
|
"top": f.bounding_box.top,
|
|
"width": f.bounding_box.width,
|
|
"height": f.bounding_box.height
|
|
},
|
|
"confidence": f.confidence,
|
|
"age": f.attributes.as_ref().and_then(|a| a.age),
|
|
"gender": f.attributes.as_ref().and_then(|a| a.gender).map(|g| format!("{:?}", g).to_lowercase()),
|
|
"emotion": f.attributes.as_ref().and_then(|a| a.emotion.as_ref()).map(|e| e.dominant_emotion()),
|
|
"smile": f.attributes.as_ref().and_then(|a| a.smile)
|
|
})
|
|
}).collect::<Vec<_>>(),
|
|
"processing_time_ms": result.processing_time_ms,
|
|
"error": result.error
|
|
})
|
|
}
|
|
|
|
/// Convert verification result to BASIC-friendly format
|
|
pub fn verification_to_basic_value(result: &FaceVerificationResult) -> serde_json::Value {
|
|
serde_json::json!({
|
|
"success": result.success,
|
|
"is_match": result.is_match,
|
|
"confidence": result.confidence,
|
|
"threshold": result.threshold,
|
|
"processing_time_ms": result.processing_time_ms,
|
|
"error": result.error
|
|
})
|
|
}
|
|
|
|
/// Convert analysis result to BASIC-friendly format
|
|
pub fn analysis_to_basic_value(result: &FaceAnalysisResult) -> serde_json::Value {
|
|
serde_json::json!({
|
|
"success": result.success,
|
|
"age": result.estimated_age,
|
|
"gender": result.gender,
|
|
"emotion": result.dominant_emotion,
|
|
"smile": result.smile_intensity,
|
|
"quality": result.quality_score,
|
|
"processing_time_ms": result.processing_time_ms,
|
|
"error": result.error
|
|
})
|
|
}
|