@baiducloud/qianfan-ai-assistant 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +143 -0
- package/dist/628.js +9 -0
- package/dist/628.js.LICENSE.txt +5 -0
- package/dist/index.d.ts +184 -0
- package/dist/index.js +3248 -0
- package/dist/index.js.LICENSE.txt +1193 -0
- package/dist/static/image/AIAssistant.b813cb55.png +0 -0
- package/dist/static/image/IntelligentAssistButtonIcon.54af3c85.png +0 -0
- package/dist/static/image/Qianfan-SFT.47e51f85.png +0 -0
- package/dist/static/image/agentProduct.414cf560.png +0 -0
- package/dist/static/image/agentTip.19abed85.png +0 -0
- package/dist/static/image/agentTip_en.bd33769e.png +0 -0
- package/dist/static/image/aiSearchIcon.403146d3.png +0 -0
- package/dist/static/image/article.89070985.png +0 -0
- package/dist/static/image/article_en.8d473ce3.png +0 -0
- package/dist/static/image/assistantIcon.18341b85.png +0 -0
- package/dist/static/image/audioPlayingIcon.b39ab0c5.png +0 -0
- package/dist/static/image/avatar.8f67c10f.png +0 -0
- package/dist/static/image/avatarLoading.b030a37a.png +0 -0
- package/dist/static/image/background.8dfa7e1e.png +0 -0
- package/dist/static/image/baiduLogoImage.bafc6704.png +0 -0
- package/dist/static/image/chartParse.a185a82d.png +0 -0
- package/dist/static/image/checking.ac4fe451.gif +0 -0
- package/dist/static/image/chunk.49ba3a4b.png +0 -0
- package/dist/static/image/chunk_en.d81358ed.png +0 -0
- package/dist/static/image/componentLoading.22b92664.png +0 -0
- package/dist/static/image/configUpdateTip.275b98d1.png +0 -0
- package/dist/static/image/contractIcon.d0b5455e.png +0 -0
- package/dist/static/image/createAppBtn.162dea9c.png +0 -0
- package/dist/static/image/deepResearch.79157720.png +0 -0
- package/dist/static/image/defaultModelIcon.7d18a0b4.png +0 -0
- package/dist/static/image/diff_baidu_search_component.452252a9.png +0 -0
- package/dist/static/image/diff_baidu_search_component_en.abf74260.png +0 -0
- package/dist/static/image/diff_web_search_enhanced.0d021ea0.png +0 -0
- package/dist/static/image/diff_web_search_enhanced_en.096a08ce.png +0 -0
- package/dist/static/image/embedEmpty.f6b9a162.png +0 -0
- package/dist/static/image/empty.af8f6414.png +0 -0
- package/dist/static/image/errorPageIcon.a178f217.png +0 -0
- package/dist/static/image/examplePng.3f9ecee8.png +0 -0
- package/dist/static/image/examplePng_en.b2099a85.png +0 -0
- package/dist/static/image/expand_chunk_tip.54be78dc.png +0 -0
- package/dist/static/image/expand_chunk_tip_en.806e827f.png +0 -0
- package/dist/static/image/extract_qaIcon.f5115b31.webp +0 -0
- package/dist/static/image/globalLoading.1b0a8588.png +0 -0
- package/dist/static/image/graph_retrieval_augment.e323b800.png +0 -0
- package/dist/static/image/graphicTextParse.6dca1926.png +0 -0
- package/dist/static/image/graphicTextParse_en.ea5dc9e5.png +0 -0
- package/dist/static/image/h5.568460d4.png +0 -0
- package/dist/static/image/h5_en.73a39513.png +0 -0
- package/dist/static/image/h5bg.be9bc2c1.png +0 -0
- package/dist/static/image/h5bg_en.d4f72d3a.png +0 -0
- package/dist/static/image/h5text.ff0793ad.png +0 -0
- package/dist/static/image/h5text_en.0efe8704.png +0 -0
- package/dist/static/image/imageParser.698e288c.png +0 -0
- package/dist/static/image/imageParser_en.35046e28.png +0 -0
- package/dist/static/image/imgBg.7c39c418.png +0 -0
- package/dist/static/image/knowledgeGraphExtract.0dae6dec.png +0 -0
- package/dist/static/image/knowledgeGraphExtract_en.a35325c4.png +0 -0
- package/dist/static/image/knowledgeGraphSearch.49d1a192.png +0 -0
- package/dist/static/image/knowledgeGraphSearch_en.109f7e34.png +0 -0
- package/dist/static/image/latexParse.8f616793.png +0 -0
- package/dist/static/image/layoutParse.e29627b4.png +0 -0
- package/dist/static/image/layoutParse_en.e6ffd0d3.png +0 -0
- package/dist/static/image/legalIcon.fb783d65.png +0 -0
- package/dist/static/image/loading.9269e3d5.png +0 -0
- package/dist/static/image/loading_sm.9269e3d5.png +0 -0
- package/dist/static/image/mcpServer.268f266b.png +0 -0
- package/dist/static/image/modelResourceModal.d977ad06.png +0 -0
- package/dist/static/image/networkError.fadb04ee.png +0 -0
- package/dist/static/image/notAccessible.c999fa29.png +0 -0
- package/dist/static/image/notFile.5575d957.png +0 -0
- package/dist/static/image/notResult.adede446.png +0 -0
- package/dist/static/image/officialIcon.1ad58cf6.png +0 -0
- package/dist/static/image/opticalParse.13696017.png +0 -0
- package/dist/static/image/paper.ba668722.png +0 -0
- package/dist/static/image/paper_en.a21ea2da.png +0 -0
- package/dist/static/image/partialLoading.758ac358.png +0 -0
- package/dist/static/image/partialLoading.7a8f72f5.png +0 -0
- package/dist/static/image/pc.c17f13b1.png +0 -0
- package/dist/static/image/pc_en.77cab601.png +0 -0
- package/dist/static/image/pcbg.89dc1640.png +0 -0
- package/dist/static/image/pcbg_en.798ccf46.png +0 -0
- package/dist/static/image/playing.47d55c3d.gif +0 -0
- package/dist/static/image/ppt.270eddd3.png +0 -0
- package/dist/static/image/ppt_en.f833a8ac.png +0 -0
- package/dist/static/image/proxyConfig.2b425357.jpg +0 -0
- package/dist/static/image/publicAppBackground.2284be0d.png +0 -0
- package/dist/static/image/publishSuccessBg.743d171a.png +0 -0
- package/dist/static/image/publishSuccessIcon.9edabb3d.png +0 -0
- package/dist/static/image/qa-pair.0665f2b2.png +0 -0
- package/dist/static/image/qa-pair_en.43165f9c.png +0 -0
- package/dist/static/image/recording.632e18f7.gif +0 -0
- package/dist/static/image/resultBg.27c66907.png +0 -0
- package/dist/static/image/resume.9599e721.png +0 -0
- package/dist/static/image/resume_en.f1b408b6.png +0 -0
- package/dist/static/image/searchEmpty.55856809.png +0 -0
- package/dist/static/image/smallEmpty.d2603dd4.png +0 -0
- package/dist/static/image/smallErrorPageIcon.511f9769.png +0 -0
- package/dist/static/image/smallSearchEmpty.491a7f02.png +0 -0
- package/dist/static/image/table.de011169.png +0 -0
- package/dist/static/image/tableParse.09be175a.png +0 -0
- package/dist/static/image/tableParseError.407be6ec.png +0 -0
- package/dist/static/image/tableSeat.6206bbd7.png +0 -0
- package/dist/static/image/tableSeat_en.c89c3478.png +0 -0
- package/dist/static/image/table_en.ba9b8e46.png +0 -0
- package/dist/static/image/tipsIcon.84271250.png +0 -0
- package/dist/static/image/toolProduct.74798c6e.png +0 -0
- package/dist/static/image/topBg.8802aebc.png +0 -0
- package/dist/static/image/tourBack.d0f7662f.png +0 -0
- package/dist/static/image/userMaterialTip.da655c4f.png +0 -0
- package/dist/static/image/userMaterialTip_en.dd04c77a.png +0 -0
- package/dist/static/image/variableLabels.7c370d69.png +0 -0
- package/dist/static/image/variableLabels_en.9712ced6.png +0 -0
- package/dist/static/image/voice-playing.b39ab0c5.png +0 -0
- package/dist/static/image/voiceBroadcastTip.fad23e99.png +0 -0
- package/dist/static/image/voiceBroadcastTip_en.be04db17.png +0 -0
- package/dist/static/image/voiceCallTip.c8e580b5.png +0 -0
- package/dist/static/image/voiceCallTip_en.8e0bea29.png +0 -0
- package/dist/static/image/voicePhoneDefaultTip.3c2ac3f1.png +0 -0
- package/dist/static/image/voicePhoneDefaultTip_en.d0e56784.png +0 -0
- package/package.json +29 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file SDK 类型声明文件
|
|
3
|
+
* @description 仅导出用户需要的类型接口,不包含内部实现细节
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** 文件上传返回结构 */
|
|
7
|
+
export interface IFileUploadRes {
|
|
8
|
+
/** 文件id */
|
|
9
|
+
file_id: string;
|
|
10
|
+
/** 对话id */
|
|
11
|
+
conversation_id: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** 用户偏好数据 */
|
|
15
|
+
export interface IUserPreferencesData {
|
|
16
|
+
user_profile: {
|
|
17
|
+
/** 个性化指令 */
|
|
18
|
+
instructions: string;
|
|
19
|
+
/** 位置信息 */
|
|
20
|
+
location_info: {
|
|
21
|
+
province: string;
|
|
22
|
+
city: string;
|
|
23
|
+
district: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 取消请求参数 */
|
|
29
|
+
export interface IAbortRequestParams {
|
|
30
|
+
message_id: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** form data 上传成功结果 */
|
|
34
|
+
export interface IUploadedFileInfo {
|
|
35
|
+
/** 文件id */
|
|
36
|
+
file_id: string;
|
|
37
|
+
|
|
38
|
+
/** 文件路径 */
|
|
39
|
+
storage_location: string;
|
|
40
|
+
|
|
41
|
+
/** 上传结果的bos url */
|
|
42
|
+
presigned_url: string;
|
|
43
|
+
|
|
44
|
+
/** 创建/更新时间 */
|
|
45
|
+
created_at: string;
|
|
46
|
+
|
|
47
|
+
/** 文件名 */
|
|
48
|
+
filename: string;
|
|
49
|
+
|
|
50
|
+
size: number;
|
|
51
|
+
|
|
52
|
+
/** 更新时间 */
|
|
53
|
+
updated_at: string;
|
|
54
|
+
message?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** 对话文件恢复拉取接口返回 */
|
|
58
|
+
export interface ISessionHistoryFilesRes {
|
|
59
|
+
data: IUploadedFileInfo[];
|
|
60
|
+
has_more: boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** 对话消息拉取接口参数 */
|
|
64
|
+
export interface ISessionHistoryDataReq {
|
|
65
|
+
/** 应用id */
|
|
66
|
+
appId?: string;
|
|
67
|
+
/** 会话id */
|
|
68
|
+
sessionId: string;
|
|
69
|
+
/** 终端用户id */
|
|
70
|
+
end_user_id?: string;
|
|
71
|
+
/** 页码 */
|
|
72
|
+
pageNum?: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** 历史对话json数据interface */
|
|
76
|
+
export interface IHistoryChatItem {
|
|
77
|
+
role: 'user' | 'assistant';
|
|
78
|
+
/** query内容 */
|
|
79
|
+
text: string;
|
|
80
|
+
/** 文件id */
|
|
81
|
+
attachments: string[];
|
|
82
|
+
/** 完善interface */
|
|
83
|
+
content: any;
|
|
84
|
+
/** 轮次id,用于标识一轮对话 */
|
|
85
|
+
turn_id: string;
|
|
86
|
+
/** 历史消息的状态 */
|
|
87
|
+
status: 'cancelled' | 'completed' | 'failed';
|
|
88
|
+
/** 请求id */
|
|
89
|
+
request_id: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** 对话列表请求参数结构ForClientService */
|
|
93
|
+
export interface IConversationListReq {
|
|
94
|
+
agent_code: string;
|
|
95
|
+
end_user_id?: string;
|
|
96
|
+
start_time?: string;
|
|
97
|
+
end_time?: string;
|
|
98
|
+
is_truncated?: boolean;
|
|
99
|
+
page: number;
|
|
100
|
+
limit: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** 对话列表元素结构 */
|
|
104
|
+
export interface IConversationItem {
|
|
105
|
+
id: string;
|
|
106
|
+
app_id: string;
|
|
107
|
+
/** 任务状态: 运行中/已结束/已完成待查看(待查看为前端人工刷的状态,用于运行中到已完成的提醒) */
|
|
108
|
+
status: 'running' | 'completed' | 'completedPendingReview';
|
|
109
|
+
/** bce-request-id */
|
|
110
|
+
request_id: string;
|
|
111
|
+
user_id: string;
|
|
112
|
+
title: string;
|
|
113
|
+
metadata: Record<string, any>;
|
|
114
|
+
end_user_id: string;
|
|
115
|
+
external_session_id: string;
|
|
116
|
+
created_at: string;
|
|
117
|
+
updated_at: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** 会话状态条目 */
|
|
121
|
+
export interface IConversationStatus {
|
|
122
|
+
conversation_id: string;
|
|
123
|
+
status: 'running' | 'completed';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** SDK模式下的客户端服务接口 */
|
|
127
|
+
export interface IClientService {
|
|
128
|
+
/** SSE 对话流式接口 */
|
|
129
|
+
agentSpaceRun: (
|
|
130
|
+
param: any,
|
|
131
|
+
callbacks: {
|
|
132
|
+
/** 接受到消息的回调 */
|
|
133
|
+
onMessage: (message: string) => void;
|
|
134
|
+
/** 任务执行完成的回调 */
|
|
135
|
+
onCompleted: () => void;
|
|
136
|
+
/** 任务执行错误的回调 */
|
|
137
|
+
onError: (error: Error) => void;
|
|
138
|
+
},
|
|
139
|
+
options?: {
|
|
140
|
+
abortController?: AbortController;
|
|
141
|
+
headers?: HeadersInit;
|
|
142
|
+
}
|
|
143
|
+
) => void;
|
|
144
|
+
/** SSE 恢复对话接口 */
|
|
145
|
+
recoverChat: (
|
|
146
|
+
param: any,
|
|
147
|
+
callbacks: {
|
|
148
|
+
onMessage: (message: string) => void;
|
|
149
|
+
onCompleted: () => void;
|
|
150
|
+
onError: (error: Error) => void;
|
|
151
|
+
},
|
|
152
|
+
options?: {
|
|
153
|
+
abortController?: AbortController;
|
|
154
|
+
headers?: HeadersInit;
|
|
155
|
+
}
|
|
156
|
+
) => void;
|
|
157
|
+
/** 创建对话 */
|
|
158
|
+
createConversation(): Promise<string>;
|
|
159
|
+
/** 文件上传 */
|
|
160
|
+
uploadFile(file: File, conversationId: string): Promise<IFileUploadRes>;
|
|
161
|
+
/** 获取用户偏好 */
|
|
162
|
+
getUserPreferences(appId: string): Promise<IUserPreferencesData>;
|
|
163
|
+
/** 保存用户偏好 */
|
|
164
|
+
saveUserPreferences(appId: string, preferences: IUserPreferencesData): Promise<void>;
|
|
165
|
+
/** 拉取历史对话消息 */
|
|
166
|
+
fetchChatHistory(params: ISessionHistoryDataReq): Promise<IHistoryChatItem[]>;
|
|
167
|
+
/** 获取上传文件信息 */
|
|
168
|
+
getUploadFileInfo(fileIds: string[]): Promise<ISessionHistoryFilesRes>;
|
|
169
|
+
/** 取消请求 */
|
|
170
|
+
sendAbortRequest(param: IAbortRequestParams): Promise<any>;
|
|
171
|
+
/** 获取历史记录列表 */
|
|
172
|
+
fetchHistoryChatList(params: IConversationListReq): Promise<{data: IConversationItem[]; has_more: boolean}>;
|
|
173
|
+
/** 获取会话状态 */
|
|
174
|
+
fetchChatStatus(conversationIds: string[]): Promise<{data: IConversationStatus[]}>;
|
|
175
|
+
/** 更新会话标题 */
|
|
176
|
+
updateChatTitle(id: string, title: string, end_user_id?: string): Promise<{success: boolean}>;
|
|
177
|
+
/** 删除历史对话 */
|
|
178
|
+
deleteHistoryChat(chatId: string): Promise<{success: boolean; deleted_count: number}>;
|
|
179
|
+
/** 语音识别 - 将音频转换为文本 */
|
|
180
|
+
speechToText(file: Blob, appId: string): Promise<string>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** SDK 初始化函数 */
|
|
184
|
+
export declare function init(dom: HTMLDivElement, clientService: IClientService): Promise<void>;
|