-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
150 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
mod summarize_test; | ||
mod tag_test; | ||
mod translate_test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use crate::appflowy_ai_client; | ||
|
||
use appflowy_ai_client::dto::{TagItem, TagRowData}; | ||
|
||
#[tokio::test] | ||
async fn translate_row_test() { | ||
let client = appflowy_ai_client(); | ||
|
||
let mut items = Vec::new(); | ||
for (key, value) in [("book name", "Atomic Habits"), ("author", "James Clear")].iter() { | ||
items.push(TagItem { | ||
title: key.to_string(), | ||
content: value.to_string(), | ||
}); | ||
} | ||
|
||
let data = TagRowData { | ||
existing_tags: vec![], | ||
items, | ||
num_tags: 3, | ||
}; | ||
|
||
let result = client.tag_row(data).await.unwrap(); | ||
assert_eq!(result.tags.len(), 3); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
mod chat_test; | ||
mod complete_text; | ||
mod summarize_row; | ||
mod tool_test; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use appflowy_ai_client::dto::{TagItem, TagRowData, TagRowParams}; | ||
use client_api_test::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.is_empty()); | ||
} | ||
#[tokio::test] | ||
async fn tag_row_test() { | ||
let test_client = TestClient::new_user().await; | ||
let workspace_id = test_client.workspace_id().await; | ||
|
||
let params = TagRowParams { | ||
workspace_id: workspace_id.clone(), | ||
data: TagRowData { | ||
existing_tags: vec![], | ||
items: vec![TagItem { | ||
title: "Atomic habits".to_string(), | ||
content: "Atomic Habits by James Clear discusses how small, consistent changes in habits can lead to significant improvements over time. The book provides strategies for building good habits and breaking bad ones, emphasizing the importance of making tiny adjustments that compound into remarkable results. Clear introduces the concepts of habit stacking, the two-minute rule, and the four laws of behavior change: making habits obvious, attractive, easy, and satisfying".to_string(), | ||
}], | ||
num_tags: 5, | ||
}, | ||
}; | ||
|
||
let resp = test_client.api_client.tag_row(params).await.unwrap(); | ||
assert_eq!(resp.tags.len(), 5); | ||
} |