Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Bitable

LarkBitableTool

Search, create, and update records in a Feishu Bitable (multi-dimensional table).

use synaptic::lark::{LarkBitableTool, LarkConfig};
use synaptic::core::Tool;
use serde_json::json;

let config = LarkConfig::new("cli_xxx", "secret_xxx");
let tool = LarkBitableTool::new(config);

// Search records
let records = tool.call(json!({
    "action": "search",
    "app_token": "bascnXxx",
    "table_id": "tblXxx",
    "filter": { "field": "Status", "value": "Pending" }
})).await?;

// Create records
let created = tool.call(json!({
    "action": "create",
    "app_token": "bascnXxx",
    "table_id": "tblXxx",
    "records": [{ "Task": "New item", "Status": "Open" }]
})).await?;

// Update a record
let updated = tool.call(json!({
    "action": "update",
    "app_token": "bascnXxx",
    "table_id": "tblXxx",
    "record_id": "recXxx",
    "fields": { "Status": "Done" }
})).await?;

Actions

ActionRequired extra fieldsDescription
searchfilter?Query records (optional field+value filter)
createrecordsCreate one or more records
updaterecord_id, fieldsUpdate fields on an existing record
deleterecord_idDelete a single record
batch_updaterecordsUpdate multiple records in one call
batch_deleterecord_idsDelete multiple records
list_tablesList all tables in the app
create_tabletable_nameCreate a new table
delete_tabletable_idDelete a table
list_fieldstable_idList all fields in a table
create_fieldtable_id, field_name, field_typeAdd a field
update_fieldtable_id, field_id, field_nameRename a field
delete_fieldtable_id, field_idDelete a field

LarkBitableLoader

Load Bitable records as Synaptic [Document]s for use in RAG pipelines or batch processing. Each row in the table becomes one Document with all field values stored in metadata.

use synaptic::lark::{LarkBitableLoader, LarkConfig};
use synaptic::core::Loader;

let config = LarkConfig::new("cli_xxx", "secret_xxx");
let loader = LarkBitableLoader::new(config, "bascnXxx", "tblXxx");

let docs = loader.load().await?;
for doc in &docs {
    println!("Record ID: {}", doc.metadata["record_id"]);
    println!("Content: {}", doc.content);
}

LarkBitableMemoryStore

Store and retrieve chat history in a Feishu Bitable table, enabling persistent multi-session conversation memory backed by Bitable.

use synaptic::lark::{LarkBitableMemoryStore, LarkConfig};
use synaptic::core::MemoryStore;

let config = LarkConfig::new("cli_xxx", "secret_xxx");
let store = LarkBitableMemoryStore::new(config, "bascnXxx", "tblXxx");

// Save messages for a session
store.add_messages("session_001", &messages).await?;

// Retrieve conversation history
let history = store.get_messages("session_001").await?;

LarkBitableCheckpointer

Persist graph state checkpoints in a Feishu Bitable table, allowing long-running StateGraph executions to be interrupted and resumed. Requires the checkpointer feature.

[dependencies]
synaptic-lark = { version = "0.4", features = ["checkpointer"] }
use synaptic::lark::{LarkBitableCheckpointer, LarkConfig};
use synaptic::graph::{CompiledGraph, RunnableConfig};

let config = LarkConfig::new("cli_xxx", "secret_xxx");
let checkpointer = LarkBitableCheckpointer::new(config, "bascnXxx", "tblXxx");

// Pass the checkpointer when compiling the graph
let graph = StateGraph::new()
    // ...add nodes and edges...
    .compile_with_checkpointer(Box::new(checkpointer));

// Resume a prior run by supplying the same thread_id
let run_config = RunnableConfig::default().with_thread_id("thread_001");
let result = graph.invoke_with_config(state, run_config).await?;

LarkBitableLlmCache

Cache LLM responses in a Feishu Bitable table to avoid redundant API calls and reduce latency for repeated prompts.

use synaptic::lark::{LarkBitableLlmCache, LarkConfig};
use synaptic::cache::CachedChatModel;
use synaptic::openai::OpenAiChatModel;

let config = LarkConfig::new("cli_xxx", "secret_xxx");
let cache = LarkBitableLlmCache::new(config, "bascnXxx", "tblXxx");

let base_model = OpenAiChatModel::from_env();
let model = CachedChatModel::new(base_model, cache);

// Identical prompts are served from Bitable on the second call
let response = model.chat(request).await?;