chore: remove no require data error log (#766)

* chore: remove no require data error log

* chore: clippy
This commit is contained in:
Nathan.fooo 2024-08-30 13:55:53 +08:00 committed by GitHub
parent 1d996677c1
commit 3e701a1f8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 19 deletions

View File

@ -3,7 +3,9 @@ use std::sync::Arc;
use anyhow::anyhow;
use async_trait::async_trait;
use collab::preclude::Collab;
use collab_document::document::DocumentBody;
use collab_document::error::DocumentError;
use collab_entity::CollabType;
use app_error::AppError;
@ -35,27 +37,30 @@ impl Indexer for DocumentIndexer {
object_id
)
})?;
let document_data = document
.get_document_data(&collab.transact())
.map_err(|err| {
anyhow!(
"Failed to get document data from collab `{}`: {}",
object_id,
err
)
})?;
let content = document_data.to_plain_text();
let plain_text_param = AFCollabEmbeddingParams {
fragment_id: object_id.clone(),
object_id: object_id.clone(),
collab_type: CollabType::Document,
content_type: EmbeddingContentType::PlainText,
content,
embedding: None,
};
let result = document.get_document_data(&collab.transact());
match result {
Ok(document_data) => {
let content = document_data.to_plain_text();
let plain_text_param = AFCollabEmbeddingParams {
fragment_id: object_id.clone(),
object_id: object_id.clone(),
collab_type: CollabType::Document,
content_type: EmbeddingContentType::PlainText,
content,
embedding: None,
};
Ok(vec![plain_text_param])
Ok(vec![plain_text_param])
},
Err(err) => {
if matches!(err, DocumentError::NoRequiredData) {
Ok(vec![])
} else {
Err(AppError::Internal(err.into()))
}
},
}
}
async fn embeddings(