feat: AI translation in Database (#5515)

* chore: add tranlate field type

* chore: integrate ai translate

* chore: integrate client api

* chore: implement UI
This commit is contained in:
Nathan.fooo
2024-06-12 16:32:28 +08:00
committed by GitHub
parent 815c99710e
commit 3d7a500550
74 changed files with 1833 additions and 148 deletions

View File

@ -9,4 +9,5 @@ edition = "2021"
lib-infra = { workspace = true }
collab-entity = { workspace = true }
collab = { workspace = true }
anyhow.workspace = true
anyhow.workspace = true
client-api = { workspace = true }

View File

@ -1,4 +1,5 @@
use anyhow::Error;
pub use client_api::entity::ai_dto::{TranslateItem, TranslateRowResponse};
use collab::core::collab::DataSource;
use collab_entity::CollabType;
use lib_infra::future::FutureResult;
@ -6,6 +7,7 @@ use std::collections::HashMap;
pub type CollabDocStateByOid = HashMap<String, DataSource>;
pub type SummaryRowContent = HashMap<String, String>;
pub type TranslateRowContent = Vec<TranslateItem>;
/// A trait for database cloud service.
/// Each kind of server should implement this trait. Check out the [AppFlowyServerProvider] of
/// [flowy-server] crate for more information.
@ -39,6 +41,13 @@ pub trait DatabaseCloudService: Send + Sync {
object_id: &str,
summary_row: SummaryRowContent,
) -> FutureResult<String, Error>;
fn translate_database_row(
&self,
workspace_id: &str,
translate_row: TranslateRowContent,
language: &str,
) -> FutureResult<TranslateRowResponse, Error>;
}
pub struct DatabaseSnapshot {