@vectorx/ai-types 0.0.0-beta-20251112071234
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/README.md +1 -0
- package/lib/abstract-request.js +31 -0
- package/lib/agent-types.js +15 -0
- package/lib/index.js +21 -0
- package/lib/runtime-schema/conversation.schema.js +35 -0
- package/lib/runtime-schema/index.js +21 -0
- package/lib/runtime-schema/knowledge.schema.js +13 -0
- package/lib/runtime-schema/memory.schema.js +15 -0
- package/lib/runtime-schema/message.schema.js +77 -0
- package/lib/runtime-schema/task.schema.js +7 -0
- package/package.json +45 -0
- package/types/abstract-request.d.ts +64 -0
- package/types/agent-types.d.ts +136 -0
- package/types/index.d.ts +4 -0
- package/types/runtime-schema/conversation.schema.d.ts +126 -0
- package/types/runtime-schema/index.d.ts +5 -0
- package/types/runtime-schema/knowledge.schema.d.ts +37 -0
- package/types/runtime-schema/memory.schema.d.ts +35 -0
- package/types/runtime-schema/message.schema.d.ts +1049 -0
- package/types/runtime-schema/task.schema.d.ts +9 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
### 小程序/智能体 ai sdk
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractRequestFactory = exports.AbstractRequest = void 0;
|
|
4
|
+
class AbstractRequest {
|
|
5
|
+
constructor(config = {}) {
|
|
6
|
+
const { timeout, timeoutMsg, restrictedMethods, defaultHeaders = {} } = config;
|
|
7
|
+
this.defaultHeaders = defaultHeaders;
|
|
8
|
+
this.timeout = timeout || 0;
|
|
9
|
+
this.timeoutMsg = timeoutMsg || "请求超时";
|
|
10
|
+
this.restrictedMethods = restrictedMethods || ["get", "post", "upload", "download"];
|
|
11
|
+
}
|
|
12
|
+
getTimeout() {
|
|
13
|
+
return this.timeout;
|
|
14
|
+
}
|
|
15
|
+
getTimeoutMsg() {
|
|
16
|
+
return this.timeoutMsg;
|
|
17
|
+
}
|
|
18
|
+
getRestrictedMethods() {
|
|
19
|
+
return this.restrictedMethods;
|
|
20
|
+
}
|
|
21
|
+
getDefaultHeaders() {
|
|
22
|
+
return this.defaultHeaders;
|
|
23
|
+
}
|
|
24
|
+
isMethodRestricted(method) {
|
|
25
|
+
return this.restrictedMethods.includes(method);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.AbstractRequest = AbstractRequest;
|
|
29
|
+
class AbstractRequestFactory {
|
|
30
|
+
}
|
|
31
|
+
exports.AbstractRequestFactory = AbstractRequestFactory;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createIntegrationResponse = createIntegrationResponse;
|
|
4
|
+
function createIntegrationResponse(statusCode, code, message) {
|
|
5
|
+
return {
|
|
6
|
+
statusCode,
|
|
7
|
+
headers: {
|
|
8
|
+
"Content-Type": "application/json",
|
|
9
|
+
},
|
|
10
|
+
body: {
|
|
11
|
+
code,
|
|
12
|
+
message,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.AbstractRequestFactory = exports.AbstractRequest = void 0;
|
|
18
|
+
var abstract_request_1 = require("./abstract-request");
|
|
19
|
+
Object.defineProperty(exports, "AbstractRequest", { enumerable: true, get: function () { return abstract_request_1.AbstractRequest; } });
|
|
20
|
+
Object.defineProperty(exports, "AbstractRequestFactory", { enumerable: true, get: function () { return abstract_request_1.AbstractRequestFactory; } });
|
|
21
|
+
__exportStar(require("./agent-types"), exports);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.conversationSchema = exports.participantInfoSchema = exports.getHistoryMessagesParamsSchema = exports.createRecordPairParamsSchema = exports.assistantRecordSchema = exports.userRecordSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.userRecordSchema = zod_1.z.object({
|
|
6
|
+
content: zod_1.z.string(),
|
|
7
|
+
role: zod_1.z.string(),
|
|
8
|
+
});
|
|
9
|
+
exports.assistantRecordSchema = zod_1.z.object({
|
|
10
|
+
content: zod_1.z.string().optional(),
|
|
11
|
+
role: zod_1.z.string().optional(),
|
|
12
|
+
reasoning_content: zod_1.z.string().optional(),
|
|
13
|
+
type: zod_1.z.string().optional(),
|
|
14
|
+
});
|
|
15
|
+
exports.createRecordPairParamsSchema = zod_1.z.object({
|
|
16
|
+
conversation_id: zod_1.z.string(),
|
|
17
|
+
user_input: exports.userRecordSchema,
|
|
18
|
+
assistant_output: exports.assistantRecordSchema,
|
|
19
|
+
});
|
|
20
|
+
exports.getHistoryMessagesParamsSchema = zod_1.z.object({
|
|
21
|
+
conversation_id: zod_1.z.coerce.string(),
|
|
22
|
+
cursor: zod_1.z.coerce.number(),
|
|
23
|
+
count: zod_1.z.coerce.number(),
|
|
24
|
+
sort: zod_1.z.enum(["desc", "asc"]),
|
|
25
|
+
});
|
|
26
|
+
exports.participantInfoSchema = zod_1.z.object({
|
|
27
|
+
id: zod_1.z.string(),
|
|
28
|
+
name: zod_1.z.string(),
|
|
29
|
+
desc: zod_1.z.string(),
|
|
30
|
+
avatar_url: zod_1.z.string(),
|
|
31
|
+
});
|
|
32
|
+
exports.conversationSchema = zod_1.z.object({
|
|
33
|
+
id: zod_1.z.string(),
|
|
34
|
+
createAt: zod_1.z.string(),
|
|
35
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./message.schema"), exports);
|
|
18
|
+
__exportStar(require("./conversation.schema"), exports);
|
|
19
|
+
__exportStar(require("./memory.schema"), exports);
|
|
20
|
+
__exportStar(require("./knowledge.schema"), exports);
|
|
21
|
+
__exportStar(require("./task.schema"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.knowledgeSearchInputSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.knowledgeSearchInputSchema = zod_1.z.object({
|
|
6
|
+
query: zod_1.z.string(),
|
|
7
|
+
knowledge_base: zod_1.z.object({
|
|
8
|
+
knowledge_base_id: zod_1.z.string(),
|
|
9
|
+
search_mode: zod_1.z.string().optional(),
|
|
10
|
+
score_threshold: zod_1.z.number().optional(),
|
|
11
|
+
limit: zod_1.z.number().optional(),
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLoneMemoryInputSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.getLoneMemoryInputSchema = zod_1.z.object({
|
|
6
|
+
userId: zod_1.z.string(),
|
|
7
|
+
limit: zod_1.z.number().optional(),
|
|
8
|
+
filter: zod_1.z
|
|
9
|
+
.object({
|
|
10
|
+
startTime: zod_1.z.number().optional(),
|
|
11
|
+
endTime: zod_1.z.number().optional(),
|
|
12
|
+
type: zod_1.z.string().optional(),
|
|
13
|
+
})
|
|
14
|
+
.optional(),
|
|
15
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendMessageInputSchema = exports.messageHistorySchema = exports.messageItemSchema = exports.toolResultMessageSchema = exports.toolCallMessageSchema = exports.baseMessageSchema = exports.messageContentSchema = exports.docUrlContentSchema = exports.videoUrlContentSchema = exports.videoContentSchema = exports.audioContentSchema = exports.imageContentSchema = exports.textContentSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.textContentSchema = zod_1.z.object({
|
|
6
|
+
type: zod_1.z.literal("text"),
|
|
7
|
+
text: zod_1.z.string(),
|
|
8
|
+
});
|
|
9
|
+
exports.imageContentSchema = zod_1.z.object({
|
|
10
|
+
type: zod_1.z.literal("image_url"),
|
|
11
|
+
image_url: zod_1.z.object({
|
|
12
|
+
url: zod_1.z.string(),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
exports.audioContentSchema = zod_1.z.object({
|
|
16
|
+
type: zod_1.z.literal("input_audio"),
|
|
17
|
+
input_audio: zod_1.z.object({
|
|
18
|
+
data: zod_1.z.string(),
|
|
19
|
+
format: zod_1.z.string(),
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
exports.videoContentSchema = zod_1.z.object({
|
|
23
|
+
type: zod_1.z.literal("video"),
|
|
24
|
+
video: zod_1.z.array(zod_1.z.string()),
|
|
25
|
+
});
|
|
26
|
+
exports.videoUrlContentSchema = zod_1.z.object({
|
|
27
|
+
type: zod_1.z.literal("video_url"),
|
|
28
|
+
video_url: zod_1.z.object({
|
|
29
|
+
url: zod_1.z.string(),
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
exports.docUrlContentSchema = zod_1.z.object({
|
|
33
|
+
type: zod_1.z.literal("doc_url"),
|
|
34
|
+
doc_url: zod_1.z.array(zod_1.z.string()),
|
|
35
|
+
file_parsing_strategy: zod_1.z.string().optional(),
|
|
36
|
+
});
|
|
37
|
+
exports.messageContentSchema = zod_1.z.union([
|
|
38
|
+
exports.textContentSchema,
|
|
39
|
+
exports.imageContentSchema,
|
|
40
|
+
exports.audioContentSchema,
|
|
41
|
+
exports.videoContentSchema,
|
|
42
|
+
exports.videoUrlContentSchema,
|
|
43
|
+
exports.docUrlContentSchema,
|
|
44
|
+
]);
|
|
45
|
+
exports.baseMessageSchema = zod_1.z.object({
|
|
46
|
+
role: zod_1.z.union([zod_1.z.literal("system"), zod_1.z.literal("user"), zod_1.z.literal("assistant")]),
|
|
47
|
+
content: zod_1.z.union([
|
|
48
|
+
zod_1.z.string(),
|
|
49
|
+
zod_1.z.array(exports.messageContentSchema),
|
|
50
|
+
]),
|
|
51
|
+
});
|
|
52
|
+
exports.toolCallMessageSchema = zod_1.z.object({
|
|
53
|
+
role: zod_1.z.literal("tool"),
|
|
54
|
+
function: zod_1.z.string(),
|
|
55
|
+
arguments: zod_1.z.record(zod_1.z.any()).optional(),
|
|
56
|
+
});
|
|
57
|
+
exports.toolResultMessageSchema = zod_1.z.object({
|
|
58
|
+
role: zod_1.z.literal("tool"),
|
|
59
|
+
function: zod_1.z.string(),
|
|
60
|
+
name: zod_1.z.string(),
|
|
61
|
+
content: zod_1.z.union([zod_1.z.string(), zod_1.z.record(zod_1.z.any()), zod_1.z.array(zod_1.z.any())]),
|
|
62
|
+
});
|
|
63
|
+
exports.messageItemSchema = zod_1.z.union([exports.baseMessageSchema, exports.toolCallMessageSchema, exports.toolResultMessageSchema]);
|
|
64
|
+
exports.messageHistorySchema = zod_1.z.array(exports.messageItemSchema);
|
|
65
|
+
exports.sendMessageInputSchema = zod_1.z.object({
|
|
66
|
+
msg: zod_1.z.string(),
|
|
67
|
+
history: exports.messageHistorySchema,
|
|
68
|
+
files: zod_1.z
|
|
69
|
+
.array(zod_1.z.object({
|
|
70
|
+
id: zod_1.z.string(),
|
|
71
|
+
filename: zod_1.z.string(),
|
|
72
|
+
purpose: zod_1.z.string(),
|
|
73
|
+
bytes: zod_1.z.number(),
|
|
74
|
+
created_at: zod_1.z.number(),
|
|
75
|
+
}))
|
|
76
|
+
.optional(),
|
|
77
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vectorx/ai-types",
|
|
3
|
+
"version": "0.0.0-beta-20251112071234",
|
|
4
|
+
"description": "Cloud AI Types",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"files": [
|
|
9
|
+
"lib",
|
|
10
|
+
"types",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"ai",
|
|
15
|
+
"sdk",
|
|
16
|
+
"cloud",
|
|
17
|
+
"types",
|
|
18
|
+
"typescript"
|
|
19
|
+
],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18.0.0"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"langfuse": "^3.38.4"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/jest": "^29.5.12",
|
|
30
|
+
"@types/node": "^20.11.24",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
|
32
|
+
"@typescript-eslint/parser": "^7.1.0",
|
|
33
|
+
"eslint": "^8.57.0",
|
|
34
|
+
"jest": "^29.7.0",
|
|
35
|
+
"typescript": "^5.3.3",
|
|
36
|
+
"zod": "^3.24.2"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"dev": "tsc -w",
|
|
40
|
+
"build": "rimraf lib types && tsc",
|
|
41
|
+
"lint": "eslint 'src/**/*.ts'",
|
|
42
|
+
"fix": "eslint 'src/**/*.ts' --fix"
|
|
43
|
+
},
|
|
44
|
+
"readme": "### 小程序/智能体 ai sdk "
|
|
45
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export type IRequestMethod = "get" | "post" | "put" | "upload" | "download";
|
|
2
|
+
export interface IRequestConfig {
|
|
3
|
+
timeout?: number;
|
|
4
|
+
timeoutMsg?: string;
|
|
5
|
+
restrictedMethods?: Array<IRequestMethod>;
|
|
6
|
+
defaultHeaders?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export interface IRequestOptions {
|
|
9
|
+
url?: string;
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
data?: any;
|
|
12
|
+
responseType?: string;
|
|
13
|
+
withCredentials?: boolean;
|
|
14
|
+
body?: any;
|
|
15
|
+
method?: string;
|
|
16
|
+
file?: File;
|
|
17
|
+
name?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface IFetchOptions {
|
|
20
|
+
url: string;
|
|
21
|
+
headers?: HeadersInit;
|
|
22
|
+
body?: any;
|
|
23
|
+
method?: string;
|
|
24
|
+
enableAbort?: boolean;
|
|
25
|
+
stream?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface ResponseObject<T = any> {
|
|
28
|
+
data?: T;
|
|
29
|
+
statusCode?: number;
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}
|
|
32
|
+
export interface IAbstractRequest {
|
|
33
|
+
get<T = any>(options: IRequestOptions): Promise<ResponseObject<T>>;
|
|
34
|
+
post<T = any>(options: IRequestOptions): Promise<ResponseObject<T>>;
|
|
35
|
+
put<T = any>(options: IRequestOptions): Promise<ResponseObject<T>>;
|
|
36
|
+
upload<T = any>(options: IRequestOptions): Promise<ResponseObject<T>>;
|
|
37
|
+
download(options: IRequestOptions): Promise<unknown>;
|
|
38
|
+
fetch(options: IFetchOptions): Promise<ResponseObject>;
|
|
39
|
+
}
|
|
40
|
+
export declare abstract class AbstractRequest implements IAbstractRequest {
|
|
41
|
+
protected readonly timeout: number;
|
|
42
|
+
protected readonly timeoutMsg: string;
|
|
43
|
+
protected readonly restrictedMethods: Array<IRequestMethod>;
|
|
44
|
+
protected readonly defaultHeaders: Record<string, string>;
|
|
45
|
+
constructor(config?: IRequestConfig);
|
|
46
|
+
abstract get<T = any>(options: IRequestOptions): Promise<ResponseObject<T>>;
|
|
47
|
+
abstract post<T = any>(options: IRequestOptions): Promise<ResponseObject<T>>;
|
|
48
|
+
abstract put<T = any>(options: IRequestOptions): Promise<ResponseObject<T>>;
|
|
49
|
+
abstract upload<T = any>(options: IRequestOptions): Promise<ResponseObject<T>>;
|
|
50
|
+
abstract download(options: IRequestOptions): Promise<unknown>;
|
|
51
|
+
abstract fetch(options: IFetchOptions): Promise<ResponseObject>;
|
|
52
|
+
protected abstract request(options: IRequestOptions, enableAbort?: boolean): Promise<ResponseObject>;
|
|
53
|
+
protected getTimeout(): number;
|
|
54
|
+
protected getTimeoutMsg(): string;
|
|
55
|
+
protected getRestrictedMethods(): Array<IRequestMethod>;
|
|
56
|
+
protected getDefaultHeaders(): Record<string, string>;
|
|
57
|
+
protected isMethodRestricted(method: IRequestMethod): boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface IRequestFactory {
|
|
60
|
+
create(config?: IRequestConfig): IAbstractRequest;
|
|
61
|
+
}
|
|
62
|
+
export declare abstract class AbstractRequestFactory implements IRequestFactory {
|
|
63
|
+
abstract create(config?: IRequestConfig): IAbstractRequest;
|
|
64
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
export type MessageType = "answer" | "image" | "video" | "async_task" | "function_call" | "function_call_response" | "knowledge_base_search" | "knowledge_base_search_response" | "error";
|
|
2
|
+
export interface IntegrationResponse {
|
|
3
|
+
statusCode: number;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
body: {
|
|
6
|
+
code: string;
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface ErrorResponse {
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
requestId: string;
|
|
14
|
+
}
|
|
15
|
+
export interface BaseResponse<T = any> {
|
|
16
|
+
code: number;
|
|
17
|
+
msg: string;
|
|
18
|
+
data?: T;
|
|
19
|
+
}
|
|
20
|
+
export declare function createIntegrationResponse(statusCode: number, code: string, message: string): IntegrationResponse;
|
|
21
|
+
export interface UserRecord {
|
|
22
|
+
content: string;
|
|
23
|
+
role: "user";
|
|
24
|
+
}
|
|
25
|
+
export interface AssistantRecord {
|
|
26
|
+
content: string;
|
|
27
|
+
role: "assistant";
|
|
28
|
+
reasoningContent: string;
|
|
29
|
+
type: MessageType;
|
|
30
|
+
}
|
|
31
|
+
export type CreateRecordPairResponse = BaseResponse;
|
|
32
|
+
export interface ParticipantInfo {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
desc: string;
|
|
36
|
+
avatar_url: string;
|
|
37
|
+
}
|
|
38
|
+
export interface GetHistoryMessagesData {
|
|
39
|
+
message_list: (UserRecord | AssistantRecord)[];
|
|
40
|
+
conversation_id: string;
|
|
41
|
+
participant_info_map: Record<string, ParticipantInfo>;
|
|
42
|
+
next_cursor: number;
|
|
43
|
+
has_more: boolean;
|
|
44
|
+
}
|
|
45
|
+
export type GetHistoryMessagesResponse = BaseResponse<GetHistoryMessagesData>;
|
|
46
|
+
export interface Conversation {
|
|
47
|
+
id: string;
|
|
48
|
+
createAt: string;
|
|
49
|
+
}
|
|
50
|
+
export interface GetConversationsData {
|
|
51
|
+
conversations: Conversation[];
|
|
52
|
+
}
|
|
53
|
+
export type GetConversationsResponse = BaseResponse<GetConversationsData>;
|
|
54
|
+
export type ChatRecordBase = {};
|
|
55
|
+
export interface GetChatRecordsOutput {
|
|
56
|
+
recordList: ChatRecordBase[];
|
|
57
|
+
total: number;
|
|
58
|
+
}
|
|
59
|
+
export interface UserProfile {
|
|
60
|
+
tags?: string[];
|
|
61
|
+
preferences?: Record<string, any>;
|
|
62
|
+
}
|
|
63
|
+
export interface LoneMemoryRecord extends ChatRecordBase {
|
|
64
|
+
userProfile?: UserProfile;
|
|
65
|
+
}
|
|
66
|
+
export interface GetLoneMemoryOutput {
|
|
67
|
+
recordList: LoneMemoryRecord[];
|
|
68
|
+
total: number;
|
|
69
|
+
}
|
|
70
|
+
export interface KnowledgeResultMetaData {
|
|
71
|
+
score: number;
|
|
72
|
+
source_type: string;
|
|
73
|
+
doc_type: string;
|
|
74
|
+
content_length: number;
|
|
75
|
+
}
|
|
76
|
+
export interface KnowledgeResult {
|
|
77
|
+
id: string;
|
|
78
|
+
content: string;
|
|
79
|
+
chunk_id: string;
|
|
80
|
+
meta_data: KnowledgeResultMetaData;
|
|
81
|
+
}
|
|
82
|
+
export interface KnowledgeSearchOutput {
|
|
83
|
+
knowledge_results: KnowledgeResult[];
|
|
84
|
+
total_tokens: number;
|
|
85
|
+
}
|
|
86
|
+
export type KnowledgeBaseRetrieveResponse = BaseResponse<KnowledgeSearchOutput>;
|
|
87
|
+
export interface AgentInfo {
|
|
88
|
+
agentId: string;
|
|
89
|
+
version: string;
|
|
90
|
+
desc: string;
|
|
91
|
+
}
|
|
92
|
+
export interface GetAgentInfoResponse {
|
|
93
|
+
code: number;
|
|
94
|
+
success: boolean;
|
|
95
|
+
msg: string;
|
|
96
|
+
data: {
|
|
97
|
+
agentInfo: AgentInfo;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export interface QueryTasksData {
|
|
101
|
+
request_id: string;
|
|
102
|
+
output: {
|
|
103
|
+
task_id: string;
|
|
104
|
+
task_status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "CANCELED" | "UNKNOWN";
|
|
105
|
+
results?: Array<{
|
|
106
|
+
url?: string;
|
|
107
|
+
[key: string]: any;
|
|
108
|
+
}>;
|
|
109
|
+
task_metrics?: {
|
|
110
|
+
TOTAL: number;
|
|
111
|
+
SUCCEEDED: number;
|
|
112
|
+
FAILED: number;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
usage?: {
|
|
116
|
+
image_count?: number;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export type RawQueryTasksResponse = QueryTasksData;
|
|
120
|
+
export type QueryTasksResponse = BaseResponse<QueryTasksData>;
|
|
121
|
+
export interface UploadFileInput {
|
|
122
|
+
file: File | Buffer | string;
|
|
123
|
+
filename: string;
|
|
124
|
+
purpose?: string;
|
|
125
|
+
}
|
|
126
|
+
export interface UploadFileData {
|
|
127
|
+
id: string;
|
|
128
|
+
object: string;
|
|
129
|
+
bytes: number;
|
|
130
|
+
created_at: number;
|
|
131
|
+
filename: string;
|
|
132
|
+
purpose: string;
|
|
133
|
+
status: string;
|
|
134
|
+
status_details?: any;
|
|
135
|
+
}
|
|
136
|
+
export type UploadFileResponse = BaseResponse<UploadFileData>;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { IRequestMethod, IRequestConfig, IRequestOptions, IFetchOptions, ResponseObject, IAbstractRequest, IRequestFactory, } from "./abstract-request";
|
|
2
|
+
export { AbstractRequest, AbstractRequestFactory, } from "./abstract-request";
|
|
3
|
+
export type { SendMessageInput, TextContent, ImageContent, AudioContent, VideoContent, VideoUrlContent, MessageContent, BaseMessage, GetHistoryMessagesParams, CreateRecordPairParams, Conversation, KnowledgeSearchInput, GetLoneMemoryInput, } from "./runtime-schema";
|
|
4
|
+
export * from "./agent-types";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const userRecordSchema: z.ZodObject<{
|
|
3
|
+
content: z.ZodString;
|
|
4
|
+
role: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
role?: string;
|
|
7
|
+
content?: string;
|
|
8
|
+
}, {
|
|
9
|
+
role?: string;
|
|
10
|
+
content?: string;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const assistantRecordSchema: z.ZodObject<{
|
|
13
|
+
content: z.ZodOptional<z.ZodString>;
|
|
14
|
+
role: z.ZodOptional<z.ZodString>;
|
|
15
|
+
reasoning_content: z.ZodOptional<z.ZodString>;
|
|
16
|
+
type: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
type?: string;
|
|
19
|
+
role?: string;
|
|
20
|
+
content?: string;
|
|
21
|
+
reasoning_content?: string;
|
|
22
|
+
}, {
|
|
23
|
+
type?: string;
|
|
24
|
+
role?: string;
|
|
25
|
+
content?: string;
|
|
26
|
+
reasoning_content?: string;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const createRecordPairParamsSchema: z.ZodObject<{
|
|
29
|
+
conversation_id: z.ZodString;
|
|
30
|
+
user_input: z.ZodObject<{
|
|
31
|
+
content: z.ZodString;
|
|
32
|
+
role: z.ZodString;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
role?: string;
|
|
35
|
+
content?: string;
|
|
36
|
+
}, {
|
|
37
|
+
role?: string;
|
|
38
|
+
content?: string;
|
|
39
|
+
}>;
|
|
40
|
+
assistant_output: z.ZodObject<{
|
|
41
|
+
content: z.ZodOptional<z.ZodString>;
|
|
42
|
+
role: z.ZodOptional<z.ZodString>;
|
|
43
|
+
reasoning_content: z.ZodOptional<z.ZodString>;
|
|
44
|
+
type: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
type?: string;
|
|
47
|
+
role?: string;
|
|
48
|
+
content?: string;
|
|
49
|
+
reasoning_content?: string;
|
|
50
|
+
}, {
|
|
51
|
+
type?: string;
|
|
52
|
+
role?: string;
|
|
53
|
+
content?: string;
|
|
54
|
+
reasoning_content?: string;
|
|
55
|
+
}>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
conversation_id?: string;
|
|
58
|
+
user_input?: {
|
|
59
|
+
role?: string;
|
|
60
|
+
content?: string;
|
|
61
|
+
};
|
|
62
|
+
assistant_output?: {
|
|
63
|
+
type?: string;
|
|
64
|
+
role?: string;
|
|
65
|
+
content?: string;
|
|
66
|
+
reasoning_content?: string;
|
|
67
|
+
};
|
|
68
|
+
}, {
|
|
69
|
+
conversation_id?: string;
|
|
70
|
+
user_input?: {
|
|
71
|
+
role?: string;
|
|
72
|
+
content?: string;
|
|
73
|
+
};
|
|
74
|
+
assistant_output?: {
|
|
75
|
+
type?: string;
|
|
76
|
+
role?: string;
|
|
77
|
+
content?: string;
|
|
78
|
+
reasoning_content?: string;
|
|
79
|
+
};
|
|
80
|
+
}>;
|
|
81
|
+
export declare const getHistoryMessagesParamsSchema: z.ZodObject<{
|
|
82
|
+
conversation_id: z.ZodString;
|
|
83
|
+
cursor: z.ZodNumber;
|
|
84
|
+
count: z.ZodNumber;
|
|
85
|
+
sort: z.ZodEnum<["desc", "asc"]>;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
sort?: "desc" | "asc";
|
|
88
|
+
conversation_id?: string;
|
|
89
|
+
cursor?: number;
|
|
90
|
+
count?: number;
|
|
91
|
+
}, {
|
|
92
|
+
sort?: "desc" | "asc";
|
|
93
|
+
conversation_id?: string;
|
|
94
|
+
cursor?: number;
|
|
95
|
+
count?: number;
|
|
96
|
+
}>;
|
|
97
|
+
export declare const participantInfoSchema: z.ZodObject<{
|
|
98
|
+
id: z.ZodString;
|
|
99
|
+
name: z.ZodString;
|
|
100
|
+
desc: z.ZodString;
|
|
101
|
+
avatar_url: z.ZodString;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
name?: string;
|
|
104
|
+
id?: string;
|
|
105
|
+
desc?: string;
|
|
106
|
+
avatar_url?: string;
|
|
107
|
+
}, {
|
|
108
|
+
name?: string;
|
|
109
|
+
id?: string;
|
|
110
|
+
desc?: string;
|
|
111
|
+
avatar_url?: string;
|
|
112
|
+
}>;
|
|
113
|
+
export declare const conversationSchema: z.ZodObject<{
|
|
114
|
+
id: z.ZodString;
|
|
115
|
+
createAt: z.ZodString;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
id?: string;
|
|
118
|
+
createAt?: string;
|
|
119
|
+
}, {
|
|
120
|
+
id?: string;
|
|
121
|
+
createAt?: string;
|
|
122
|
+
}>;
|
|
123
|
+
export type GetHistoryMessagesParams = z.infer<typeof getHistoryMessagesParamsSchema>;
|
|
124
|
+
export type CreateRecordPairParams = z.infer<typeof createRecordPairParamsSchema>;
|
|
125
|
+
export type ParticipantInfo = z.infer<typeof participantInfoSchema>;
|
|
126
|
+
export type Conversation = z.infer<typeof conversationSchema>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const knowledgeSearchInputSchema: z.ZodObject<{
|
|
3
|
+
query: z.ZodString;
|
|
4
|
+
knowledge_base: z.ZodObject<{
|
|
5
|
+
knowledge_base_id: z.ZodString;
|
|
6
|
+
search_mode: z.ZodOptional<z.ZodString>;
|
|
7
|
+
score_threshold: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
limit?: number;
|
|
11
|
+
knowledge_base_id?: string;
|
|
12
|
+
search_mode?: string;
|
|
13
|
+
score_threshold?: number;
|
|
14
|
+
}, {
|
|
15
|
+
limit?: number;
|
|
16
|
+
knowledge_base_id?: string;
|
|
17
|
+
search_mode?: string;
|
|
18
|
+
score_threshold?: number;
|
|
19
|
+
}>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
query?: string;
|
|
22
|
+
knowledge_base?: {
|
|
23
|
+
limit?: number;
|
|
24
|
+
knowledge_base_id?: string;
|
|
25
|
+
search_mode?: string;
|
|
26
|
+
score_threshold?: number;
|
|
27
|
+
};
|
|
28
|
+
}, {
|
|
29
|
+
query?: string;
|
|
30
|
+
knowledge_base?: {
|
|
31
|
+
limit?: number;
|
|
32
|
+
knowledge_base_id?: string;
|
|
33
|
+
search_mode?: string;
|
|
34
|
+
score_threshold?: number;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
export type KnowledgeSearchInput = z.infer<typeof knowledgeSearchInputSchema>;
|