@acip/cli 1.5.0
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 +368 -0
- package/bin/acip.js +3 -0
- package/dist/commands/call.d.ts +3 -0
- package/dist/commands/call.d.ts.map +1 -0
- package/dist/commands/call.js +65 -0
- package/dist/commands/call.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +144 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/deploy.d.ts +3 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +280 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/dev.d.ts +3 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +218 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +289 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +80 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/inspect.d.ts +3 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +69 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +118 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/monitor.d.ts +3 -0
- package/dist/commands/monitor.d.ts.map +1 -0
- package/dist/commands/monitor.js +51 -0
- package/dist/commands/monitor.js.map +1 -0
- package/dist/commands/new.d.ts +3 -0
- package/dist/commands/new.d.ts.map +1 -0
- package/dist/commands/new.js +252 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +79 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/project.d.ts +13 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +149 -0
- package/dist/utils/project.js.map +1 -0
- package/package.json +87 -0
- package/templates/.env.example.template +9 -0
- package/templates/.gitignore.template +31 -0
- package/templates/README.md.template +33 -0
- package/templates/advanced/src/components/assistant.js.template +66 -0
- package/templates/advanced/src/components/assistant.ts.template +71 -0
- package/templates/advanced/src/index.js.template +45 -0
- package/templates/advanced/src/index.ts.template +45 -0
- package/templates/basic/src/config/index.js.template +28 -0
- package/templates/basic/src/config/index.ts.template +28 -0
- package/templates/basic/src/index.js.template +29 -0
- package/templates/basic/src/index.ts.template +29 -0
- package/templates/package.json.template +21 -0
- package/templates/tsconfig.json.template +17 -0
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@acip/cli",
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "Command Line Interface for ACIP",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"acip": "./bin/acip.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"bin",
|
|
14
|
+
"templates",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public",
|
|
25
|
+
"registry": "https://registry.npmjs.org/"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"dev": "tsc -w",
|
|
30
|
+
"clean": "rimraf dist",
|
|
31
|
+
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
|
|
32
|
+
"test:watch": "NODE_OPTIONS='--experimental-vm-modules' jest --watch",
|
|
33
|
+
"test:coverage": "NODE_OPTIONS='--experimental-vm-modules' jest --coverage",
|
|
34
|
+
"lint": "eslint src --ext .ts",
|
|
35
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
36
|
+
"prepublishOnly": "npm run build"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"acip",
|
|
40
|
+
"cli",
|
|
41
|
+
"ai",
|
|
42
|
+
"context",
|
|
43
|
+
"intelligence",
|
|
44
|
+
"protocol"
|
|
45
|
+
],
|
|
46
|
+
"author": "ACIP Team",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/Baozhi888/acip.git"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"chalk": "^4.1.2",
|
|
54
|
+
"chokidar": "^3.6.0",
|
|
55
|
+
"commander": "^11.1.0",
|
|
56
|
+
"conf": "^10.2.0",
|
|
57
|
+
"fs-extra": "^11.2.0",
|
|
58
|
+
"ora": "^5.4.1",
|
|
59
|
+
"express": "^4.17.1",
|
|
60
|
+
"swagger-jsdoc": "^6.1.0",
|
|
61
|
+
"swagger-ui-express": "^4.1.6",
|
|
62
|
+
"inquirer": "^8.2.5",
|
|
63
|
+
"update-notifier": "^6.0.2",
|
|
64
|
+
"boxen": "^7.1.1",
|
|
65
|
+
"open": "^8.4.2"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/fs-extra": "^11.0.4",
|
|
69
|
+
"@types/node": "^20.11.5",
|
|
70
|
+
"@types/express": "^4.17.13",
|
|
71
|
+
"@types/swagger-jsdoc": "^6.0.1",
|
|
72
|
+
"@types/swagger-ui-express": "^4.1.3",
|
|
73
|
+
"@types/inquirer": "^8.2.5",
|
|
74
|
+
"@types/update-notifier": "^6.0.8",
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^6.19.1",
|
|
76
|
+
"@typescript-eslint/parser": "^6.19.1",
|
|
77
|
+
"eslint": "^8.56.0",
|
|
78
|
+
"jest": "^30.0.5",
|
|
79
|
+
"@types/jest": "^30.0.0",
|
|
80
|
+
"ts-jest": "^29.4.1",
|
|
81
|
+
"rimraf": "^5.0.5",
|
|
82
|
+
"typescript": "^5.3.3"
|
|
83
|
+
},
|
|
84
|
+
"engines": {
|
|
85
|
+
"node": ">=18.0.0"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# dependencies
|
|
2
|
+
node_modules
|
|
3
|
+
/.pnp
|
|
4
|
+
.pnp.js
|
|
5
|
+
|
|
6
|
+
# testing
|
|
7
|
+
/coverage
|
|
8
|
+
|
|
9
|
+
# production
|
|
10
|
+
/build
|
|
11
|
+
/dist
|
|
12
|
+
|
|
13
|
+
# misc
|
|
14
|
+
.DS_Store
|
|
15
|
+
*.pem
|
|
16
|
+
|
|
17
|
+
# debug
|
|
18
|
+
npm-debug.log*
|
|
19
|
+
yarn-debug.log*
|
|
20
|
+
yarn-error.log*
|
|
21
|
+
|
|
22
|
+
# local env files
|
|
23
|
+
.env
|
|
24
|
+
.env.local
|
|
25
|
+
.env.development.local
|
|
26
|
+
.env.test.local
|
|
27
|
+
.env.production.local
|
|
28
|
+
|
|
29
|
+
# IDE
|
|
30
|
+
.idea
|
|
31
|
+
.vscode
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
This project was created with [ACIP CLI](https://acip.dev).
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
First, install the dependencies:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install
|
|
11
|
+
# or
|
|
12
|
+
yarn
|
|
13
|
+
# or
|
|
14
|
+
pnpm install
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Then, run the development server:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm run dev
|
|
21
|
+
# or
|
|
22
|
+
yarn dev
|
|
23
|
+
# or
|
|
24
|
+
pnpm dev
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Learn More
|
|
28
|
+
|
|
29
|
+
To learn more about ACIP, check out the [ACIP documentation](https://acip.dev/docs).
|
|
30
|
+
|
|
31
|
+
## Deploy
|
|
32
|
+
|
|
33
|
+
Follow the [deployment documentation](https://acip.dev/docs/deployment) to deploy your ACIP application.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 创建AI助手实例
|
|
3
|
+
*/
|
|
4
|
+
export function createAssistant(acip) {
|
|
5
|
+
// 创建助手实例
|
|
6
|
+
const assistant = acip.createAssistant({
|
|
7
|
+
name: 'ACIP Guide',
|
|
8
|
+
description: 'An assistant that helps with understanding ACIP concepts and features.',
|
|
9
|
+
instructions: `
|
|
10
|
+
You are ACIP Guide, an AI assistant specializing in the Adaptive Contextual Intelligence Protocol.
|
|
11
|
+
Provide helpful, accurate, and concise information about ACIP's features, architecture, and usage.
|
|
12
|
+
When asked about technical details, include code examples when appropriate.
|
|
13
|
+
If you don't know something, admit it rather than making up information.
|
|
14
|
+
`,
|
|
15
|
+
tools: [
|
|
16
|
+
{
|
|
17
|
+
name: 'getCurrentTime',
|
|
18
|
+
description: 'Get the current time',
|
|
19
|
+
parameters: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {},
|
|
22
|
+
required: []
|
|
23
|
+
},
|
|
24
|
+
handler: async () => {
|
|
25
|
+
return {
|
|
26
|
+
time: new Date().toISOString()
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
model: {
|
|
32
|
+
provider: 'openai',
|
|
33
|
+
modelId: 'gpt-4'
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// 扩展助手功能
|
|
38
|
+
const enhancedAssistant = {
|
|
39
|
+
...assistant,
|
|
40
|
+
|
|
41
|
+
// 发送消息并返回响应
|
|
42
|
+
async sendMessage(content, options = {}) {
|
|
43
|
+
console.log('Sending message to assistant:', content);
|
|
44
|
+
|
|
45
|
+
// 调用原始sendMessage方法
|
|
46
|
+
const response = await assistant.sendMessage(content, options);
|
|
47
|
+
|
|
48
|
+
// 记录响应
|
|
49
|
+
console.log('Received response from assistant');
|
|
50
|
+
|
|
51
|
+
return response;
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
// 获取对话历史
|
|
55
|
+
getHistory() {
|
|
56
|
+
return assistant.getConversation().getMessages();
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
// 清除对话历史
|
|
60
|
+
clearHistory() {
|
|
61
|
+
return assistant.getConversation().clear();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return enhancedAssistant;
|
|
66
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ACIP, Assistant, SendMessageOptions } from '@acip/sdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 创建AI助手实例
|
|
5
|
+
*/
|
|
6
|
+
export function createAssistant(acip: ACIP) {
|
|
7
|
+
// 创建助手实例
|
|
8
|
+
const assistant = acip.createAssistant({
|
|
9
|
+
name: 'ACIP Guide',
|
|
10
|
+
description: 'An assistant that helps with understanding ACIP concepts and features.',
|
|
11
|
+
instructions: `
|
|
12
|
+
You are ACIP Guide, an AI assistant specializing in the Adaptive Contextual Intelligence Protocol.
|
|
13
|
+
Provide helpful, accurate, and concise information about ACIP's features, architecture, and usage.
|
|
14
|
+
When asked about technical details, include code examples when appropriate.
|
|
15
|
+
If you don't know something, admit it rather than making up information.
|
|
16
|
+
`,
|
|
17
|
+
tools: [
|
|
18
|
+
{
|
|
19
|
+
name: 'getCurrentTime',
|
|
20
|
+
description: 'Get the current time',
|
|
21
|
+
parameters: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {},
|
|
24
|
+
required: []
|
|
25
|
+
},
|
|
26
|
+
handler: async () => {
|
|
27
|
+
return {
|
|
28
|
+
time: new Date().toISOString()
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
model: {
|
|
34
|
+
provider: 'openai',
|
|
35
|
+
modelId: 'gpt-4'
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// 扩展助手功能
|
|
40
|
+
const enhancedAssistant = {
|
|
41
|
+
...assistant,
|
|
42
|
+
|
|
43
|
+
// 发送消息并返回响应
|
|
44
|
+
async sendMessage(
|
|
45
|
+
content: string,
|
|
46
|
+
options?: SendMessageOptions
|
|
47
|
+
) {
|
|
48
|
+
console.log('Sending message to assistant:', content);
|
|
49
|
+
|
|
50
|
+
// 调用原始sendMessage方法
|
|
51
|
+
const response = await assistant.sendMessage(content, options || {});
|
|
52
|
+
|
|
53
|
+
// 记录响应
|
|
54
|
+
console.log('Received response from assistant');
|
|
55
|
+
|
|
56
|
+
return response;
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
// 获取对话历史
|
|
60
|
+
getHistory() {
|
|
61
|
+
return assistant.getConversation().getMessages();
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
// 清除对话历史
|
|
65
|
+
clearHistory() {
|
|
66
|
+
return assistant.getConversation().clear();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return enhancedAssistant;
|
|
71
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ACIP } from '@acip/sdk';
|
|
2
|
+
import { createAssistant } from './components/assistant.js';
|
|
3
|
+
import 'dotenv/config';
|
|
4
|
+
|
|
5
|
+
async function main() {
|
|
6
|
+
// 初始化ACIP SDK
|
|
7
|
+
const acip = new ACIP({
|
|
8
|
+
apiKey: process.env.ACIP_API_KEY,
|
|
9
|
+
defaultModelId: process.env.DEFAULT_MODEL_ID || 'gpt-4',
|
|
10
|
+
cacheEnabled: true,
|
|
11
|
+
logger: {
|
|
12
|
+
level: 'info'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// 创建并启动助手
|
|
17
|
+
const assistant = createAssistant(acip);
|
|
18
|
+
|
|
19
|
+
// 注册事件监听器
|
|
20
|
+
acip.on('modelInvocation:start', (data) => {
|
|
21
|
+
console.log(`Model invocation started with ID: ${data.invocationId}`);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
acip.on('modelInvocation:complete', (data) => {
|
|
25
|
+
console.log(`Model invocation completed in ${data.metrics.latency}ms`);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// 与助手互动
|
|
29
|
+
try {
|
|
30
|
+
const response = await assistant.sendMessage(
|
|
31
|
+
'Hello! I want to learn about adaptive context management in AI systems.'
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
console.log('Assistant Response:', response.content);
|
|
35
|
+
|
|
36
|
+
// 获取对话历史
|
|
37
|
+
const history = assistant.getHistory();
|
|
38
|
+
console.log(`Conversation has ${history.length} messages`);
|
|
39
|
+
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error('Error:', error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ACIP } from '@acip/sdk';
|
|
2
|
+
import { createAssistant } from './components/assistant.js';
|
|
3
|
+
import 'dotenv/config';
|
|
4
|
+
|
|
5
|
+
async function main(): Promise<void> {
|
|
6
|
+
// 初始化ACIP SDK
|
|
7
|
+
const acip = new ACIP({
|
|
8
|
+
apiKey: process.env.ACIP_API_KEY,
|
|
9
|
+
defaultModelId: process.env.DEFAULT_MODEL_ID || 'gpt-4',
|
|
10
|
+
cacheEnabled: true,
|
|
11
|
+
logger: {
|
|
12
|
+
level: 'info'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// 创建并启动助手
|
|
17
|
+
const assistant = createAssistant(acip);
|
|
18
|
+
|
|
19
|
+
// 注册事件监听器
|
|
20
|
+
acip.on('modelInvocation:start', (data) => {
|
|
21
|
+
console.log(`Model invocation started with ID: ${data.invocationId}`);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
acip.on('modelInvocation:complete', (data) => {
|
|
25
|
+
console.log(`Model invocation completed in ${data.metrics.latency}ms`);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// 与助手互动
|
|
29
|
+
try {
|
|
30
|
+
const response = await assistant.sendMessage(
|
|
31
|
+
'Hello! I want to learn about adaptive context management in AI systems.'
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
console.log('Assistant Response:', response.content);
|
|
35
|
+
|
|
36
|
+
// 获取对话历史
|
|
37
|
+
const history = assistant.getHistory();
|
|
38
|
+
console.log(`Conversation has ${history.length} messages`);
|
|
39
|
+
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error('Error:', error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// 应用配置
|
|
2
|
+
export const appConfig = {
|
|
3
|
+
name: 'ACIP Example App',
|
|
4
|
+
version: '0.1.0',
|
|
5
|
+
description: 'An example application using ACIP SDK',
|
|
6
|
+
port: process.env.APP_PORT || 3000,
|
|
7
|
+
environment: process.env.NODE_ENV || 'development'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// AI模型配置
|
|
11
|
+
export const modelConfig = {
|
|
12
|
+
defaultModelId: process.env.DEFAULT_MODEL_ID || 'gpt-4',
|
|
13
|
+
fallbackModelId: 'gpt-3.5-turbo',
|
|
14
|
+
maxTokens: 8192,
|
|
15
|
+
temperature: 0.7,
|
|
16
|
+
topP: 1,
|
|
17
|
+
cacheEnabled: true,
|
|
18
|
+
cacheTTL: 3600 // 1小时
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// 安全配置
|
|
22
|
+
export const securityConfig = {
|
|
23
|
+
contentModerationEnabled: true,
|
|
24
|
+
rateLimit: {
|
|
25
|
+
windowMs: 15 * 60 * 1000, // 15分钟
|
|
26
|
+
max: 100 // 每个IP限制请求数
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// 应用配置
|
|
2
|
+
export const appConfig: Record<string, any> = {
|
|
3
|
+
name: 'ACIP Example App',
|
|
4
|
+
version: '0.1.0',
|
|
5
|
+
description: 'An example application using ACIP SDK',
|
|
6
|
+
port: process.env.APP_PORT || 3000,
|
|
7
|
+
environment: process.env.NODE_ENV || 'development'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// AI模型配置
|
|
11
|
+
export const modelConfig: Record<string, any> = {
|
|
12
|
+
defaultModelId: process.env.DEFAULT_MODEL_ID || 'gpt-4',
|
|
13
|
+
fallbackModelId: 'gpt-3.5-turbo',
|
|
14
|
+
maxTokens: 8192,
|
|
15
|
+
temperature: 0.7,
|
|
16
|
+
topP: 1,
|
|
17
|
+
cacheEnabled: true,
|
|
18
|
+
cacheTTL: 3600 // 1小时
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// 安全配置
|
|
22
|
+
export const securityConfig: Record<string, any> = {
|
|
23
|
+
contentModerationEnabled: true,
|
|
24
|
+
rateLimit: {
|
|
25
|
+
windowMs: 15 * 60 * 1000, // 15分钟
|
|
26
|
+
max: 100 // 每个IP限制请求数
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ACIP } from '@acip/sdk';
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
|
|
4
|
+
async function main() {
|
|
5
|
+
// 初始化ACIP SDK
|
|
6
|
+
const acip = new ACIP({
|
|
7
|
+
apiKey: process.env.ACIP_API_KEY,
|
|
8
|
+
defaultModelId: process.env.DEFAULT_MODEL_ID || 'gpt-4'
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// 简单的模型调用示例
|
|
12
|
+
try {
|
|
13
|
+
const response = await acip.modelInvocation.invoke({
|
|
14
|
+
messages: [
|
|
15
|
+
{ role: 'system', content: 'You are a helpful assistant.' },
|
|
16
|
+
{ role: 'user', content: 'Hello! What can you tell me about ACIP?' }
|
|
17
|
+
]
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
console.log('AI Response:', response.content);
|
|
21
|
+
|
|
22
|
+
// 输出使用的tokens和延迟
|
|
23
|
+
console.log('Metrics:', response.metrics);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error('Error:', error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ACIP } from '@acip/sdk';
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
|
|
4
|
+
async function main(): Promise<void> {
|
|
5
|
+
// 初始化ACIP SDK
|
|
6
|
+
const acip = new ACIP({
|
|
7
|
+
apiKey: process.env.ACIP_API_KEY,
|
|
8
|
+
defaultModelId: process.env.DEFAULT_MODEL_ID || 'gpt-4'
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// 简单的模型调用示例
|
|
12
|
+
try {
|
|
13
|
+
const response = await acip.modelInvocation.invoke({
|
|
14
|
+
messages: [
|
|
15
|
+
{ role: 'system', content: 'You are a helpful assistant.' },
|
|
16
|
+
{ role: 'user', content: 'Hello! What can you tell me about ACIP?' }
|
|
17
|
+
]
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
console.log('AI Response:', response.content);
|
|
21
|
+
|
|
22
|
+
// 输出使用的tokens和延迟
|
|
23
|
+
console.log('Metrics:', response.metrics);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error('Error:', error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "An ACIP (Adaptive Contextual Intelligence Protocol) project",
|
|
5
|
+
"main": "{{mainFile}}",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "{{startCommand}}",
|
|
9
|
+
"dev": "{{devCommand}}",
|
|
10
|
+
"build": "{{buildCommand}}",
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
+
},
|
|
13
|
+
"keywords": ["acip", "ai", "contextual-intelligence"],
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@acip/sdk": "^0.1.0",
|
|
18
|
+
"dotenv": "^16.3.1"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {{devDependencies}}
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"declaration": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*"],
|
|
16
|
+
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
|
17
|
+
}
|