chore: remove no require data error log (#766)
* chore: remove no require data error log * chore: clippy
This commit is contained in:
parent
1d996677c1
commit
3e701a1f8b
|
|
@ -3,7 +3,9 @@ use std::sync::Arc;
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use collab::preclude::Collab;
|
use collab::preclude::Collab;
|
||||||
|
|
||||||
use collab_document::document::DocumentBody;
|
use collab_document::document::DocumentBody;
|
||||||
|
use collab_document::error::DocumentError;
|
||||||
use collab_entity::CollabType;
|
use collab_entity::CollabType;
|
||||||
|
|
||||||
use app_error::AppError;
|
use app_error::AppError;
|
||||||
|
|
@ -35,27 +37,30 @@ impl Indexer for DocumentIndexer {
|
||||||
object_id
|
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 {
|
let result = document.get_document_data(&collab.transact());
|
||||||
fragment_id: object_id.clone(),
|
match result {
|
||||||
object_id: object_id.clone(),
|
Ok(document_data) => {
|
||||||
collab_type: CollabType::Document,
|
let content = document_data.to_plain_text();
|
||||||
content_type: EmbeddingContentType::PlainText,
|
let plain_text_param = AFCollabEmbeddingParams {
|
||||||
content,
|
fragment_id: object_id.clone(),
|
||||||
embedding: None,
|
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(
|
async fn embeddings(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue