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