chore: return no content (#523)
This commit is contained in:
parent
a9d49403ae
commit
c115414f5a
|
|
@ -1019,14 +1019,27 @@ async fn summary_row_handler(
|
|||
return Err(AppError::InvalidRequest("Identity data is not supported".to_string()).into());
|
||||
},
|
||||
SummarizeRowData::Content(content) => {
|
||||
let text = state
|
||||
.ai_client
|
||||
.summarize_row(&content)
|
||||
.await
|
||||
.map_err(|err| AppError::InvalidRequest(err.to_string()))?
|
||||
.text;
|
||||
if content.is_empty() {
|
||||
return Ok(
|
||||
AppResponse::Ok()
|
||||
.with_data(SummarizeRowResponse {
|
||||
text: "No content".to_string(),
|
||||
})
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
||||
let result = state.ai_client.summarize_row(&content).await;
|
||||
let resp = match result {
|
||||
Ok(resp) => SummarizeRowResponse { text: resp.text },
|
||||
Err(err) => {
|
||||
error!("Failed to summarize row: {:?}", err);
|
||||
SummarizeRowResponse {
|
||||
text: "No content".to_string(),
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let resp = SummarizeRowResponse { text };
|
||||
Ok(AppResponse::Ok().with_data(resp).into())
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue