langtrain 0.1.20 → 0.1.21
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 +73 -72
- package/assets/cli-demo.png +0 -0
- package/dist/{chunk-Z7FYIYKL.js → chunk-QZ6U7AJN.js} +12 -12
- package/dist/chunk-QZ6U7AJN.js.map +1 -0
- package/dist/{chunk-D3O435OM.mjs → chunk-TDQXC2RA.mjs} +12 -12
- package/dist/chunk-TDQXC2RA.mjs.map +1 -0
- package/dist/cli.js +8 -8
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +8 -8
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +40 -1
- package/dist/index.d.ts +40 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -1
- package/src/cli/auth.ts +2 -2
- package/src/cli/components/Table.ts +20 -0
- package/src/cli/handlers/agent.ts +15 -2
- package/src/cli/handlers/logs.ts +2 -2
- package/src/cli/handlers/subscription.ts +2 -2
- package/src/cli/handlers/tune.ts +18 -8
- package/src/cli/handlers/vision.ts +2 -2
- package/src/cli/ui.ts +2 -0
- package/dist/chunk-D3O435OM.mjs.map +0 -1
- package/dist/chunk-Z7FYIYKL.js.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -210,4 +210,43 @@ declare namespace secrets {
|
|
|
210
210
|
export { type secrets_Secret as Secret, secrets_SecretClient as SecretClient };
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
|
|
213
|
+
interface GuardrailConfig {
|
|
214
|
+
pii_enabled: boolean;
|
|
215
|
+
pii_entities?: string[];
|
|
216
|
+
profanity_enabled: boolean;
|
|
217
|
+
profanity_threshold?: number;
|
|
218
|
+
blocked_topics?: string[];
|
|
219
|
+
regex_patterns?: string[];
|
|
220
|
+
min_length?: number;
|
|
221
|
+
max_length?: number;
|
|
222
|
+
}
|
|
223
|
+
interface Guardrail {
|
|
224
|
+
id: string;
|
|
225
|
+
workspace_id: string;
|
|
226
|
+
name: string;
|
|
227
|
+
description?: string;
|
|
228
|
+
config: GuardrailConfig;
|
|
229
|
+
is_active: boolean;
|
|
230
|
+
created_at: string;
|
|
231
|
+
updated_at: string;
|
|
232
|
+
}
|
|
233
|
+
interface GuardrailCreate {
|
|
234
|
+
name: string;
|
|
235
|
+
description?: string;
|
|
236
|
+
config: GuardrailConfig;
|
|
237
|
+
}
|
|
238
|
+
declare class GuardrailClient {
|
|
239
|
+
private config;
|
|
240
|
+
private client;
|
|
241
|
+
constructor(config: {
|
|
242
|
+
apiKey: string;
|
|
243
|
+
baseUrl?: string;
|
|
244
|
+
});
|
|
245
|
+
list(workspaceId?: string): Promise<Guardrail[]>;
|
|
246
|
+
get(guardrailId: string): Promise<Guardrail>;
|
|
247
|
+
create(data: GuardrailCreate): Promise<Guardrail>;
|
|
248
|
+
delete(guardrailId: string): Promise<void>;
|
|
249
|
+
apply(datasetId: string, guardrailId: string): Promise<any>;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export { type Agent, AgentClient, type AgentCreate, type AgentRun, agent as AgentTypes, type FeatureCheck, FileClient, type FileResponse, type FineTuneJobCreate, type FineTuneJobResponse, type Guardrail, GuardrailClient, type GuardrailConfig, type GuardrailCreate, type Model, ModelClient, models as ModelTypes, type Secret, SecretClient, secrets as SecretTypes, SubscriptionClient, type SubscriptionInfo, TrainingClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -210,4 +210,43 @@ declare namespace secrets {
|
|
|
210
210
|
export { type secrets_Secret as Secret, secrets_SecretClient as SecretClient };
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
|
|
213
|
+
interface GuardrailConfig {
|
|
214
|
+
pii_enabled: boolean;
|
|
215
|
+
pii_entities?: string[];
|
|
216
|
+
profanity_enabled: boolean;
|
|
217
|
+
profanity_threshold?: number;
|
|
218
|
+
blocked_topics?: string[];
|
|
219
|
+
regex_patterns?: string[];
|
|
220
|
+
min_length?: number;
|
|
221
|
+
max_length?: number;
|
|
222
|
+
}
|
|
223
|
+
interface Guardrail {
|
|
224
|
+
id: string;
|
|
225
|
+
workspace_id: string;
|
|
226
|
+
name: string;
|
|
227
|
+
description?: string;
|
|
228
|
+
config: GuardrailConfig;
|
|
229
|
+
is_active: boolean;
|
|
230
|
+
created_at: string;
|
|
231
|
+
updated_at: string;
|
|
232
|
+
}
|
|
233
|
+
interface GuardrailCreate {
|
|
234
|
+
name: string;
|
|
235
|
+
description?: string;
|
|
236
|
+
config: GuardrailConfig;
|
|
237
|
+
}
|
|
238
|
+
declare class GuardrailClient {
|
|
239
|
+
private config;
|
|
240
|
+
private client;
|
|
241
|
+
constructor(config: {
|
|
242
|
+
apiKey: string;
|
|
243
|
+
baseUrl?: string;
|
|
244
|
+
});
|
|
245
|
+
list(workspaceId?: string): Promise<Guardrail[]>;
|
|
246
|
+
get(guardrailId: string): Promise<Guardrail>;
|
|
247
|
+
create(data: GuardrailCreate): Promise<Guardrail>;
|
|
248
|
+
delete(guardrailId: string): Promise<void>;
|
|
249
|
+
apply(datasetId: string, guardrailId: string): Promise<any>;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export { type Agent, AgentClient, type AgentCreate, type AgentRun, agent as AgentTypes, type FeatureCheck, FileClient, type FileResponse, type FineTuneJobCreate, type FineTuneJobResponse, type Guardrail, GuardrailClient, type GuardrailConfig, type GuardrailCreate, type Model, ModelClient, models as ModelTypes, type Secret, SecretClient, secrets as SecretTypes, SubscriptionClient, type SubscriptionInfo, TrainingClient };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkQZ6U7AJN_js=require('./chunk-QZ6U7AJN.js');chunkQZ6U7AJN_js.r();Object.defineProperty(exports,"AgentClient",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.h}});Object.defineProperty(exports,"AgentTypes",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.i}});Object.defineProperty(exports,"FileClient",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.j}});Object.defineProperty(exports,"GuardrailClient",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.q}});Object.defineProperty(exports,"Langtune",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.f}});Object.defineProperty(exports,"Langvision",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.d}});Object.defineProperty(exports,"ModelClient",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.m}});Object.defineProperty(exports,"ModelTypes",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.n}});Object.defineProperty(exports,"SecretClient",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.o}});Object.defineProperty(exports,"SecretTypes",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.p}});Object.defineProperty(exports,"SubscriptionClient",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.l}});Object.defineProperty(exports,"Text",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.g}});Object.defineProperty(exports,"TrainingClient",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.k}});Object.defineProperty(exports,"Vision",{enumerable:true,get:function(){return chunkQZ6U7AJN_js.e}});//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {r}from'./chunk-TDQXC2RA.mjs';export{h as AgentClient,i as AgentTypes,j as FileClient,q as GuardrailClient,f as Langtune,d as Langvision,m as ModelClient,n as ModelTypes,o as SecretClient,p as SecretTypes,l as SubscriptionClient,g as Text,k as TrainingClient,e as Vision}from'./chunk-TDQXC2RA.mjs';r();//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langtrain",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "Unified JavaScript SDK for Langtrain Ecosystem",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@clack/prompts": "^1.0.1",
|
|
43
43
|
"axios": "^1.13.5",
|
|
44
|
+
"cli-table3": "^0.6.5",
|
|
44
45
|
"commander": "^14.0.3",
|
|
45
46
|
"gradient-string": "^3.0.0",
|
|
46
47
|
"kleur": "^4.1.5",
|
package/src/cli/auth.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { password, isCancel, cancel, intro, green, yellow, red,
|
|
1
|
+
import { password, isCancel, cancel, intro, green, yellow, red, bgMagenta, black, spinner, gray } from './ui';
|
|
2
2
|
import { getConfig, saveConfig } from './config';
|
|
3
3
|
import { SubscriptionClient, SubscriptionInfo } from '../index';
|
|
4
4
|
|
|
@@ -58,7 +58,7 @@ export async function getSubscription(apiKey: string): Promise<SubscriptionInfo
|
|
|
58
58
|
const info = await client.getStatus();
|
|
59
59
|
|
|
60
60
|
// Enhance: Show plan details immediately on auth check
|
|
61
|
-
const planLabel = info.plan === 'pro' ?
|
|
61
|
+
const planLabel = info.plan === 'pro' ? bgMagenta(' PRO ') : info.plan.toUpperCase();
|
|
62
62
|
s.stop(green(`Authenticated as ${planLabel}`));
|
|
63
63
|
|
|
64
64
|
if (info.is_active === false) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Table from 'cli-table3';
|
|
2
|
+
import { colors } from '../ui';
|
|
3
|
+
|
|
4
|
+
export function createTable(headers: string[]) {
|
|
5
|
+
return new Table({
|
|
6
|
+
head: headers.map(h => colors.magenta(colors.bold(h))),
|
|
7
|
+
chars: {
|
|
8
|
+
'top': '─', 'top-mid': '┬', 'top-left': '┌', 'top-right': '┐',
|
|
9
|
+
'bottom': '─', 'bottom-mid': '┴', 'bottom-left': '└', 'bottom-right': '┘',
|
|
10
|
+
'left': '│', 'left-mid': '├', 'mid': '─', 'mid-mid': '┼',
|
|
11
|
+
'right': '│', 'right-mid': '┤', 'middle': '│'
|
|
12
|
+
},
|
|
13
|
+
style: {
|
|
14
|
+
'padding-left': 1,
|
|
15
|
+
'padding-right': 1,
|
|
16
|
+
head: [], // handle colors manually
|
|
17
|
+
border: ['gray']
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { text, select, confirm, isCancel, cancel, spinner, intro, red, green, yellow, gray,
|
|
1
|
+
import { text, select, confirm, isCancel, cancel, spinner, intro, red, green, yellow, gray, bgMagenta, black, gradient, createTable } from '../ui';
|
|
2
2
|
import { AgentClient, ModelClient } from '../../index';
|
|
3
3
|
|
|
4
4
|
export async function handleAgentCreate(client: AgentClient, modelClient: ModelClient) {
|
|
@@ -136,6 +136,19 @@ export async function handleAgentList(client: AgentClient) {
|
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
// Display Table
|
|
140
|
+
const table = createTable(['ID', 'Name', 'Model', 'Created']);
|
|
141
|
+
agents.forEach(a => {
|
|
142
|
+
table.push([
|
|
143
|
+
a.id.substring(0, 8) + '...',
|
|
144
|
+
a.name,
|
|
145
|
+
(a.config as any)?.model || 'default',
|
|
146
|
+
new Date(a.created_at).toLocaleDateString()
|
|
147
|
+
]);
|
|
148
|
+
});
|
|
149
|
+
console.log(table.toString());
|
|
150
|
+
console.log(''); // spacer
|
|
151
|
+
|
|
139
152
|
const agentId = await select({
|
|
140
153
|
message: 'Select an agent to run:',
|
|
141
154
|
options: agents.map(a => ({ value: a.id, label: a.name, hint: a.description || 'No description' }))
|
|
@@ -147,7 +160,7 @@ export async function handleAgentList(client: AgentClient) {
|
|
|
147
160
|
}
|
|
148
161
|
|
|
149
162
|
export async function handleAgentRun(client: AgentClient, agentId: string, agentName: string, initialMessage?: string) {
|
|
150
|
-
intro(
|
|
163
|
+
intro(bgMagenta(black(` Chatting with ${agentName} `)));
|
|
151
164
|
console.log(gray('Type "exit" to quit conversation.'));
|
|
152
165
|
|
|
153
166
|
let conversationId: string | undefined = undefined;
|
package/src/cli/handlers/logs.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { intro, spinner, red, gray, yellow,
|
|
1
|
+
import { intro, spinner, red, gray, yellow, bgMagenta, black, green } from '../ui';
|
|
2
2
|
import { AgentClient } from '../../index';
|
|
3
3
|
import { select, text, isCancel } from '../ui';
|
|
4
4
|
|
|
@@ -54,7 +54,7 @@ export async function handleLogs(client: AgentClient, agentName?: string) {
|
|
|
54
54
|
s2.stop('Logs fetched.');
|
|
55
55
|
|
|
56
56
|
console.log(gray('------------------------------------------------'));
|
|
57
|
-
console.log(`${
|
|
57
|
+
console.log(`${bgMagenta(black(' Recent Logs '))}`);
|
|
58
58
|
if (logs.logs && logs.logs.length > 0) {
|
|
59
59
|
logs.logs.forEach(log => console.log(log));
|
|
60
60
|
} else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spinner, intro, red, green, gray,
|
|
1
|
+
import { spinner, intro, red, green, gray, bgMagenta } from '../ui';
|
|
2
2
|
import { getConfig } from '../config';
|
|
3
3
|
import { SubscriptionClient } from '../../index';
|
|
4
4
|
|
|
@@ -15,7 +15,7 @@ export async function handleSubscriptionStatus() {
|
|
|
15
15
|
const info = await client.getStatus();
|
|
16
16
|
s.stop(green('Subscription Status:'));
|
|
17
17
|
|
|
18
|
-
console.log(gray('Plan: ') + (info.plan === 'pro' ?
|
|
18
|
+
console.log(gray('Plan: ') + (info.plan === 'pro' ? bgMagenta(' PRO ') : info.plan.toUpperCase()));
|
|
19
19
|
console.log(gray('Active: ') + (info.is_active ? green('Yes') : red('No')));
|
|
20
20
|
if (info.expires_at) console.log(gray('Expires: ') + new Date(info.expires_at).toLocaleDateString());
|
|
21
21
|
|
package/src/cli/handlers/tune.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { text, select, confirm, isCancel, cancel, spinner, intro, red, green, yellow,
|
|
1
|
+
import { text, select, confirm, isCancel, cancel, spinner, intro, red, green, yellow, bgMagenta, black, gradient, gray, createTable } from '../ui';
|
|
2
2
|
import { getConfig } from '../config';
|
|
3
3
|
import { Langtune, ModelClient, SubscriptionClient, FileClient, TrainingClient } from '../../index';
|
|
4
4
|
|
|
@@ -73,7 +73,7 @@ export async function handleTuneFinetune(tune: Langtune, modelClient: ModelClien
|
|
|
73
73
|
s.stop(red('Feature "cloud_finetuning" is not available on your plan.'));
|
|
74
74
|
const upgrade = await confirm({ message: 'Upgrade to Pro for cloud tracking?' });
|
|
75
75
|
if (upgrade && !isCancel(upgrade)) {
|
|
76
|
-
console.log(
|
|
76
|
+
console.log(bgMagenta(black(' Visit https://langtrain.ai/dashboard/billing to upgrade. ')));
|
|
77
77
|
}
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
@@ -158,11 +158,6 @@ export async function handleTuneList(trainingClient: TrainingClient) {
|
|
|
158
158
|
const s = spinner();
|
|
159
159
|
s.start('Fetching fine-tuning jobs...');
|
|
160
160
|
|
|
161
|
-
// We need workspace ID, usually from config or first agent?
|
|
162
|
-
// For now, let's just ask or list from all available if API supports it (it requires workspace_id)
|
|
163
|
-
// Let's assume user knows it or we can find it.
|
|
164
|
-
// Simplified: Just ask for Workspace ID if not in config (we don't save it yet)
|
|
165
|
-
// BETTER: Get it from an existing agent or config.
|
|
166
161
|
const config = getConfig();
|
|
167
162
|
let workspaceId = config.workspace_id;
|
|
168
163
|
|
|
@@ -181,6 +176,21 @@ export async function handleTuneList(trainingClient: TrainingClient) {
|
|
|
181
176
|
return;
|
|
182
177
|
}
|
|
183
178
|
|
|
179
|
+
// Display Table
|
|
180
|
+
const table = createTable(['ID', 'Status', 'Model', 'Progress', 'Created']);
|
|
181
|
+
jobs.data.forEach(j => {
|
|
182
|
+
const statusColor = j.status === 'succeeded' ? green : (j.status === 'failed' ? red : yellow);
|
|
183
|
+
table.push([
|
|
184
|
+
j.id.substring(0, 8) + '...',
|
|
185
|
+
statusColor(j.status),
|
|
186
|
+
j.base_model,
|
|
187
|
+
(j.progress || 0) + '%',
|
|
188
|
+
new Date(j.created_at).toLocaleDateString()
|
|
189
|
+
]);
|
|
190
|
+
});
|
|
191
|
+
console.log(table.toString());
|
|
192
|
+
console.log('');
|
|
193
|
+
|
|
184
194
|
const selectedJob = await select({
|
|
185
195
|
message: 'Select a job to view details:',
|
|
186
196
|
options: jobs.data.map(j => ({
|
|
@@ -214,7 +224,7 @@ export async function handleTuneStatus(trainingClient: TrainingClient, jobId?: s
|
|
|
214
224
|
s.stop(`Job Status: ${job.status.toUpperCase()}`);
|
|
215
225
|
|
|
216
226
|
console.log(gray('------------------------------------------------'));
|
|
217
|
-
console.log(`${
|
|
227
|
+
console.log(`${bgMagenta(black(' Job Details '))}`);
|
|
218
228
|
console.log(`ID: ${job.id}`);
|
|
219
229
|
console.log(`Name: ${job.name}`);
|
|
220
230
|
console.log(`Status: ${job.status === 'succeeded' ? green(job.status) : job.status}`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { text, select, confirm, isCancel, cancel, spinner, intro, red, green, yellow,
|
|
1
|
+
import { text, select, confirm, isCancel, cancel, spinner, intro, red, green, yellow, bgMagenta, black, gradient } from '../ui';
|
|
2
2
|
import { getConfig } from '../config';
|
|
3
3
|
import { Langvision, ModelClient, SubscriptionClient, FileClient, TrainingClient } from '../../index';
|
|
4
4
|
|
|
@@ -74,7 +74,7 @@ export async function handleVisionFinetune(vision: Langvision, modelClient: Mode
|
|
|
74
74
|
s.stop(red('Feature "cloud_finetuning" is not available on your plan.'));
|
|
75
75
|
const upgrade = await confirm({ message: 'Upgrade to Pro for cloud tracking?' });
|
|
76
76
|
if (upgrade && !isCancel(upgrade)) {
|
|
77
|
-
console.log(
|
|
77
|
+
console.log(bgMagenta(black(' Visit https://langtrain.ai/dashboard/billing to upgrade. ')));
|
|
78
78
|
}
|
|
79
79
|
return;
|
|
80
80
|
}
|