From 0c98eec1f1cce892ba1686bf10d0cdc0514f152a Mon Sep 17 00:00:00 2001 From: RadeenXALNW Date: Sat, 8 Nov 2025 19:30:06 +0000 Subject: [PATCH] fix rust example ui --- examples/lead-agent/backend-rust/src/main.rs | 41 +++++++------------- examples/lead-agent/frontend/src/App.tsx | 22 +---------- examples/lead-agent/frontend/vite.config.ts | 2 +- 3 files changed, 18 insertions(+), 47 deletions(-) diff --git a/examples/lead-agent/backend-rust/src/main.rs b/examples/lead-agent/backend-rust/src/main.rs index c3a1543..ece94ff 100644 --- a/examples/lead-agent/backend-rust/src/main.rs +++ b/examples/lead-agent/backend-rust/src/main.rs @@ -9,10 +9,14 @@ use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; use tower_http::cors::{CorsLayer, AllowOrigin}; +// RunAgent configuration +const RUNAGENT_ID: &str = "93eaf000-0000-0000-0000-000000000000"; + // Request/Response types #[derive(Deserialize)] struct ScoreLeadsRequest { - agent_id: String, + #[serde(default)] + agent_id: Option, // Deprecated: kept for backward compatibility but ignored candidates: Vec, #[serde(default)] top_n: Option, @@ -26,7 +30,8 @@ struct ScoreLeadsRequest { #[derive(Deserialize)] struct ScoreSingleRequest { - agent_id: String, + #[serde(default)] + agent_id: Option, // Deprecated: kept for backward compatibility but ignored #[serde(default)] candidate_id: Option, name: String, @@ -60,16 +65,6 @@ async fn score_leads( Json(request): Json, ) -> Result, (StatusCode, JsonResponse)> { // Validate required fields - if request.agent_id.is_empty() { - return Err(( - StatusCode::BAD_REQUEST, - JsonResponse(ErrorResponse { - error: "agent_id is required".to_string(), - traceback: None, - }), - )); - } - if request.candidates.is_empty() { return Err(( StatusCode::BAD_REQUEST, @@ -111,9 +106,9 @@ async fn score_leads( println!("[DEBUG] First candidate sample: {}", serde_json::to_string(first).unwrap_or_default()); } - // Initialize RunAgent client + // Initialize RunAgent client using configured agent ID let client = match runagent::client::RunAgentClient::new( - &request.agent_id, + RUNAGENT_ID, "lead_score_flow", false, // Set to false when using RunAgent Cloud ) @@ -195,16 +190,6 @@ async fn score_single( Json(request): Json, ) -> Result, (StatusCode, JsonResponse)> { // Validate required fields - if request.agent_id.is_empty() { - return Err(( - StatusCode::BAD_REQUEST, - JsonResponse(ErrorResponse { - error: "agent_id is required".to_string(), - traceback: None, - }), - )); - } - if request.name.is_empty() { return Err(( StatusCode::BAD_REQUEST, @@ -225,9 +210,9 @@ async fn score_single( )); } - // Initialize RunAgent client + // Initialize RunAgent client using configured agent ID let client = match runagent::client::RunAgentClient::new( - &request.agent_id, + RUNAGENT_ID, "score_candidate", true, // local = true for single candidate scoring ) @@ -294,9 +279,13 @@ async fn main() -> Result<(), Box> { // Setup CORS - matching Flask backend origins let allowed_origins = vec![ "http://localhost:5173", + "http://localhost:5174", "http://127.0.0.1:5173", + "http://127.0.0.1:5174", "http://10.1.0.5:5173", + "http://10.1.0.5:5174", "http://20.84.81.110:5173", + "http://20.84.81.110:5174", ] .into_iter() .map(|s| HeaderValue::from_static(s)) diff --git a/examples/lead-agent/frontend/src/App.tsx b/examples/lead-agent/frontend/src/App.tsx index 707a2c7..505426e 100644 --- a/examples/lead-agent/frontend/src/App.tsx +++ b/examples/lead-agent/frontend/src/App.tsx @@ -42,7 +42,6 @@ interface CSVMapping { function App() { const [step, setStep] = useState<'config' | 'upload' | 'mapping' | 'processing' | 'results'>('config'); - const [agentId, setAgentId] = useState(''); const [jobDescription, setJobDescription] = useState(''); const [topN, setTopN] = useState(3); const [candidates, setCandidates] = useState([]); @@ -160,13 +159,12 @@ function App() { setError(null); try { - const response = await fetch('http://localhost:8000/api/score-leads', { + const response = await fetch('/api/score-leads', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ - agent_id: agentId, candidates: candidateList, job_description: jobDescription, top_n: topN, @@ -281,22 +279,6 @@ function App() {
-
- - setAgentId(e.target.value)} - placeholder="Enter your deployed agent ID" - className="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-transparent" - /> -

- Get this from running: runagent serve . -

-
-