chore: add missing files
This commit is contained in:
parent
206c7a29ea
commit
c698f9720e
|
|
@ -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,
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
mod summarize_row;
|
||||||
|
|
@ -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"));
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue