Skip to content

Commit 1403927

Browse files
chore: fix format for no diff
1 parent e06b806 commit 1403927

File tree

8 files changed

+44
-30
lines changed

8 files changed

+44
-30
lines changed

crates/openfang-api/src/openai_compat.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,15 @@ async fn stream_response(
379379

380380
let (mut rx, _handle) = state
381381
.kernel
382-
.send_message_streaming(agent_id, message, Some(kernel_handle), None, None, None, None)
382+
.send_message_streaming(
383+
agent_id,
384+
message,
385+
Some(kernel_handle),
386+
None,
387+
None,
388+
None,
389+
None,
390+
)
383391
.map_err(|e| format!("Streaming setup failed: {e}"))?;
384392

385393
let (tx, stream_rx) = tokio::sync::mpsc::channel::<Result<SseEvent, Infallible>>(64);

crates/openfang-api/src/routes.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -632,10 +632,7 @@ fn format_session_messages(session: &openfang_memory::session::Session) -> Vec<s
632632
openfang_types::message::ContentBlock::Text { text, .. } => {
633633
texts.push(text.clone());
634634
}
635-
openfang_types::message::ContentBlock::Image {
636-
media_type,
637-
data,
638-
} => {
635+
openfang_types::message::ContentBlock::Image { media_type, data } => {
639636
texts.push("[Image]".to_string());
640637
// Persist image to upload dir so it can be
641638
// served back when loading session history.
@@ -663,10 +660,7 @@ fn format_session_messages(session: &openfang_memory::session::Session) -> Vec<s
663660
}
664661
}
665662
openfang_types::message::ContentBlock::ToolUse {
666-
id,
667-
name,
668-
input,
669-
..
663+
id, name, input, ..
670664
} => {
671665
let tool_idx = tools.len();
672666
tools.push(serde_json::json!({
@@ -727,10 +721,8 @@ fn format_session_messages(session: &openfang_memory::session::Session) -> Vec<s
727721
msg.get_mut("tools").and_then(|v| v.as_array_mut())
728722
{
729723
if let Some(tool_obj) = tools_arr.get_mut(tool_idx) {
730-
tool_obj["result"] =
731-
serde_json::Value::String(result.clone());
732-
tool_obj["is_error"] =
733-
serde_json::Value::Bool(*is_error);
724+
tool_obj["result"] = serde_json::Value::String(result.clone());
725+
tool_obj["is_error"] = serde_json::Value::Bool(*is_error);
734726
}
735727
}
736728
}

crates/openfang-api/src/server.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,7 @@ pub async fn build_router(
523523
.route("/api/sessions", axum::routing::get(routes::list_sessions))
524524
.route(
525525
"/api/sessions/{id}",
526-
axum::routing::get(routes::get_session)
527-
.delete(routes::delete_session),
526+
axum::routing::get(routes::get_session).delete(routes::delete_session),
528527
)
529528
.route(
530529
"/api/sessions/{id}/label",

crates/openfang-api/src/ws.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,10 @@ async fn handle_text_message(
492492
.and_then(|s| s.parse::<uuid::Uuid>().ok())
493493
.map(openfang_types::agent::SessionId)
494494
.unwrap_or_else(|| {
495-
state.kernel.registry.get(agent_id)
495+
state
496+
.kernel
497+
.registry
498+
.get(agent_id)
496499
.map(|e| e.session_id)
497500
.unwrap_or_else(|| openfang_types::agent::SessionId(uuid::Uuid::nil()))
498501
});

crates/openfang-api/tests/api_integration_test.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ async fn test_specific_session_messaging() {
354354
.send()
355355
.await
356356
.unwrap();
357-
357+
358358
assert_eq!(resp.status(), 200);
359359
let body: serde_json::Value = resp.json().await.unwrap();
360360
let response_text = body["response"].as_str().unwrap();
@@ -369,10 +369,13 @@ async fn test_specific_session_messaging() {
369369
.send()
370370
.await
371371
.unwrap();
372-
372+
373373
assert_eq!(resp.status(), 200);
374374
let session_body: serde_json::Value = resp.json().await.unwrap();
375-
assert_eq!(session_body["session_id"].as_str().unwrap(), custom_session_id);
375+
assert_eq!(
376+
session_body["session_id"].as_str().unwrap(),
377+
custom_session_id
378+
);
376379
assert_eq!(session_body["agent_id"].as_str().unwrap(), agent_id);
377380
assert!(session_body["message_count"].as_u64().unwrap() > 0);
378381
assert!(!session_body["messages"].as_array().unwrap().is_empty());
@@ -386,7 +389,7 @@ async fn test_specific_session_messaging() {
386389
.send()
387390
.await
388391
.unwrap();
389-
392+
390393
assert_eq!(resp.status(), 200);
391394
let default_session: serde_json::Value = resp.json().await.unwrap();
392395
// Default session should either be 0 or point to a different session ID

crates/openfang-kernel/src/kernel.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -881,12 +881,12 @@ impl OpenFangKernel {
881881
// Auto-detect embedding provider by checking API key env vars in
882882
// priority order. First match wins.
883883
const API_KEY_PROVIDERS: &[(&str, &str)] = &[
884-
("OPENAI_API_KEY", "openai"),
885-
("GROQ_API_KEY", "groq"),
886-
("MISTRAL_API_KEY", "mistral"),
887-
("TOGETHER_API_KEY", "together"),
884+
("OPENAI_API_KEY", "openai"),
885+
("GROQ_API_KEY", "groq"),
886+
("MISTRAL_API_KEY", "mistral"),
887+
("TOGETHER_API_KEY", "together"),
888888
("FIREWORKS_API_KEY", "fireworks"),
889-
("COHERE_API_KEY", "cohere"),
889+
("COHERE_API_KEY", "cohere"),
890890
];
891891

892892
let detected_from_key = API_KEY_PROVIDERS
@@ -1127,8 +1127,7 @@ impl OpenFangKernel {
11271127
!= entry.manifest.tool_allowlist
11281128
|| disk_manifest.tool_blocklist
11291129
!= entry.manifest.tool_blocklist
1130-
|| disk_manifest.skills
1131-
!= entry.manifest.skills
1130+
|| disk_manifest.skills != entry.manifest.skills
11321131
|| disk_manifest.mcp_servers
11331132
!= entry.manifest.mcp_servers;
11341133
if changed {

crates/openfang-runtime/src/web_fetch.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,11 @@ mod tests {
506506
assert!(check_ssrf("http://169.254.169.254/latest/meta-data/", &allow).is_err());
507507
// Also verify hostname-based metadata blocks
508508
let allow2 = vec!["metadata.google.internal".to_string()];
509-
assert!(check_ssrf("http://metadata.google.internal/computeMetadata/v1/", &allow2).is_err());
509+
assert!(check_ssrf(
510+
"http://metadata.google.internal/computeMetadata/v1/",
511+
&allow2
512+
)
513+
.is_err());
510514
}
511515

512516
#[test]

crates/openfang-runtime/src/web_search.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,10 @@ impl WebSearchEngine {
358358

359359
let resp = self
360360
.client
361-
.get(format!("{}/search", self.config.searxng.url.trim_end_matches('/')))
361+
.get(format!(
362+
"{}/search",
363+
self.config.searxng.url.trim_end_matches('/')
364+
))
362365
.query(&[
363366
("q", query),
364367
("format", "json"),
@@ -451,7 +454,10 @@ impl WebSearchEngine {
451454

452455
let resp = self
453456
.client
454-
.get(format!("{}/config", self.config.searxng.url.trim_end_matches('/')))
457+
.get(format!(
458+
"{}/config",
459+
self.config.searxng.url.trim_end_matches('/')
460+
))
455461
.header("User-Agent", "Mozilla/5.0 (compatible; OpenFangAgent/0.1)")
456462
.send()
457463
.await

0 commit comments

Comments
 (0)