langtrain 0.2.2 → 0.2.4
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/dist/cli.js +12 -12
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +12 -12
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -2
- package/src/cli/auth.ts +8 -3
- package/src/cli/index.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langtrain",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Unified JavaScript SDK for Langtrain Ecosystem",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"form-data": "^4.0.5",
|
|
46
46
|
"gradient-string": "^3.0.0",
|
|
47
47
|
"kleur": "^4.1.5",
|
|
48
|
-
"langtrain": "^0.1.15",
|
|
49
48
|
"langtune": "^0.1.1",
|
|
50
49
|
"langvision": "^0.1.1"
|
|
51
50
|
}
|
package/src/cli/auth.ts
CHANGED
|
@@ -6,7 +6,12 @@ import { exec } from 'child_process';
|
|
|
6
6
|
import { promisify } from 'util';
|
|
7
7
|
|
|
8
8
|
const execAsync = promisify(exec);
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
function getApiBase() {
|
|
11
|
+
const config = getConfig();
|
|
12
|
+
const base = (config.baseUrl || 'https://api.langtrain.ai').replace(/\/$/, '');
|
|
13
|
+
return `${base}/api/v1`;
|
|
14
|
+
}
|
|
10
15
|
|
|
11
16
|
async function openBrowser(url: string) {
|
|
12
17
|
try {
|
|
@@ -55,7 +60,7 @@ export async function handleLogin() {
|
|
|
55
60
|
|
|
56
61
|
try {
|
|
57
62
|
// 1. Request device code
|
|
58
|
-
const { data: codeData } = await axios.post(`${
|
|
63
|
+
const { data: codeData } = await axios.post(`${getApiBase()}/auth/device/code`);
|
|
59
64
|
const { device_code, user_code, verification_url, expires_in, interval } = codeData;
|
|
60
65
|
|
|
61
66
|
s.stop(green('Connected.'));
|
|
@@ -80,7 +85,7 @@ export async function handleLogin() {
|
|
|
80
85
|
|
|
81
86
|
while (Date.now() - startTime < timeout) {
|
|
82
87
|
try {
|
|
83
|
-
const { data: tokenData } = await axios.post(`${
|
|
88
|
+
const { data: tokenData } = await axios.post(`${getApiBase()}/auth/device/token?device_code=${device_code}`);
|
|
84
89
|
|
|
85
90
|
if (tokenData.status === 'approved') {
|
|
86
91
|
const apiKey = tokenData.api_key;
|