Make SafetyRatings option in Candidates
This commit is contained in:
@@ -69,9 +69,13 @@ impl<T: TokenProvider + Clone> GeminiClient<T> {
|
||||
match event {
|
||||
Ok(event) => {
|
||||
if let Event::Message(event) = event {
|
||||
let response: GenerateContentResponse =
|
||||
serde_json::from_str(&event.data).unwrap();
|
||||
let response: serde_json::error::Result<GenerateContentResponse> =
|
||||
serde_json::from_str(&event.data);
|
||||
if let Ok(response) = response {
|
||||
cloned_queue.push(Some(response));
|
||||
} else {
|
||||
tracing::error!("Error parsing message: {}", event.data);
|
||||
};
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
|
||||
@@ -48,7 +48,7 @@ pub struct GenerationConfig {
|
||||
pub struct Candidate {
|
||||
pub content: Option<Content>,
|
||||
pub citation_metadata: Option<CitationMetadata>,
|
||||
pub safety_ratings: Vec<SafetyRating>,
|
||||
pub safety_ratings: Option<Vec<SafetyRating>>,
|
||||
pub finish_reason: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user