diamond-in commited on
Commit
75e762e
·
verified ·
1 Parent(s): ef98263

Update src/agent/mod.rs

Browse files
Files changed (1) hide show
  1. src/agent/mod.rs +3 -20
src/agent/mod.rs CHANGED
@@ -1,3 +1,4 @@
 
1
  use axum::{extract::State, Json};
2
  use serde_json::json;
3
  use std::sync::Arc;
@@ -7,24 +8,6 @@ pub async fn chat_handler(
7
  State(state): State<Arc<AppState>>,
8
  Json(payload): Json<serde_json::Value>
9
  ) -> Json<serde_json::Value> {
10
- let user_msg = payload["message"].as_str().unwrap_or("");
11
- let api_key = std::env::var("GEMINI_API_KEY").expect("Missing GEMINI_API_KEY");
12
-
13
- let client = reqwest::Client::new();
14
- let response = client.post(format!("https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent?key={}", api_key))
15
- .json(&json!({
16
- "contents": [{ "parts": [{ "text": user_msg }] }]
17
- }))
18
- .send()
19
- .await;
20
-
21
- if let Ok(res) = response {
22
- let body: serde_json::Value = res.json().await.unwrap();
23
- let ai_text = body["candidates"][0]["content"]["parts"][0]["text"].as_str().unwrap_or("Error");
24
-
25
- // Send log to UI via SSE
26
- let _ = state.tx.send(json!({"type": "log", "data": ai_text}).to_string());
27
- }
28
-
29
- Json(json!({"status": "sent"}))
30
  }
 
1
+ pub mod executor;
2
  use axum::{extract::State, Json};
3
  use serde_json::json;
4
  use std::sync::Arc;
 
8
  State(state): State<Arc<AppState>>,
9
  Json(payload): Json<serde_json::Value>
10
  ) -> Json<serde_json::Value> {
11
+ let _ = state.tx.send(json!({"type": "log", "data": "Agent is thinking..."}).to_string());
12
+ Json(json!({"status": "ok"}))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }