chore: add missing files

This commit is contained in:
Zack Fu Zi Xiang 2024-04-29 23:37:18 +08:00
parent 206c7a29ea
commit c698f9720e
No known key found for this signature in database
3 changed files with 52 additions and 0 deletions

View File

@ -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<String, Value>),
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SummarizeRowResponse {
pub text: String,
}

1
tests/ai_test/mod.rs Normal file
View File

@ -0,0 +1 @@
mod summarize_row;

View File

@ -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"));
}