@hddjs/hdd-cloud-types 1.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/HddCloud/common/index.d.ts +4 -0
- package/HddCloud/index.d.ts +59 -0
- package/README.md +3 -0
- package/hdd-ai-cloud/common/AISceneEnum.d.ts +21 -0
- package/hdd-ai-cloud/common/IAliFcContext.js +2 -0
- package/hdd-ai-cloud/common/IAliFcContext.ts +5 -0
- package/hdd-ai-cloud/common/IChatAiMessageItem.d.ts +23 -0
- package/hdd-ai-cloud/common/ICommonReqRes.d.ts +30 -0
- package/hdd-ai-cloud/common/ICounselor.d.ts +4 -0
- package/hdd-ai-cloud/common/ISceneAiConfig.d.ts +27 -0
- package/hdd-ai-cloud/common/ISessionContent.d.ts +9 -0
- package/hdd-ai-cloud/common/ISessionRole.d.ts +21 -0
- package/hdd-ai-cloud/common/ISseChunk.d.ts +53 -0
- package/hdd-ai-cloud/common/IThisContext.d.ts +128 -0
- package/hdd-ai-cloud/common/index.d.ts +9 -0
- package/hdd-ai-cloud/index.d.ts +131 -0
- package/index.d.ts +2 -0
- package/npmPublish.md +11 -0
- package/package.json +12 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export * from './common';
|
|
2
|
+
export interface HddCloud {}
|
|
3
|
+
/**
|
|
4
|
+
* 符合openai格式的大模型调用入参
|
|
5
|
+
* @tutorial https://help.aliyun.com/zh/model-studio/developer-reference/use-qwen-by-calling-api?spm=a2c4g.11186623.help-menu-2400256.d_3_3_0.1ff14823Prcy7Z&scm=20140722.H_2712576._.OR_help-T_cn~zh-V_1
|
|
6
|
+
*/
|
|
7
|
+
export interface IChatOpenAiParams {
|
|
8
|
+
/**
|
|
9
|
+
* 调用配置信息 如apikey url等
|
|
10
|
+
*/
|
|
11
|
+
hddOptions: {
|
|
12
|
+
/**
|
|
13
|
+
* 模型地址
|
|
14
|
+
*/
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
/**
|
|
17
|
+
* 调用大模型的apiKey
|
|
18
|
+
*/
|
|
19
|
+
apiKey: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 调用的模型
|
|
23
|
+
*/
|
|
24
|
+
model?: 'qwq-plus' | 'qwen-max' | 'deepseek-r1' | 'deepseek-v3';
|
|
25
|
+
/**
|
|
26
|
+
* 对话消息
|
|
27
|
+
*/
|
|
28
|
+
messages?: IOpenAiMessage[];
|
|
29
|
+
/**
|
|
30
|
+
* 是否开启流式传输
|
|
31
|
+
*/
|
|
32
|
+
stream?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 是否包含使用情况 流式传输时候生效
|
|
35
|
+
*/
|
|
36
|
+
stream_options?: {
|
|
37
|
+
include_usage?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 返回的格式 默认text
|
|
41
|
+
*/
|
|
42
|
+
response_format?: {
|
|
43
|
+
type: 'text' | 'json_object';
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* 最大生成token数
|
|
47
|
+
*/
|
|
48
|
+
max_tokens?: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 符合openai规范的 大模型调用的流式chunk消息体
|
|
53
|
+
*/
|
|
54
|
+
export interface IChatOpenAiChunk {}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 符合openai格式的大模型调用出参
|
|
58
|
+
*/
|
|
59
|
+
export interface IChatOpenAiRes extends AsyncIterable<IChatOpenAiChunk> {}
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI场景枚举
|
|
3
|
+
*/
|
|
4
|
+
export const enum AISceneEnum {
|
|
5
|
+
/**
|
|
6
|
+
* 高考志愿填报
|
|
7
|
+
*/
|
|
8
|
+
GAOKAO = 'gaokao',
|
|
9
|
+
/**
|
|
10
|
+
* 高考志愿填报 基本情况问答
|
|
11
|
+
*/
|
|
12
|
+
GAOKAO_BASE_ASK = 'gaokao_base_ask',
|
|
13
|
+
/**
|
|
14
|
+
* 高考志愿填报 可能的答案
|
|
15
|
+
*/
|
|
16
|
+
GAOKAO_MAYBE_ANSWER = 'gaokao_maybe_answer',
|
|
17
|
+
/**
|
|
18
|
+
* 学习助手
|
|
19
|
+
*/
|
|
20
|
+
Study_Helper = 'study_helper'
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type SessionRoleEnum } from './SessionRoleEnum';
|
|
2
|
+
export interface IChatAiMessageItem {
|
|
3
|
+
/**
|
|
4
|
+
* 会话角色 前端禁止传入系统消息 服务端需要过滤前端传入的系统消息
|
|
5
|
+
*/
|
|
6
|
+
role: SessionRoleEnum;
|
|
7
|
+
/**
|
|
8
|
+
* 消息内容
|
|
9
|
+
*/
|
|
10
|
+
content: string;
|
|
11
|
+
/**
|
|
12
|
+
* 发送者昵称
|
|
13
|
+
*/
|
|
14
|
+
nickName?: string;
|
|
15
|
+
/**
|
|
16
|
+
* 发送时间戳
|
|
17
|
+
*/
|
|
18
|
+
timeStamp?: number;
|
|
19
|
+
/**
|
|
20
|
+
* 发送时间字符串展示 YYYY-MM-DD HH:mm:ss / HH:mm:ss
|
|
21
|
+
*/
|
|
22
|
+
timeStr?: string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通用res返回参数
|
|
3
|
+
*/
|
|
4
|
+
export interface ICommonRes {
|
|
5
|
+
/**
|
|
6
|
+
* 错误码 0:成功
|
|
7
|
+
*/
|
|
8
|
+
errCode?: string;
|
|
9
|
+
/**
|
|
10
|
+
* 错误信息
|
|
11
|
+
*/
|
|
12
|
+
errMsg?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 运行时间 ms
|
|
15
|
+
*/
|
|
16
|
+
funRunTime?: number;
|
|
17
|
+
/**
|
|
18
|
+
* 开始时间时间戳
|
|
19
|
+
*/
|
|
20
|
+
funStartTime?: number;
|
|
21
|
+
/**
|
|
22
|
+
* 结束时间时间戳
|
|
23
|
+
*/
|
|
24
|
+
funEndTime?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 通用请求参数
|
|
29
|
+
*/
|
|
30
|
+
export interface ICommonReq {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type AISceneEnum } from './AISceneEnum';
|
|
2
|
+
/**
|
|
3
|
+
* AI场景hdd-ai-config配置
|
|
4
|
+
*/
|
|
5
|
+
export interface ISceneAiConfig {
|
|
6
|
+
/**
|
|
7
|
+
* apiKey
|
|
8
|
+
*/
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
/**
|
|
11
|
+
* baseURL
|
|
12
|
+
*/
|
|
13
|
+
baseURL?: string;
|
|
14
|
+
/**
|
|
15
|
+
* 提问场景
|
|
16
|
+
*/
|
|
17
|
+
scene?: AISceneEnum;
|
|
18
|
+
/**
|
|
19
|
+
* 场景描述
|
|
20
|
+
*/
|
|
21
|
+
desc?: string;
|
|
22
|
+
/**
|
|
23
|
+
* 该场景需要调用的模型
|
|
24
|
+
* @enum 'qwen-max' | 'deepseek-r1' | 'qwen-plus'
|
|
25
|
+
*/
|
|
26
|
+
model?: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type SessionRoleEnum } from './ISessionRole';
|
|
2
|
+
/**
|
|
3
|
+
* sse流式返回片段
|
|
4
|
+
*/
|
|
5
|
+
export interface ISseChunk {
|
|
6
|
+
/**
|
|
7
|
+
* sse流式返回片段的类型
|
|
8
|
+
*/
|
|
9
|
+
type: ISseChunkType;
|
|
10
|
+
/**
|
|
11
|
+
* sse流式返回片段的角色
|
|
12
|
+
*/
|
|
13
|
+
role?: SessionRoleEnum;
|
|
14
|
+
/**
|
|
15
|
+
* 当type为content时sse流式返回片段的内容
|
|
16
|
+
*/
|
|
17
|
+
content?: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* 当type为reason时sse流式返回片段的原因
|
|
20
|
+
*/
|
|
21
|
+
reason?: string | null;
|
|
22
|
+
/**
|
|
23
|
+
* 当type为formatJson时sse流式返回片段的格式化json
|
|
24
|
+
* */
|
|
25
|
+
formatJson?: {
|
|
26
|
+
/**
|
|
27
|
+
* 是否开始下一个流程
|
|
28
|
+
*/
|
|
29
|
+
startNextStep?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 可能的答案选项
|
|
32
|
+
*/
|
|
33
|
+
guessAnswerList?: string[];
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* sse流式返回片段的类型
|
|
39
|
+
*/
|
|
40
|
+
export const enum ISseChunkType {
|
|
41
|
+
/**
|
|
42
|
+
* 内容
|
|
43
|
+
*/
|
|
44
|
+
CONTENT = 'content',
|
|
45
|
+
/**
|
|
46
|
+
* 原因
|
|
47
|
+
*/
|
|
48
|
+
REASON = 'reason',
|
|
49
|
+
/**
|
|
50
|
+
* 格式化的json
|
|
51
|
+
* */
|
|
52
|
+
FORMATJSON = 'formatJson'
|
|
53
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* uniCloud云对象的this上下文
|
|
3
|
+
*/
|
|
4
|
+
export interface IThisContext {
|
|
5
|
+
/**
|
|
6
|
+
* 函数执行开始的时间戳 毫秒 在_before中赋值
|
|
7
|
+
*/
|
|
8
|
+
funStartTime?: number;
|
|
9
|
+
/**
|
|
10
|
+
* 函数执行结束的时间戳 毫秒 在_after中赋值
|
|
11
|
+
*/
|
|
12
|
+
funEndTime?: number;
|
|
13
|
+
/**
|
|
14
|
+
* 函数执行的总时间 毫秒 在_after中赋值funEndTime - funStartTime
|
|
15
|
+
*/
|
|
16
|
+
funRunTime?: number;
|
|
17
|
+
/**
|
|
18
|
+
* 通过token解析出来的用户信息 _before中赋值 未登录时候赋值为null
|
|
19
|
+
*/
|
|
20
|
+
tokenRes?: ITokenRes | null;
|
|
21
|
+
/**
|
|
22
|
+
* 获取的云对象信息
|
|
23
|
+
*/
|
|
24
|
+
getCloudInfo?: () => ICloudInfo;
|
|
25
|
+
/**
|
|
26
|
+
* 获取客户端信息
|
|
27
|
+
*/
|
|
28
|
+
getClientInfo?: () => IClientInfo;
|
|
29
|
+
/**
|
|
30
|
+
* 获取token
|
|
31
|
+
*/
|
|
32
|
+
getUniIdToken?: () => string;
|
|
33
|
+
/**
|
|
34
|
+
* 获取调用的云对象方法名
|
|
35
|
+
*/
|
|
36
|
+
getMethodName?: () => string;
|
|
37
|
+
/**
|
|
38
|
+
* 获取调用云对象时候传入的参数
|
|
39
|
+
*/
|
|
40
|
+
getParams?: () => any;
|
|
41
|
+
/**
|
|
42
|
+
* 获取请求id
|
|
43
|
+
*/
|
|
44
|
+
getUniCloudRequestId?: () => string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* this.tokenRes解析出来的用户信息
|
|
49
|
+
*/
|
|
50
|
+
export interface ITokenRes {
|
|
51
|
+
/**
|
|
52
|
+
* 错误码 0为成功
|
|
53
|
+
*/
|
|
54
|
+
errCode?: number;
|
|
55
|
+
/**
|
|
56
|
+
* token解析出来的uid
|
|
57
|
+
*/
|
|
58
|
+
uid?: string;
|
|
59
|
+
/**
|
|
60
|
+
* token解析出来的role角色
|
|
61
|
+
*/
|
|
62
|
+
role?: string[];
|
|
63
|
+
/**
|
|
64
|
+
* token解析出来的permission权限
|
|
65
|
+
*/
|
|
66
|
+
permission?: string[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* this.getClientInfo返回的客户端信息
|
|
71
|
+
*/
|
|
72
|
+
export interface IClientInfo {
|
|
73
|
+
/**
|
|
74
|
+
* 客户端ip
|
|
75
|
+
*/
|
|
76
|
+
clientIP?: string;
|
|
77
|
+
/**
|
|
78
|
+
* 客户端ua,注意非本地运行环境下客户端getSystemInfoSync也会获取ua参数并上传给云对象,但是云对象会从http请求头里面获取ua而不是clientInfo里面的ua
|
|
79
|
+
*/
|
|
80
|
+
userAgent?: string;
|
|
81
|
+
/**
|
|
82
|
+
* 调用来源
|
|
83
|
+
* client uni-app客户端导入云对象调用
|
|
84
|
+
* function 由其他云函数或云对象调用
|
|
85
|
+
* http 云对象URL化后通过http访问调用 HBuilderX 3.5.2+
|
|
86
|
+
* timing 定时任务调用云对象 HBuilderX 3.5.2+
|
|
87
|
+
* server 云函数上传并运行
|
|
88
|
+
*/
|
|
89
|
+
source?: 'client' | 'function' | 'http' | 'timing' | 'server';
|
|
90
|
+
/**
|
|
91
|
+
* 请求id
|
|
92
|
+
*/
|
|
93
|
+
requestId?: string;
|
|
94
|
+
/**
|
|
95
|
+
* 场景值 客户端uni.getLaunchOptionsSync返回的scene参数,新增于HBuilderX 3.5.1
|
|
96
|
+
*/
|
|
97
|
+
scene?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* this.getCloudInfo获取的云对象信息
|
|
102
|
+
*/
|
|
103
|
+
export interface ICloudInfo {
|
|
104
|
+
/**
|
|
105
|
+
* 服务空间供应商,支付宝云为:alipay,阿里云为:aliyun,腾讯云为:tencent
|
|
106
|
+
*/
|
|
107
|
+
provider: 'alipay' | 'aliyun' | 'tencent';
|
|
108
|
+
/**
|
|
109
|
+
* 服务空间Id
|
|
110
|
+
*/
|
|
111
|
+
spaceId: string;
|
|
112
|
+
/**
|
|
113
|
+
* 当前获取的服务空间id是否为迁移前的服务空间id
|
|
114
|
+
*/
|
|
115
|
+
useOldSpaceId: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* 云对象名称
|
|
118
|
+
*/
|
|
119
|
+
functionName: string;
|
|
120
|
+
/**
|
|
121
|
+
* 云对象此值固定为cloudobject
|
|
122
|
+
*/
|
|
123
|
+
functionType: 'cloudobject';
|
|
124
|
+
/**
|
|
125
|
+
* 运行环境,取值为local(本地运行)或cloud(云端运行) 新增于HBuilderX 4.25
|
|
126
|
+
*/
|
|
127
|
+
runtimeEnv: 'local' | 'cloud';
|
|
128
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './ICommonReqRes';
|
|
2
|
+
export * from './ISessionRole';
|
|
3
|
+
export * from './ISessionContent';
|
|
4
|
+
export * from './ICounselor';
|
|
5
|
+
export * from './IChatAiMessageItem';
|
|
6
|
+
export * from './AISceneEnum';
|
|
7
|
+
export * from './ISceneAiConfig';
|
|
8
|
+
export * from './IAliFcContext';
|
|
9
|
+
export * from './ISseChunk';
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { type IChatAiMessageItem } from './common/IChatAiMessageItem';
|
|
2
|
+
import { type ICommonReq, type AISceneEnum } from './common';
|
|
3
|
+
|
|
4
|
+
export * from './common';
|
|
5
|
+
/**
|
|
6
|
+
* 千问AI聊天api 请求参数
|
|
7
|
+
*/
|
|
8
|
+
export interface IChatQwenReq extends ICommonReq {
|
|
9
|
+
/**
|
|
10
|
+
* 历史对话消息
|
|
11
|
+
*/
|
|
12
|
+
messages: IChatAiMessageItem[];
|
|
13
|
+
/**
|
|
14
|
+
* 是否开启流式传输
|
|
15
|
+
*/
|
|
16
|
+
stream: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 提问场景
|
|
19
|
+
*/
|
|
20
|
+
scene?: AISceneEnum;
|
|
21
|
+
/**
|
|
22
|
+
* 通道id(如果开启流式传输stream为true则必传)
|
|
23
|
+
*/
|
|
24
|
+
channel?: string;
|
|
25
|
+
/**
|
|
26
|
+
* 是否开发模式 仅调式使用 默认false 前端禁止使用
|
|
27
|
+
*/
|
|
28
|
+
devMode?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 千问AI聊天api 返回参数
|
|
33
|
+
*/
|
|
34
|
+
export interface IChatQwenRes extends ICommonReq {
|
|
35
|
+
/**
|
|
36
|
+
* ai回复消息(完成拼接之后的消息)
|
|
37
|
+
*/
|
|
38
|
+
message: string;
|
|
39
|
+
/**
|
|
40
|
+
* llm运行总时间 单位ms
|
|
41
|
+
*/
|
|
42
|
+
llmRunTime: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* AI聊天api 单次流式传输返回参数
|
|
47
|
+
*/
|
|
48
|
+
export interface IChatAIStreamRes {
|
|
49
|
+
/**
|
|
50
|
+
* 当前返回的消息
|
|
51
|
+
*/
|
|
52
|
+
chunkMessage: string;
|
|
53
|
+
/**
|
|
54
|
+
* 深度思考的原因 仅deepseek模型返回
|
|
55
|
+
*/
|
|
56
|
+
chunkReasonMessage?: string;
|
|
57
|
+
/**
|
|
58
|
+
* 索引(从0开始) 本次流式消息是整体流式消息的第几个
|
|
59
|
+
*/
|
|
60
|
+
index: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* DeepSeek AI聊天api 请求参数
|
|
65
|
+
*/
|
|
66
|
+
export interface IChatDeepSeekReq extends ICommonReq {
|
|
67
|
+
/**
|
|
68
|
+
* 历史对话消息
|
|
69
|
+
*/
|
|
70
|
+
messages: IChatAiMessageItem[];
|
|
71
|
+
/**
|
|
72
|
+
* 是否开启流式传输
|
|
73
|
+
*/
|
|
74
|
+
stream: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* 通道id(如果开启流式传输stream为true则必传)
|
|
77
|
+
*/
|
|
78
|
+
channel?: string;
|
|
79
|
+
/**
|
|
80
|
+
* 提问场景
|
|
81
|
+
*/
|
|
82
|
+
scene?: AISceneEnum;
|
|
83
|
+
/**
|
|
84
|
+
* 是否开发模式 仅调式使用 默认false 前端禁止使用
|
|
85
|
+
*/
|
|
86
|
+
devMode?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* DeepSeek AI聊天api 返回参数
|
|
91
|
+
*/
|
|
92
|
+
export interface IChatDeepSeekRes extends ICommonReq {
|
|
93
|
+
/**
|
|
94
|
+
* ai回复消息(完成拼接之后的消息)
|
|
95
|
+
*/
|
|
96
|
+
message: string;
|
|
97
|
+
/**
|
|
98
|
+
* deepseek深度思考给出的原因
|
|
99
|
+
*/
|
|
100
|
+
reasonMessage: string;
|
|
101
|
+
/**
|
|
102
|
+
* llm运行总时间 单位ms
|
|
103
|
+
*/
|
|
104
|
+
llmRunTime: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface IGuessAnswerListReq extends ICommonReq {
|
|
108
|
+
/**
|
|
109
|
+
* 问题内容
|
|
110
|
+
*/
|
|
111
|
+
content: string;
|
|
112
|
+
/**
|
|
113
|
+
* 临时消息id
|
|
114
|
+
*/
|
|
115
|
+
tempMsgId: string;
|
|
116
|
+
/**
|
|
117
|
+
* 场景
|
|
118
|
+
*/
|
|
119
|
+
scene?: AISceneEnum;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface IGuessAnswerListRes extends ICommonRes {
|
|
123
|
+
/**
|
|
124
|
+
* 关联的问题id
|
|
125
|
+
*/
|
|
126
|
+
relatedTempMsgId?: string;
|
|
127
|
+
/**
|
|
128
|
+
* 可能的答案选项
|
|
129
|
+
*/
|
|
130
|
+
choices?: string[];
|
|
131
|
+
}
|
package/index.d.ts
ADDED
package/npmPublish.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
### 发布前切换到官方的站点
|
|
2
|
+
npm config set registry https://registry.npmjs.org/
|
|
3
|
+
### 执行登录
|
|
4
|
+
npm login
|
|
5
|
+
### 发公有包
|
|
6
|
+
npm publish --access=public
|
|
7
|
+
```
|
|
8
|
+
--access=public必须要加上,不然发布的是私有包,而NPM上要发布私有包是要收费的,如果第一步init时没有加上--scope=hddjs,那么这里可以不加上这个后缀,因为不带作用域的包发布时,默认是公有的
|
|
9
|
+
```
|
|
10
|
+
### 发布完包之后切会淘宝源
|
|
11
|
+
npm config set registry https://registry.npmmirror.com
|
package/package.json
ADDED