From 71c33f27f6fa76891f3d587422adc27d4a6219ce Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Wed, 1 Oct 2025 09:04:19 -0300 Subject: [PATCH] Add logging for LLM and embedding server commands --- src/models/PROMPT.md | 94 +++++++++++++++++++++++++++++++++++++++ src/models/org_model.rs | 12 +++++ src/services/llm_local.rs | 11 ++--- 3 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 src/models/PROMPT.md create mode 100644 src/models/org_model.rs diff --git a/src/models/PROMPT.md b/src/models/PROMPT.md new file mode 100644 index 0000000..c3c462e --- /dev/null +++ b/src/models/PROMPT.md @@ -0,0 +1,94 @@ + +Create a Rust data model for database storage with optimal size and performance characteristics. Follow these specifications: + +**REQUIREMENTS:** +1. Use appropriate integer types (i32, i16, i8, etc.) based on expected value ranges +2. Use `Option` for nullable fields to avoid memory overhead +3. Use `Vec` for binary data instead of strings when appropriate +4. Prefer enum representations as integers rather than strings +5. Use `chrono::DateTime` for timestamps +6. Use `uuid::Uuid` for unique identifiers +7. Implement necessary traits: `Debug`, `Clone`, `Serialize`, `Deserialize`, `FromRow` +8. Include validation where appropriate +9. Consider database index strategy in field design + +**CONTEXT:** +- Database: PostgreSQL/SQLx compatible +- Serialization: Serde for JSON +- ORM: SQLx for database operations + +**OUTPUT FORMAT:** +Provide the complete Rust struct with: +- Struct definition with fields +- Enum definitions with integer representations +- Conversion implementations +- Basic validation if needed + +**EXAMPLE REFERENCE:** +```rust +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use sqlx::FromRow; +use uuid::Uuid; + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum Status { + Pending = 0, + Active = 1, + Inactive = 2, +} + +impl Status { + pub fn from_i16(value: i16) -> Option { + match value { + 0 => Some(Self::Pending), + 1 => Some(Self::Active), + 2 => Some(Self::Inactive), + _ => None, + } + } +} + +#[derive(Debug, FromRow, Serialize, Deserialize)] +pub struct User { + pub id: Uuid, + pub status: i16, // Using i16 for enum storage + pub email: String, + pub age: Option, // Nullable small integer + pub metadata: Vec, // Binary data for flexibility + pub created_at: DateTime, +} +``` + +Generate a similar model for: [YOUR DOMAIN HERE] +``` + +## Specialized Variants + +### For High-Performance Applications +``` +Add these additional requirements: +- Use `#[repr(u8)]` for enums to ensure minimal size +- Consider `Box` instead of `String` for reduced heap overhead +- Use `arrayvec::ArrayString` for fixed-size short strings +- Implement `PartialEq` and `Eq` for hash-based operations +- Include `#[derive(Default)]` where appropriate +``` + +### For Embedded/Memory-Constrained Systems +``` +Add these constraints: +- Prefer `i16` over `i32` where possible +- Use `u32` instead of `Uuid` if sequential IDs are acceptable +- Consider `bitflags` for multiple boolean flags in single byte +- Use `smol_str::SmolStr` for string optimization +- Avoid `Vec` in favor of arrays with capacity limits +``` + +### For Time-Series Data +``` +Add time-series specific optimizations: +- Use `i64` for timestamps as nanoseconds since epoch +- Use `f32` instead of `f64` for measurements where precision allows +- Consider `ordered_float::OrderedFloat` for floating-point comparisons +- Use `#[serde(with = "chrono::serde::ts_seconds")]` for compact serialization diff --git a/src/models/org_model.rs b/src/models/org_model.rs new file mode 100644 index 0000000..fddf524 --- /dev/null +++ b/src/models/org_model.rs @@ -0,0 +1,12 @@ +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use sqlx::FromRow; +use uuid::Uuid; + +#[derive(Debug, Clone, Serialize, Deserialize, FromRow)] +pub struct organization { + pub org_id: Uuid, + pub name: String, + pub slug: String, + pub created_at: DateTime, +} diff --git a/src/services/llm_local.rs b/src/services/llm_local.rs index 05ca382..b1add2b 100644 --- a/src/services/llm_local.rs +++ b/src/services/llm_local.rs @@ -215,9 +215,8 @@ async fn start_llm_server( info!("Model path: {}", model_path.display()); // Use absolute paths and proper process management - let mut cmd = Command::new("numactl"); - cmd.arg("--interleave=all") - .arg(executable_path) + let mut cmd = Command::new(executable_path); + cmd.arg("-m") .arg("-m") .arg(model_path) .arg("--host") @@ -316,10 +315,8 @@ async fn start_embedding_server( info!("Model path: {}", model_path.display()); // Use absolute paths and proper process management - let mut cmd = Command::new("numactl"); - cmd.arg("--interleave=all") - .arg(executable_path) - .arg("-m") + let mut cmd = Command::new(executable_path); + cmd.arg("-m") .arg(model_path) .arg("--host") .arg("0.0.0.0")