Skip to content

Commit e2e9060

Browse files
committed
✨ feat: 实现飞书智能伙伴创建平台 aily-v1 API
全面实现飞书智能伙伴创建平台(aily)的完整功能模块: 🤖 会话管理 (4个API) - create_session() - 创建智能伙伴会话 - update_session() - 更新会话信息 - get_session() - 获取会话详情 - delete_session() - 删除会话 💬 消息管理 (3个API) - create_message() - 发送消息到智能伙伴 - get_message() - 获取消息详情 - list_messages() - 查询消息列表 ⚡ 运行管理 (4个API) - create_run() - 创建智能伙伴运行 - get_run() - 获取运行详情 - list_runs() - 查询运行列表 - cancel_run() - 取消运行 🛠️ 技能管理 (3个API) - start_skill() - 调用技能 - get_skill() - 获取技能信息 - list_skills() - 查询技能列表 🧠 知识问答 (7个API) - ask_data_knowledge() - 执行数据知识问答 - upload_file() - 上传文件用于数据知识管理 - create_data_knowledge() - 创建数据知识 - get_data_knowledge() - 获取数据知识 - delete_data_knowledge() - 删除数据知识 - list_data_knowledge() - 查询数据知识列表 - list_data_knowledge_categories() - 获取数据知识分类列表 🏗️ 架构优化 - 实现模块化的服务架构 - 集成到主LarkClient客户端 - 创建完整的数据模型和类型定义 - 统一的错误处理和响应格式 📋 示例和文档 - 新增aily_v1_example.rs演示所有功能 - 完整的使用方法和错误处理示例 - 更新项目配置支持新功能 🔧 配置更新 - 更新依赖管理使用dotenvy替代dotenv - 补充文档API链接(hire-v1, okr-v1) - 优化示例代码规范
1 parent 8d612e1 commit e2e9060

File tree

15 files changed

+2122
-4
lines changed

15 files changed

+2122
-4
lines changed

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ docs/apis 目录下是接口文档链接地址
1818

1919
生成代码后, 先格式化, 再代码检查
2020

21-
examples 需要用 dotenv 读取 本地.env配置
21+
examples 需要用 dotenvy 读取 本地.env配置
2222

2323
在 examples/api目录下, 建立每个接口的单独example
2424

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ path = "examples/api/application_demo.rs"
263263
name = "ai_comprehensive"
264264
path = "examples/api/ai_comprehensive.rs"
265265

266+
[[example]]
267+
name = "aily_v1_example"
268+
path = "examples/api/aily_v1_example.rs"
269+
266270
# ===========================================
267271
# Benchmarks
268272
# ===========================================

docs/apis/hire-v1.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,115 @@
227227
[获取 Offer 信息](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/offer/offer)
228228
[获取 Offer 详情](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/offer/get)
229229
[获取 Offer 列表](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/offer/list)
230+
[更新 Offer 状态](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/offer/offer_status)
231+
[更新实习 Offer 入/离职状态](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/offer/intern_offer_status)
232+
233+
##### 事件
234+
235+
[Offer 状态变更](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/offer/events/status_changed)
236+
237+
#### 背调
238+
239+
[获取背调信息列表](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/background_check_order/list)
240+
241+
#### 三方协议
242+
243+
[创建三方协议](https://open.feishu.cn/document/hire-v1/candidate-management/delivery-process-management/tripartite_agreement/create)
244+
[获取三方协议](https://open.feishu.cn/document/hire-v1/candidate-management/delivery-process-management/tripartite_agreement/list)
245+
[更新三方协议](https://open.feishu.cn/document/hire-v1/candidate-management/delivery-process-management/tripartite_agreement/update)
246+
[删除三方协议](https://open.feishu.cn/document/hire-v1/candidate-management/delivery-process-management/tripartite_agreement/delete)
247+
248+
#### 入职
249+
250+
[更新 e-HR 导入任务结果](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/onboard/patch-2)
251+
[操作候选人入职](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/onboard/transfer_onboard)
252+
[取消候选人入职](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/onboard/cancel_onboard)
253+
[更新员工状态](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/onboard/patch)
254+
[通过投递 ID 获取入职信息](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/onboard/get_by_application)
255+
[通过员工 ID 获取入职信息](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/onboard/get)
256+
257+
##### 事件
258+
259+
[导入 e-HR](https://open.feishu.cn/document/hire-v1/candidate-management/delivery-process-management/onboard/events/imported-2)
260+
[导入 e-HR(实习 Offer)](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/delivery-process-management/onboard/events/imported)
261+
262+
### 招聘进程跟进
263+
264+
[批量获取待办事项](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/recruitment-process-follow-up/list)
265+
[获取简历评估任务列表](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/recruitment-process-follow-up/list-3)
266+
[获取笔试阅卷任务列表](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/recruitment-process-follow-up/list-2)
267+
[获取面试任务列表](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/recruitment-process-follow-up/list-4)
268+
269+
### 备注
270+
271+
[创建备注](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/note/create)
272+
[更新备注](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/note/patch)
273+
[获取备注](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/note/get)
274+
[获取备注列表](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/note/list)
275+
[删除备注](https://open.feishu.cn/document/hire-v1/candidate-management/note/delete)
276+
277+
#### 简历来源
278+
279+
[获取简历来源列表](https://open.feishu.cn/document/server-docs/hire-v1/candidate-management/resume_source/list)
280+
281+
## 生态对接
282+
283+
[背调/笔试生态接入概览文档](https://open.feishu.cn/document/hire-v1/ecological-docking/summary)
284+
285+
### 账号
286+
287+
[创建账号自定义字段](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_account_custom_field/create)
288+
[更新账号自定义字段](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_account_custom_field/batch_update)
289+
[删除账号自定义字段](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_account_custom_field/batch_delete)
290+
291+
#### 事件
292+
293+
[账号绑定](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_account/events/created)
294+
295+
### 背调
296+
297+
[创建背调自定义字段](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_background_check_custom_field/create)
298+
[更新背调自定义字段](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_background_check_custom_field/batch_update)
299+
[删除背调自定义字段](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_background_check_custom_field/batch_delete)
300+
[创建背调套餐和附加调查项](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_background_check_package/create)
301+
[更新背调套餐和附加调查项](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_background_check_package/batch_update)
302+
[删除背调套餐和附加调查项](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_background_check_package/batch_delete)
303+
[更新背调订单进度](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_background_check/update_progress)
304+
[回传背调订单的最终结果](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_background_check/update_result)
305+
[终止背调订单](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_background_check/cancel)
306+
307+
#### 事件
308+
309+
[创建背调](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_background_check/events/created)
310+
[终止背调](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_background_check/events/canceled)
311+
312+
### 笔试
313+
314+
[创建试卷列表](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_exam_paper/create)
315+
[更新试卷列表](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_exam_paper/batch_update)
316+
[删除试卷列表](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_exam_paper/batch_delete)
317+
[回传笔试安排结果](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_exam/login_info)
318+
[回传笔试结果](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_exam/update_result)
319+
320+
#### 事件
321+
322+
[创建笔试](https://open.feishu.cn/document/server-docs/hire-v1/ecological-docking/eco_exam/events/created)
323+
324+
## 内推账户
325+
326+
[启用内推账户](https://open.feishu.cn/document/hire-v1/referral_account/enable)
327+
[查询内推账户](https://open.feishu.cn/document/hire-v1/referral_account/get_account_assets)
328+
[注册内推账户](https://open.feishu.cn/document/hire-v1/referral_account/create)
329+
[停用内推账户](https://open.feishu.cn/document/hire-v1/referral_account/deactivate)
330+
[全额提取内推账户余额](https://open.feishu.cn/document/hire-v1/referral_account/withdraw)
331+
[内推账户提现数据对账](https://open.feishu.cn/document/hire-v1/referral_account/reconciliation)
332+
333+
### 事件
334+
335+
[内推账户余额变更](https://open.feishu.cn/document/hire-v1/referral_account/events/assets_update)
336+
337+
## 附件
338+
339+
[创建附件](https://open.feishu.cn/document/server-docs/hire-v1/attachment/create_attachment)
340+
[获取附件信息](https://open.feishu.cn/document/server-docs/hire-v1/attachment/get)
341+
[获取附件 PDF 格式下载链接](https://open.feishu.cn/document/server-docs/hire-v1/attachment/preview)

docs/apis/okr-v1.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# OKR
2+
3+
[OKR 概述](https://open.feishu.cn/document/server-docs/okr-v1/okr-guide)
4+
5+
## OKR 周期
6+
7+
[创建 OKR 周期](https://open.feishu.cn/document/server-docs/okr-v1/period/create)
8+
[修改 OKR 周期状态](https://open.feishu.cn/document/server-docs/okr-v1/period/patch)
9+
[获取 OKR 周期列表](https://open.feishu.cn/document/server-docs/okr-v1/period/list)
10+
11+
## 周期规则
12+
13+
[获取 OKR 周期规则](https://open.feishu.cn/document/server-docs/okr-v1/period_rule/list)
14+
15+
## OKR 内容
16+
17+
[获取用户的 OKR 列表](https://open.feishu.cn/document/server-docs/okr-v1/okr/list)
18+
[批量获取 OKR](https://open.feishu.cn/document/server-docs/okr-v1/okr/batch_get)
19+
20+
## OKR 进展记录
21+
22+
[创建 OKR 进展记录](https://open.feishu.cn/document/server-docs/okr-v1/progress_record/create)
23+
[删除 OKR 进展记录](https://open.feishu.cn/document/server-docs/okr-v1/progress_record/delete)
24+
[更新 OKR 进展记录](https://open.feishu.cn/document/server-docs/okr-v1/progress_record/update)
25+
[获取 OKR 进展记录](https://open.feishu.cn/document/server-docs/okr-v1/progress_record/get)
26+
[上传进展记录图片](https://open.feishu.cn/document/server-docs/okr-v1/progress_record/upload)
27+
28+
## OKR 复盘
29+
30+
[查询复盘信息](https://open.feishu.cn/document/server-docs/okr-v1/review/query)

examples/api/aily_v1_example.rs

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
use dotenvy::dotenv;
2+
use open_lark::prelude::*;
3+
use std::env;
4+
5+
#[tokio::main]
6+
async fn main() -> SDKResult<()> {
7+
dotenv().ok();
8+
9+
let app_id = env::var("APP_ID").expect("APP_ID is required");
10+
let app_secret = env::var("APP_SECRET").expect("APP_SECRET is required");
11+
12+
let client = LarkClient::builder(&app_id, &app_secret)
13+
.with_app_type(AppType::SelfBuild)
14+
.with_enable_token_cache(true)
15+
.build();
16+
17+
// 示例应用ID(实际使用时需要替换为真实的智能伙伴应用ID)
18+
let aily_app_id = "your_aily_app_id".to_string();
19+
20+
println!("=== 飞书智能伙伴创建平台 API 示例 ===\n");
21+
22+
// 1. 会话管理示例
23+
println!("1. 创建智能伙伴会话");
24+
let session_request = open_lark::service::aily::models::SessionCreateRequest {
25+
app_id: aily_app_id.clone(),
26+
metadata: None,
27+
tool_set: None,
28+
};
29+
30+
match client
31+
.aily
32+
.session
33+
.create_session(session_request, None)
34+
.await
35+
{
36+
Ok(response) => {
37+
println!("创建会话成功: {:?}", response);
38+
let session_id = "demo_session_id".to_string(); // 使用示例会话ID
39+
40+
// 2. 消息管理示例
41+
println!("\n2. 发送消息到智能伙伴");
42+
let message_request = open_lark::service::aily::models::MessageCreateRequest {
43+
app_id: aily_app_id.clone(),
44+
session_id: session_id.clone(),
45+
content: "你好,请帮我分析一下市场趋势".to_string(),
46+
message_type: Some("text".to_string()),
47+
metadata: None,
48+
};
49+
50+
match client
51+
.aily
52+
.message
53+
.create_message(message_request, None)
54+
.await
55+
{
56+
Ok(msg_response) => {
57+
println!("发送消息成功: {:?}", msg_response);
58+
59+
// 3. 运行管理示例
60+
println!("\n3. 创建智能伙伴运行");
61+
let run_request = open_lark::service::aily::models::RunCreateRequest {
62+
app_id: aily_app_id.clone(),
63+
session_id: session_id.clone(),
64+
instructions: Some("请基于用户问题进行详细分析".to_string()),
65+
model: Some("your_model_name".to_string()),
66+
additional_messages: None,
67+
tool_set: None,
68+
};
69+
70+
match client.aily.run.create_run(run_request, None).await {
71+
Ok(run_response) => {
72+
println!("创建运行成功: {:?}", run_response);
73+
let _run_id = "demo_run_id".to_string(); // 使用示例运行ID
74+
75+
// 4. 技能管理示例
76+
println!("\n4. 查询可用技能列表");
77+
let skill_list_request =
78+
open_lark::service::aily::models::SkillListRequest {
79+
app_id: aily_app_id.clone(),
80+
page_size: Some(10),
81+
page_token: None,
82+
};
83+
84+
match client
85+
.aily
86+
.skill
87+
.list_skills(skill_list_request, None)
88+
.await
89+
{
90+
Ok(skills_response) => {
91+
println!("技能列表查询成功: {:?}", skills_response);
92+
}
93+
Err(e) => {
94+
println!("技能列表查询失败: {:?}", e);
95+
}
96+
}
97+
98+
// 5. 知识问答示例
99+
println!("\n5. 执行数据知识问答");
100+
let knowledge_ask_request =
101+
open_lark::service::aily::models::DataKnowledgeAskRequest {
102+
app_id: aily_app_id.clone(),
103+
question: "什么是人工智能?".to_string(),
104+
knowledge_base_ids: Some(vec!["kb_001".to_string()]),
105+
chat_history: None,
106+
retrieval_config: None,
107+
};
108+
109+
match client
110+
.aily
111+
.knowledge
112+
.ask_data_knowledge(knowledge_ask_request, None)
113+
.await
114+
{
115+
Ok(knowledge_response) => {
116+
println!("知识问答成功: {:?}", knowledge_response);
117+
}
118+
Err(e) => {
119+
println!("知识问答失败: {:?}", e);
120+
}
121+
}
122+
123+
// 6. 查询会话信息
124+
println!("\n6. 查询会话信息");
125+
let session_get_request =
126+
open_lark::service::aily::models::SessionGetRequest {
127+
app_id: aily_app_id.clone(),
128+
session_id: session_id.clone(),
129+
};
130+
131+
match client
132+
.aily
133+
.session
134+
.get_session(session_get_request, None)
135+
.await
136+
{
137+
Ok(session_response) => {
138+
println!("查询会话成功: {:?}", session_response);
139+
}
140+
Err(e) => {
141+
println!("查询会话失败: {:?}", e);
142+
}
143+
}
144+
}
145+
Err(e) => {
146+
println!("创建运行失败: {:?}", e);
147+
}
148+
}
149+
}
150+
Err(e) => {
151+
println!("发送消息失败: {:?}", e);
152+
}
153+
}
154+
}
155+
Err(e) => {
156+
println!("创建会话失败: {:?}", e);
157+
}
158+
}
159+
160+
println!("\n=== 智能伙伴 API 示例完成 ===");
161+
Ok(())
162+
}

examples/api/apass_example.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use open_lark::{
22
prelude::*,
33
service::apass::models::{
4-
AuditLogListRequest, FlowExecuteRequest, FunctionInvokeRequest, RecordSearchRequest,
5-
RecordQueryRequest, SeatActivityListRequest, SeatAssignmentListRequest, UserTaskQueryRequest,
6-
EnvironmentVariableQueryRequest,
4+
AuditLogListRequest, EnvironmentVariableQueryRequest, FlowExecuteRequest,
5+
FunctionInvokeRequest, RecordQueryRequest, RecordSearchRequest, SeatActivityListRequest,
6+
SeatAssignmentListRequest, UserTaskQueryRequest,
77
},
88
};
99
use serde_json::json;

src/client/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::{
44
core::{config::Config, constants::AppType},
55
service::{
66
ai::AiService,
7+
aily::AilyService,
78
apass::ApassService,
89
application::ApplicationService,
910
approval::ApprovalService,
@@ -47,6 +48,7 @@ pub struct LarkClient {
4748
pub config: Config,
4849
// 核心服务
4950
pub ai: AiService,
51+
pub aily: AilyService,
5052
pub apass: ApassService,
5153
pub application: ApplicationService,
5254
pub approval: ApprovalService,
@@ -130,6 +132,7 @@ impl LarkClientBuilder {
130132
config: self.config.clone(),
131133
// 核心服务
132134
ai: AiService::new((*config).clone()),
135+
aily: AilyService::new((*config).clone()),
133136
apass: ApassService::new((*config).clone()),
134137
application: ApplicationService::new((*config).clone()),
135138
approval: ApprovalService::new((*config).clone()),

0 commit comments

Comments
 (0)