mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: Implement summary field for database row (#5246)
* chore: impl summary field * chore: draft ui * chore: add summary event * chore: impl desktop ui * chore: impl mobile ui * chore: update test * chore: disable ai test
This commit is contained in:
@ -1,14 +1,18 @@
|
||||
use anyhow::Error;
|
||||
use client_api::entity::ai_dto::{SummarizeRowData, SummarizeRowParams};
|
||||
use client_api::entity::QueryCollabResult::{Failed, Success};
|
||||
use client_api::entity::{QueryCollab, QueryCollabParams};
|
||||
use client_api::error::ErrorCode::RecordNotFound;
|
||||
use collab::core::collab::DataSource;
|
||||
use collab::entity::EncodedCollab;
|
||||
use collab_entity::CollabType;
|
||||
use serde_json::{Map, Value};
|
||||
use std::sync::Arc;
|
||||
use tracing::{error, instrument};
|
||||
|
||||
use flowy_database_pub::cloud::{CollabDocStateByOid, DatabaseCloudService, DatabaseSnapshot};
|
||||
use flowy_database_pub::cloud::{
|
||||
CollabDocStateByOid, DatabaseCloudService, DatabaseSnapshot, SummaryRowContent,
|
||||
};
|
||||
use lib_infra::future::FutureResult;
|
||||
|
||||
use crate::af_cloud::define::ServerUser;
|
||||
@ -119,4 +123,26 @@ where
|
||||
) -> FutureResult<Vec<DatabaseSnapshot>, Error> {
|
||||
FutureResult::new(async move { Ok(vec![]) })
|
||||
}
|
||||
|
||||
fn summary_database_row(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
_object_id: &str,
|
||||
summary_row: SummaryRowContent,
|
||||
) -> FutureResult<String, Error> {
|
||||
let workspace_id = workspace_id.to_string();
|
||||
let try_get_client = self.inner.try_get_client();
|
||||
FutureResult::new(async move {
|
||||
let map: Map<String, Value> = summary_row
|
||||
.into_iter()
|
||||
.map(|(key, value)| (key, Value::String(value)))
|
||||
.collect();
|
||||
let params = SummarizeRowParams {
|
||||
workspace_id,
|
||||
data: SummarizeRowData::Content(map),
|
||||
};
|
||||
let data = try_get_client?.summarize_row(params).await?;
|
||||
Ok(data.text)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,9 @@ use collab_entity::define::{DATABASE, DATABASE_ROW_DATA, WORKSPACE_DATABASES};
|
||||
use collab_entity::CollabType;
|
||||
use yrs::{Any, MapPrelim};
|
||||
|
||||
use flowy_database_pub::cloud::{CollabDocStateByOid, DatabaseCloudService, DatabaseSnapshot};
|
||||
use flowy_database_pub::cloud::{
|
||||
CollabDocStateByOid, DatabaseCloudService, DatabaseSnapshot, SummaryRowContent,
|
||||
};
|
||||
use lib_infra::future::FutureResult;
|
||||
|
||||
pub(crate) struct LocalServerDatabaseCloudServiceImpl();
|
||||
@ -73,4 +75,14 @@ impl DatabaseCloudService for LocalServerDatabaseCloudServiceImpl {
|
||||
) -> FutureResult<Vec<DatabaseSnapshot>, Error> {
|
||||
FutureResult::new(async move { Ok(vec![]) })
|
||||
}
|
||||
|
||||
fn summary_database_row(
|
||||
&self,
|
||||
_workspace_id: &str,
|
||||
_object_id: &str,
|
||||
_summary_row: SummaryRowContent,
|
||||
) -> FutureResult<String, Error> {
|
||||
// TODO(lucas): local ai
|
||||
FutureResult::new(async move { Ok("".to_string()) })
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ use anyhow::Error;
|
||||
use collab_entity::CollabType;
|
||||
use tokio::sync::oneshot::channel;
|
||||
|
||||
use flowy_database_pub::cloud::{CollabDocStateByOid, DatabaseCloudService, DatabaseSnapshot};
|
||||
use flowy_database_pub::cloud::{
|
||||
CollabDocStateByOid, DatabaseCloudService, DatabaseSnapshot, SummaryRowContent,
|
||||
};
|
||||
use lib_dispatch::prelude::af_spawn;
|
||||
use lib_infra::future::FutureResult;
|
||||
|
||||
@ -94,4 +96,13 @@ where
|
||||
Ok(snapshots)
|
||||
})
|
||||
}
|
||||
|
||||
fn summary_database_row(
|
||||
&self,
|
||||
_workspace_id: &str,
|
||||
_object_id: &str,
|
||||
_summary_row: SummaryRowContent,
|
||||
) -> FutureResult<String, Error> {
|
||||
FutureResult::new(async move { Ok("".to_string()) })
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user