travel-agent-cli 0.2.1 → 0.2.2
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/package.json +1 -1
- package/python/pyproject.toml +1 -1
- package/scripts/postinstall.js +59 -65
package/package.json
CHANGED
package/python/pyproject.toml
CHANGED
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "travel-agent"
|
|
7
|
-
version = "0.1
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "AI-powered travel destination recommendation agent"
|
|
9
9
|
authors = [{ name = "Your Name", email = "your.email@example.com" }]
|
|
10
10
|
readme = "README.md"
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,104 +1,98 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* npm 安装后执行的脚本
|
|
4
|
-
*
|
|
4
|
+
* 安装 Python 依赖
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const { execSync } = require('child_process');
|
|
8
8
|
const fs = require('fs');
|
|
9
9
|
const path = require('path');
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const packagePath = path.join(__dirname, '..');
|
|
12
|
+
const pythonDir = path.join(packagePath, 'python');
|
|
13
13
|
|
|
14
14
|
console.log('╭───────────────────────────────────────────────────────────────╮');
|
|
15
|
-
console.log('│ travel-agent-cli
|
|
15
|
+
console.log('│ travel-agent-cli 正在安装 Python 依赖... │');
|
|
16
16
|
console.log('╰───────────────────────────────────────────────────────────────╯\n');
|
|
17
17
|
|
|
18
18
|
// 检查 Python
|
|
19
|
-
function
|
|
19
|
+
function findPython() {
|
|
20
20
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return true;
|
|
21
|
+
execSync('python3 --version', { stdio: 'ignore' });
|
|
22
|
+
return 'python3';
|
|
24
23
|
} catch (e) {
|
|
25
24
|
try {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return true;
|
|
25
|
+
execSync('python --version', { stdio: 'ignore' });
|
|
26
|
+
return 'python';
|
|
29
27
|
} catch (e2) {
|
|
30
|
-
|
|
31
|
-
console.error('\n请先安装 Python 3.10+:');
|
|
32
|
-
console.error(' macOS: brew install python@3.10');
|
|
33
|
-
console.error(' Linux: sudo apt install python3.10');
|
|
34
|
-
console.error(' Windows: https://www.python.org/downloads/');
|
|
35
|
-
return false;
|
|
28
|
+
return null;
|
|
36
29
|
}
|
|
37
30
|
}
|
|
38
31
|
}
|
|
39
32
|
|
|
40
|
-
//
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} catch (e2) {
|
|
52
|
-
console.error('✗ pip: 未找到');
|
|
53
|
-
console.error(' 安装:https://pip.pypa.io/en/stable/installation/');
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
33
|
+
// 安装依赖
|
|
34
|
+
function installDependencies() {
|
|
35
|
+
const pythonCmd = findPython();
|
|
36
|
+
|
|
37
|
+
if (!pythonCmd) {
|
|
38
|
+
console.error('\n⚠ 警告:未找到 Python');
|
|
39
|
+
console.error('请先安装 Python 3.10+');
|
|
40
|
+
console.error(' macOS: brew install python@3.10');
|
|
41
|
+
console.error(' Linux: sudo apt install python3.10');
|
|
42
|
+
console.error(' Windows: https://www.python.org/downloads/');
|
|
43
|
+
return false;
|
|
56
44
|
}
|
|
57
|
-
}
|
|
58
45
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
46
|
+
console.log(`使用 Python: ${pythonCmd}\n`);
|
|
47
|
+
|
|
48
|
+
// 检查 pyproject.toml 是否存在
|
|
49
|
+
const pyprojectPath = path.join(pythonDir, 'pyproject.toml');
|
|
50
|
+
if (!fs.existsSync(pyprojectPath)) {
|
|
51
|
+
console.error(`⚠ 未找到 pyproject.toml`);
|
|
52
|
+
return false;
|
|
64
53
|
}
|
|
65
|
-
console.log(`○ 虚拟环境:未创建(首次运行会自动创建)`);
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
54
|
|
|
69
|
-
// 检查 Playwright
|
|
70
|
-
function checkPlaywright() {
|
|
71
55
|
try {
|
|
72
|
-
|
|
73
|
-
console.log(
|
|
56
|
+
// 使用 pip install -e 安装可编辑模式
|
|
57
|
+
console.log('正在安装 Python 依赖...');
|
|
58
|
+
execSync(`${pythonCmd} -m pip install -e "${pythonDir}"`, {
|
|
59
|
+
stdio: 'inherit',
|
|
60
|
+
env: { ...process.env, PIP_NO_INPUT: '1' }
|
|
61
|
+
});
|
|
62
|
+
console.log('\n✓ Python 依赖安装完成\n');
|
|
74
63
|
return true;
|
|
75
64
|
} catch (e) {
|
|
76
|
-
console.
|
|
65
|
+
console.error('\n⚠ Python 依赖安装失败');
|
|
66
|
+
console.error('\n手动安装:');
|
|
67
|
+
console.error(` ${pythonCmd} -m pip install -e "${pythonDir}"`);
|
|
77
68
|
return false;
|
|
78
69
|
}
|
|
79
70
|
}
|
|
80
71
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
checkVenv();
|
|
85
|
-
checkPlaywright();
|
|
72
|
+
// 主函数
|
|
73
|
+
function main() {
|
|
74
|
+
const success = installDependencies();
|
|
86
75
|
|
|
87
|
-
|
|
88
|
-
console.log('
|
|
89
|
-
console.log('
|
|
76
|
+
if (success) {
|
|
77
|
+
console.log('╭───────────────────────────────────────────────────────────────╮');
|
|
78
|
+
console.log('│ 安装完成!快速开始: │');
|
|
79
|
+
console.log('╰───────────────────────────────────────────────────────────────╯\n');
|
|
80
|
+
|
|
81
|
+
console.log('1. 初始化配置:');
|
|
82
|
+
console.log(' travel-agent config --init\n');
|
|
90
83
|
|
|
91
|
-
console.log('
|
|
92
|
-
console.log('
|
|
84
|
+
console.log('2. 配置 LLM API Key:');
|
|
85
|
+
console.log(' 编辑 .env 文件,填入你的 API Key\n');
|
|
93
86
|
|
|
94
|
-
console.log('
|
|
95
|
-
console.log('
|
|
87
|
+
console.log('3. 查看支持的模型:');
|
|
88
|
+
console.log(' travel-agent model list\n');
|
|
96
89
|
|
|
97
|
-
console.log('
|
|
98
|
-
console.log(' travel-agent
|
|
90
|
+
console.log('4. 运行工作流:');
|
|
91
|
+
console.log(' travel-agent run -k "海岛游"\n');
|
|
99
92
|
|
|
100
|
-
console.log('
|
|
101
|
-
console.log(' travel-agent
|
|
93
|
+
console.log('更多帮助:');
|
|
94
|
+
console.log(' travel-agent --help\n');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
102
97
|
|
|
103
|
-
|
|
104
|
-
console.log(' travel-agent --help\n');
|
|
98
|
+
main();
|