langtrain 0.1.19 → 0.1.20
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/.agent/workflows/gsd.md +27 -0
- package/.agent/workflows/ralph.md +28 -0
- package/README.md +4 -0
- package/assets/cli-demo.png +0 -0
- package/dist/chunk-D3O435OM.mjs +30 -0
- package/dist/chunk-D3O435OM.mjs.map +1 -0
- package/dist/chunk-Z7FYIYKL.js +30 -0
- package/dist/chunk-Z7FYIYKL.js.map +1 -0
- package/dist/cli.js +8 -6
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +8 -6
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/cli/handlers/agent.ts +20 -1
- package/src/cli/handlers/data.ts +128 -5
- package/src/cli/handlers/env.ts +89 -0
- package/src/cli/handlers/guardrails.ts +100 -0
- package/src/cli/handlers/logs.ts +68 -0
- package/src/cli/index.ts +100 -15
- package/src/cli/menu.ts +12 -1
- package/src/cli/ui.ts +11 -8
- package/src/index.ts +4 -1
- package/src/lib/agent.ts +7 -0
- package/src/lib/guardrails.ts +72 -0
- package/src/lib/secrets.ts +39 -0
- package/dist/chunk-PAHGEWDE.js +0 -30
- package/dist/chunk-PAHGEWDE.js.map +0 -1
- package/dist/chunk-Q46V6ODQ.mjs +0 -30
- package/dist/chunk-Q46V6ODQ.mjs.map +0 -1
package/src/cli/ui.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { text, select, confirm, password, isCancel, cancel, note } from '@clack/prompts';
|
|
2
|
-
import {
|
|
2
|
+
import { bgMagenta, black, red, green, yellow, gray, cyan, bold, dim, blue, magenta, white } from 'kleur/colors';
|
|
3
3
|
import gradient from 'gradient-string';
|
|
4
4
|
|
|
5
5
|
// Re-export specific prompts to keep imports clean in other files
|
|
@@ -15,12 +15,15 @@ export function showBanner(version: string) {
|
|
|
15
15
|
███████╗██║ ██║██║ ╚████║╚██████╔╝ ██║ ██║ ██║██║ ██║██║██║ ╚████║
|
|
16
16
|
╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝
|
|
17
17
|
`;
|
|
18
|
-
|
|
19
|
-
console.log(
|
|
18
|
+
// Brand Gradient: Purple to Pink to Blue (Light Luxury)
|
|
19
|
+
console.log(gradient(['#A855F7', '#EC4899', '#3B82F6'])(banner));
|
|
20
|
+
|
|
21
|
+
// Elegant Badge: Black text on Magenta background
|
|
22
|
+
console.log(`${bgMagenta(black(` Langtrain SDK v${version} `))}\n`);
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
export function intro(message: string) {
|
|
23
|
-
console.log(
|
|
26
|
+
console.log(magenta(`◆ ${message}`));
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
export function outro(message: string) {
|
|
@@ -29,12 +32,12 @@ export function outro(message: string) {
|
|
|
29
32
|
|
|
30
33
|
export function spinner() {
|
|
31
34
|
return {
|
|
32
|
-
start: (msg: string) => process.stdout.write(`${
|
|
35
|
+
start: (msg: string) => process.stdout.write(`${magenta('●')} ${msg}\r`),
|
|
33
36
|
stop: (msg?: string) => {
|
|
34
37
|
if (msg) console.log(`${green('✔')} ${msg}`);
|
|
35
38
|
else console.log(''); // Newline
|
|
36
39
|
},
|
|
37
|
-
message: (msg: string) => process.stdout.write(`${
|
|
40
|
+
message: (msg: string) => process.stdout.write(`${magenta('●')} ${msg}\r`)
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
43
|
|
|
@@ -59,9 +62,9 @@ export function showDim(message: string) {
|
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
// Re-export for backward compatibility
|
|
62
|
-
export {
|
|
65
|
+
export { bgMagenta, black, red, green, yellow, gray, cyan, bold, dim, blue, gradient, magenta, white };
|
|
63
66
|
|
|
64
67
|
export const colors = {
|
|
65
|
-
|
|
68
|
+
bgMagenta, black, red, green, yellow, gray, cyan, bold, dim, blue, magenta, white
|
|
66
69
|
};
|
|
67
70
|
|
package/src/index.ts
CHANGED
|
@@ -9,11 +9,14 @@ export { FileClient, FileResponse } from './lib/files';
|
|
|
9
9
|
export { TrainingClient, FineTuneJobCreate, FineTuneJobResponse } from './lib/training';
|
|
10
10
|
export { SubscriptionClient, SubscriptionInfo, FeatureCheck } from './lib/subscription';
|
|
11
11
|
export { ModelClient, Model } from './lib/models';
|
|
12
|
+
export { SecretClient, Secret } from './lib/secrets';
|
|
13
|
+
export { GuardrailClient, Guardrail, GuardrailConfig, GuardrailCreate } from './lib/guardrails';
|
|
12
14
|
|
|
13
15
|
// Export Types with Namespaces to avoid collisions
|
|
14
16
|
import * as Vision from 'langvision';
|
|
15
17
|
import * as Text from 'langtune';
|
|
16
18
|
import * as AgentTypes from './lib/agent';
|
|
17
19
|
import * as ModelTypes from './lib/models';
|
|
20
|
+
import * as SecretTypes from './lib/secrets';
|
|
18
21
|
|
|
19
|
-
export { Vision, Text, AgentTypes, ModelTypes };
|
|
22
|
+
export { Vision, Text, AgentTypes, ModelTypes, SecretTypes };
|
package/src/lib/agent.ts
CHANGED
|
@@ -65,6 +65,13 @@ export class AgentClient {
|
|
|
65
65
|
});
|
|
66
66
|
return response.data;
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
async logs(agentId: string, limit: number = 100): Promise<{ logs: string[] }> {
|
|
70
|
+
const response = await this.client.get<{ logs: string[] }>(`/agents/${agentId}/logs`, {
|
|
71
|
+
params: { limit }
|
|
72
|
+
});
|
|
73
|
+
return response.data;
|
|
74
|
+
}
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
export interface AgentConfig {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import axios, { AxiosInstance } from 'axios';
|
|
2
|
+
|
|
3
|
+
export interface GuardrailConfig {
|
|
4
|
+
pii_enabled: boolean;
|
|
5
|
+
pii_entities?: string[];
|
|
6
|
+
profanity_enabled: boolean;
|
|
7
|
+
profanity_threshold?: number;
|
|
8
|
+
blocked_topics?: string[];
|
|
9
|
+
regex_patterns?: string[];
|
|
10
|
+
min_length?: number;
|
|
11
|
+
max_length?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface Guardrail {
|
|
15
|
+
id: string;
|
|
16
|
+
workspace_id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
config: GuardrailConfig;
|
|
20
|
+
is_active: boolean;
|
|
21
|
+
created_at: string;
|
|
22
|
+
updated_at: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface GuardrailCreate {
|
|
26
|
+
name: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
config: GuardrailConfig;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class GuardrailClient {
|
|
32
|
+
private client: AxiosInstance;
|
|
33
|
+
|
|
34
|
+
constructor(private config: { apiKey: string, baseUrl?: string }) {
|
|
35
|
+
this.client = axios.create({
|
|
36
|
+
baseURL: config.baseUrl || 'https://api.langtrain.ai/api/v1',
|
|
37
|
+
headers: {
|
|
38
|
+
'X-API-Key': config.apiKey,
|
|
39
|
+
'Content-Type': 'application/json'
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async list(workspaceId?: string): Promise<Guardrail[]> {
|
|
45
|
+
const params: any = {};
|
|
46
|
+
if (workspaceId) params.workspace_id = workspaceId;
|
|
47
|
+
const response = await this.client.get<Guardrail[]>('/guardrails/', { params });
|
|
48
|
+
return response.data;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async get(guardrailId: string): Promise<Guardrail> {
|
|
52
|
+
const response = await this.client.get<Guardrail>(`/guardrails/${guardrailId}`);
|
|
53
|
+
return response.data;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async create(data: GuardrailCreate): Promise<Guardrail> {
|
|
57
|
+
const response = await this.client.post<Guardrail>('/guardrails/', data);
|
|
58
|
+
return response.data;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async delete(guardrailId: string): Promise<void> {
|
|
62
|
+
await this.client.delete(`/guardrails/${guardrailId}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async apply(datasetId: string, guardrailId: string): Promise<any> {
|
|
66
|
+
const response = await this.client.post('/guardrails/apply', {
|
|
67
|
+
dataset_id: datasetId,
|
|
68
|
+
guardrail_id: guardrailId
|
|
69
|
+
});
|
|
70
|
+
return response.data;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import axios, { AxiosInstance } from 'axios';
|
|
2
|
+
|
|
3
|
+
export interface Secret {
|
|
4
|
+
key: string;
|
|
5
|
+
created_at: string;
|
|
6
|
+
updated_at: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class SecretClient {
|
|
10
|
+
private client: AxiosInstance;
|
|
11
|
+
|
|
12
|
+
constructor(private config: { apiKey: string, baseUrl?: string }) {
|
|
13
|
+
this.client = axios.create({
|
|
14
|
+
baseURL: config.baseUrl || 'https://api.langtrain.ai/api/v1',
|
|
15
|
+
headers: {
|
|
16
|
+
'X-API-Key': config.apiKey,
|
|
17
|
+
'Content-Type': 'application/json'
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async list(workspaceId?: string): Promise<Secret[]> {
|
|
23
|
+
const params: any = {};
|
|
24
|
+
if (workspaceId) params.workspace_id = workspaceId;
|
|
25
|
+
const response = await this.client.get<{ secrets: Secret[] }>('/secrets', { params });
|
|
26
|
+
return response.data.secrets;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async set(key: string, value: string, workspaceId?: string): Promise<Secret> {
|
|
30
|
+
const response = await this.client.post<Secret>('/secrets', { key, value, workspaceId });
|
|
31
|
+
return response.data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async delete(key: string, workspaceId?: string): Promise<void> {
|
|
35
|
+
const params: any = { key };
|
|
36
|
+
if (workspaceId) params.workspace_id = workspaceId;
|
|
37
|
+
await this.client.delete(`/secrets/${key}`, { params });
|
|
38
|
+
}
|
|
39
|
+
}
|