Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion crates/agentic-core/src/cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,25 @@ pub async fn call_cloud_model(
.map(|choice| &choice.message.content)
.ok_or(CloudError::ParseError)?;

// Extract JSON from markdown code blocks if present
let clean_content = if message_content.contains("```json") {
// Extract content between ```json and ```
if let Some(json_start) = message_content.find("```json") {
let after_start = &message_content[json_start + 7..]; // Skip "```json"
if let Some(json_end) = after_start.find("```") {
after_start[..json_end].trim()
} else {
message_content
}
} else {
message_content
}
} else {
message_content
};

let atomic_note: AtomicNote =
serde_json::from_str(message_content).map_err(|_| CloudError::ParseError)?;
serde_json::from_str(clean_content).map_err(|_| CloudError::ParseError)?;

Ok(atomic_note)
}
42 changes: 42 additions & 0 deletions crates/agentic-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,48 @@ mod tests {
}
}

#[tokio::test]
async fn test_provider_detection() {
use crate::models::{LocalProvider, ModelValidator};

println!("🧪 Testing provider detection system...");

let validator = ModelValidator::new();

// Test provider detection for common endpoints
let ollama_provider = validator.detect_provider_type("localhost:11434").await;
let lmstudio_provider = validator.detect_provider_type("localhost:1234").await;
let custom_provider = validator.detect_provider_type("localhost:8080").await;

println!("Provider detection results:");
println!(" Ollama (11434): {:?}", ollama_provider);
println!(" LM Studio (1234): {:?}", lmstudio_provider);
println!(" Custom (8080): {:?}", custom_provider);

// Test fetching local models if Ollama is available
if ollama_provider == LocalProvider::Ollama {
println!("Testing local model fetching...");
match validator.fetch_local_models("localhost:11434").await {
Ok(models) => {
println!("✅ Successfully fetched {} local models", models.len());
for model in models.iter().take(3) {
println!(" - {} ({:?}, {})", model.name, model.provider, model.size);
}
}
Err(e) => {
println!(
"⚠️ Could not fetch local models (Ollama not running): {}",
e
);
}
}
} else {
println!("⚠️ Ollama not detected, skipping local model test");
}

println!("✅ Provider detection test completed!");
}

#[test]
fn test_api_key_truncation() {
// Test the API key display formatting (simulating the settings modal function)
Expand Down
Loading