Make SafetyRatings option in Candidates

This commit is contained in:
2024-04-25 14:45:31 +01:00
parent 5fde27b70d
commit 9754618153
2 changed files with 8 additions and 4 deletions

View File

@@ -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();
cloned_queue.push(Some(response));
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) => {

View File

@@ -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>,
}