Skip to content

Commit fb4180d

Browse files
Fix/rust sdk (#56)
* feat(sdk-rust): add end-to-end example for TinyHumansMemoryClient - Introduced a new example script `example_e2e.rs` demonstrating the usage of the TinyHumansMemoryClient. - Implemented various steps including memory insertion, job checking, document listing, and querying memory. - Enhanced logging for better traceability during the execution of the example. - Updated `list_documents` method to accept parameters for namespace, limit, and offset, improving flexibility in document retrieval. * fix(sdk-rust): clean up whitespace and ensure newline at end of file - Removed unnecessary whitespace in `example_e2e.rs` for cleaner code. - Added a newline at the end of `example_e2e.rs` to adhere to file formatting standards. - Reformatted error message in `lib.rs` for better readability in validation checks. * fix(sdk-rust): update example scripts for improved functionality - Updated `example_e2e.rs` to correctly utilize the document ID in memory operations, ensuring all steps are executed. - Enhanced `test_routes.rs` to include parameters for the `list_documents` method, allowing for better control over document retrieval.
1 parent 27ddec1 commit fb4180d

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

packages/sdk-rust/examples/example_e2e.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ async fn main() {
178178
.map(|d| d.as_millis())
179179
.unwrap_or(0);
180180
let namespace = "sdk-rust-e2e".to_string();
181-
let single_doc_id = format!("sdk-rust-e2e-doc-single-{ts}");
181+
let _single_doc_id = format!("sdk-rust-e2e-doc-single-{ts}");
182182

183183
let result = async {
184-
// let insert_job_id = step1_insert_memory(&client, &namespace, &single_doc_id).await?;
185-
// step2_check_ingestion_job(&client, &insert_job_id).await?;
184+
let insert_job_id = step1_insert_memory(&client, &namespace, &single_doc_id).await?;
185+
step2_check_ingestion_job(&client, &insert_job_id).await?;
186186
step3_list_documents(&client, &namespace).await?;
187-
// step4_get_document(&client, &namespace, &single_doc_id).await?;
187+
step4_get_document(&client, &namespace, &single_doc_id).await?;
188188

189189
if let Err(err) = step5_query_memory(&client, &namespace).await {
190190
eprintln!("[warn] step5 queryMemory skipped: {err}");

packages/sdk-rust/examples/test_routes.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use std::time::{SystemTime, UNIX_EPOCH};
44

55
use tinyhumansai::{
66
BatchDocumentItem, BatchInsertDocumentsParams, ChatMessage, DeleteMemoryParams,
7-
InsertDocumentParams, InsertMemoryParams, InteractionLevel, MemoryChatParams,
8-
MemoryConversationParams, MemoryInteractionsParams, MemoryThoughtsParams, QueryMemoriesParams,
9-
QueryMemoryParams, RecallMemoriesContextParams, RecallMemoriesParams, RecallMemoryParams,
10-
SourceType, TinyHumanConfig, TinyHumansError, TinyHumansMemoryClient,
7+
InsertDocumentParams, InsertMemoryParams, InteractionLevel, ListDocumentsParams,
8+
MemoryChatParams, MemoryConversationParams, MemoryInteractionsParams, MemoryThoughtsParams,
9+
QueryMemoriesParams, QueryMemoryParams, RecallMemoriesContextParams, RecallMemoriesParams,
10+
RecallMemoryParams, SourceType, TinyHumanConfig, TinyHumansError, TinyHumansMemoryClient,
1111
};
1212

1313
type CheckResults = Vec<(String, bool, String)>;
@@ -294,7 +294,13 @@ async fn main() {
294294
push_result(
295295
&mut results,
296296
"list_documents",
297-
client.list_documents().await,
297+
client
298+
.list_documents(ListDocumentsParams {
299+
namespace: Some(namespace.clone()),
300+
limit: Some(50.0),
301+
offset: Some(0.0),
302+
})
303+
.await,
298304
false,
299305
);
300306

0 commit comments

Comments
 (0)