diff --git a/libs/shared-entity/src/dto/ai_dto.rs b/libs/shared-entity/src/dto/ai_dto.rs new file mode 100644 index 00000000..94209d17 --- /dev/null +++ b/libs/shared-entity/src/dto/ai_dto.rs @@ -0,0 +1,29 @@ +use serde::{Deserialize, Serialize}; +use serde_json::{Map, Value}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct SummarizeRowParams { + pub workspace_id: String, + pub data: SummarizeRowData, +} + +/// Represents different types of content that can be used to summarize a database row. +#[derive(Clone, Debug, Serialize, Deserialize)] +pub enum SummarizeRowData { + /// Specifies the identity of the row within the database. + Identity { database_id: String, row_id: String }, + /// Content of the row provided as key-value pairs. + /// For example: + /// ```json + /// { + /// "name": "Jack", + /// "age": 25, + /// "city": "New York" + /// } + Content(Map), +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct SummarizeRowResponse { + pub text: String, +} diff --git a/tests/ai_test/mod.rs b/tests/ai_test/mod.rs new file mode 100644 index 00000000..8a5982f6 --- /dev/null +++ b/tests/ai_test/mod.rs @@ -0,0 +1 @@ +mod summarize_row; diff --git a/tests/ai_test/summarize_row.rs b/tests/ai_test/summarize_row.rs new file mode 100644 index 00000000..65a02a07 --- /dev/null +++ b/tests/ai_test/summarize_row.rs @@ -0,0 +1,22 @@ +use client_api_test_util::TestClient; +use serde_json::json; +use shared_entity::dto::ai_dto::{SummarizeRowData, SummarizeRowParams}; + +#[tokio::test] +async fn summarize_row_test() { + let test_client = TestClient::new_user().await; + let workspace_id = test_client.workspace_id().await; + + let params = SummarizeRowParams { + workspace_id: workspace_id.clone(), + data: SummarizeRowData::Content( + json!({"name": "Jack", "age": 25, "city": "New York"}) + .as_object() + .unwrap() + .clone(), + ), + }; + + let resp = test_client.api_client.summarize_row(params).await.unwrap(); + assert!(resp.text.contains("Jack")); +}