fix: apply cargo fmt to fix formatting issues
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
915ce58a8c
commit
4070131bb8
3 changed files with 26 additions and 16 deletions
|
|
@ -262,8 +262,7 @@ fn parse_sse_line(line: &str) -> StreamResult<Option<String>> {
|
|||
}
|
||||
|
||||
// Parse JSON delta
|
||||
let chunk: StreamChunkResponse = serde_json::from_str(data)
|
||||
.map_err(StreamError::Json)?;
|
||||
let chunk: StreamChunkResponse = serde_json::from_str(data).map_err(StreamError::Json)?;
|
||||
|
||||
// Extract content from delta
|
||||
if let Some(choice) = chunk.choices.first() {
|
||||
|
|
@ -294,7 +293,7 @@ async fn sse_bytes_to_chunks(
|
|||
|
||||
// Get response body as bytes stream
|
||||
match response.error_for_status_ref() {
|
||||
Ok(_) => {},
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
let _ = tx.send(Err(StreamError::Http(e))).await;
|
||||
return;
|
||||
|
|
@ -310,7 +309,12 @@ async fn sse_bytes_to_chunks(
|
|||
let text = match String::from_utf8(bytes.to_vec()) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
let _ = tx.send(Err(StreamError::InvalidSse(format!("Invalid UTF-8: {}", e)))).await;
|
||||
let _ = tx
|
||||
.send(Err(StreamError::InvalidSse(format!(
|
||||
"Invalid UTF-8: {}",
|
||||
e
|
||||
))))
|
||||
.await;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
|
@ -360,7 +364,8 @@ async fn sse_bytes_to_chunks(
|
|||
Some(chunk) => Some((chunk, rx)),
|
||||
None => None,
|
||||
}
|
||||
}).boxed()
|
||||
})
|
||||
.boxed()
|
||||
}
|
||||
|
||||
fn first_nonempty(text: Option<&str>) -> Option<String> {
|
||||
|
|
@ -691,7 +696,8 @@ impl Provider for OpenAiCompatibleProvider {
|
|||
"{} API key not set",
|
||||
provider_name
|
||||
)))
|
||||
}).boxed();
|
||||
})
|
||||
.boxed();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -727,7 +733,9 @@ impl Provider for OpenAiCompatibleProvider {
|
|||
|
||||
// Apply auth header
|
||||
req_builder = match &auth_header {
|
||||
AuthStyle::Bearer => req_builder.header("Authorization", format!("Bearer {}", api_key)),
|
||||
AuthStyle::Bearer => {
|
||||
req_builder.header("Authorization", format!("Bearer {}", api_key))
|
||||
}
|
||||
AuthStyle::XApiKey => req_builder.header("x-api-key", &api_key),
|
||||
AuthStyle::Custom(header) => req_builder.header(header, &api_key),
|
||||
};
|
||||
|
|
@ -751,7 +759,9 @@ impl Provider for OpenAiCompatibleProvider {
|
|||
Ok(e) => e,
|
||||
Err(_) => format!("HTTP error: {}", status),
|
||||
};
|
||||
let _ = tx.send(Err(StreamError::Provider(format!("{}: {}", status, error)))).await;
|
||||
let _ = tx
|
||||
.send(Err(StreamError::Provider(format!("{}: {}", status, error))))
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -770,7 +780,8 @@ impl Provider for OpenAiCompatibleProvider {
|
|||
Some(chunk) => Some((chunk, rx)),
|
||||
None => None,
|
||||
}
|
||||
}).boxed()
|
||||
})
|
||||
.boxed()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -402,15 +402,17 @@ impl Provider for ReliableProvider {
|
|||
Some(chunk) => Some((chunk, rx)),
|
||||
None => None,
|
||||
}
|
||||
}).boxed();
|
||||
})
|
||||
.boxed();
|
||||
}
|
||||
|
||||
// No streaming support available
|
||||
stream::once(async move {
|
||||
Err(super::traits::StreamError::Provider(
|
||||
"No provider supports streaming".to_string()
|
||||
"No provider supports streaming".to_string(),
|
||||
))
|
||||
}).boxed()
|
||||
})
|
||||
.boxed()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -327,10 +327,7 @@ pub trait Provider: Send + Sync {
|
|||
let provider_name = "unknown".to_string();
|
||||
|
||||
// Create a single empty chunk to indicate not supported
|
||||
let chunk = StreamChunk::error(format!(
|
||||
"{} does not support streaming",
|
||||
provider_name
|
||||
));
|
||||
let chunk = StreamChunk::error(format!("{} does not support streaming", provider_name));
|
||||
stream::once(async move { Ok(chunk) }).boxed()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue