langtrain 0.1.18 → 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 +8 -4
- 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 -4
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +8 -4
- 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 +3 -2
- package/src/cli/auth.ts +1 -0
- package/src/cli/handlers/agent.ts +22 -3
- package/src/cli/handlers/data.ts +207 -0
- package/src/cli/handlers/deploy.ts +62 -0
- package/src/cli/handlers/dev.ts +42 -0
- package/src/cli/handlers/doctor.ts +54 -0
- package/src/cli/handlers/env.ts +89 -0
- package/src/cli/handlers/guardrails.ts +100 -0
- package/src/cli/handlers/init.ts +104 -0
- package/src/cli/handlers/logs.ts +68 -0
- package/src/cli/handlers/tune.ts +103 -1
- package/src/cli/index.ts +138 -17
- package/src/cli/menu.ts +19 -2
- package/src/cli/ui.ts +32 -12
- 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
|
@@ -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
|
+
}
|