-
-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathapi_aily_aily_session_create.go
More file actions
94 lines (83 loc) · 5.03 KB
/
Copy pathapi_aily_aily_session_create.go
File metadata and controls
94 lines (83 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Code generated by lark_sdk_gen. DO NOT EDIT.
/**
* Copyright 2022 chyroc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package lark
import (
"context"
)
// CreateAilySession 该 API 用于创建与某个飞书 Aily 应用的一次会话(Session);当创建会话成功后, 可以发送消息、创建运行。
//
// 更多信息及示例代码, 可参考 [Aily OpenAPI 接入与接口说明](https://bytedance.larkoffice.com/wiki/UTU6wVTVGigefykjO1acAOOvnNc)。
// ## 实体概念说明
// - 会话(Session): 管理用户与 Aily 助手之间的交互会话;每次会话记录了用户发送给 Aily 助手的消息以及 Aily 助手的响应。
// - 消息(Message): 消息可以包含文本、表格、图片等多种类型的内容。
// - 运行(Run): Aily 助手基于会话内消息进行意图判定、调用匹配的技能, 并返回技能执行后的结果消息。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/aily-v1/aily_session/create
// new doc: https://open.feishu.cn/document/aily-v1/aily_session/create
func (r *AilyService) CreateAilySession(ctx context.Context, request *CreateAilySessionReq, options ...MethodOptionFunc) (*CreateAilySessionResp, *Response, error) {
if r.cli.mock.mockAilyCreateAilySession != nil {
r.cli.Log(ctx, LogLevelDebug, "[lark] Aily#CreateAilySession mock enable")
return r.cli.mock.mockAilyCreateAilySession(ctx, request, options...)
}
req := &RawRequestReq{
Scope: "Aily",
API: "CreateAilySession",
Method: "POST",
URL: r.cli.openBaseURL + "/open-apis/aily/v1/sessions",
Body: request,
MethodOption: newMethodOption(options),
NeedTenantAccessToken: true,
NeedUserAccessToken: true,
}
resp := new(createAilySessionResp)
response, err := r.cli.RawRequest(ctx, req, resp)
return resp.Data, response, err
}
// MockAilyCreateAilySession mock AilyCreateAilySession method
func (r *Mock) MockAilyCreateAilySession(f func(ctx context.Context, request *CreateAilySessionReq, options ...MethodOptionFunc) (*CreateAilySessionResp, *Response, error)) {
r.mockAilyCreateAilySession = f
}
// UnMockAilyCreateAilySession un-mock AilyCreateAilySession method
func (r *Mock) UnMockAilyCreateAilySession() {
r.mockAilyCreateAilySession = nil
}
// CreateAilySessionReq ...
type CreateAilySessionReq struct {
XAilyBizUserID *string `header:"X-Aily-BizUserID" json:"-"` // 唯一用户身份标识。> 建议使用唯一内部 ID 或其他可标识用户唯一身份的字段(如飞书账号的 `user_id`), 可用于分析来自 API 的具体用户示例值: "ou_5ad573a6411d72b8305fda3a9c15c70e" 长度范围: `0` ~ `255` 字符
ChannelContext *string `json:"channel_context,omitempty"` // 可自行构造的 Context [上下文变量](https://aily.feishu.cn/hc/1u7kleqg/en70bqqj#6a446d5e);在 Workflow 技能中可消费这部分全局变量示例值: "{}" 长度范围: `0` ~ `255` 字符
Metadata *string `json:"metadata,omitempty"` // 会话的自定义变量内容, 变量数据保存在服务端 Session 中, 可在 `GetSession` 时原样返回, 无需在 API 调用侧存储示例值: "{}" 长度范围: `0` ~ `255` 字符
}
// CreateAilySessionResp ...
type CreateAilySessionResp struct {
Session *CreateAilySessionRespSession `json:"session,omitempty"` // 创建的会话信息
}
// CreateAilySessionRespSession ...
type CreateAilySessionRespSession struct {
ID string `json:"id,omitempty"` // 会话 ID
CreatedAt string `json:"created_at,omitempty"` // 会话的创建时间, 毫秒时间戳
ModifiedAt string `json:"modified_at,omitempty"` // 会话的上次更新时间, 毫秒时间戳
CreatedBy string `json:"created_by,omitempty"` // 会话的创建人(Aily UserID)
ChannelContext string `json:"channel_context,omitempty"` // 可自行构造的 Context [上下文变量](https://aily.feishu.cn/hc/1u7kleqg/en70bqqj#6a446d5e);在 Workflow 技能中可消费这部分全局变量
Metadata string `json:"metadata,omitempty"` // 会话的自定义变量内容, 变量数据保存在服务端 Session 中, 可在 `GetSession` 时原样返回, 无需在 API 调用侧存储
}
// createAilySessionResp ...
type createAilySessionResp struct {
Code int64 `json:"code,omitempty"` // 错误码, 非 0 表示失败
Msg string `json:"msg,omitempty"` // 错误描述
Data *CreateAilySessionResp `json:"data,omitempty"`
Error *ErrorDetail `json:"error,omitempty"`
}