langtrain 0.1.6 → 0.1.9
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.d.mts +0 -2
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +301 -125
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +303 -127
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +41 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +65 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
- package/src/agent.ts +54 -0
- package/src/cli.ts +206 -49
- package/src/index.ts +5 -1
package/dist/index.d.mts
CHANGED
|
@@ -4,3 +4,44 @@ export { Langvision } from 'langvision';
|
|
|
4
4
|
import * as langtune from 'langtune';
|
|
5
5
|
export { langtune as Text };
|
|
6
6
|
export { Langtune } from 'langtune';
|
|
7
|
+
|
|
8
|
+
interface Agent {
|
|
9
|
+
id: string;
|
|
10
|
+
workspace_id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
model_id?: string;
|
|
14
|
+
config: any;
|
|
15
|
+
is_active: boolean;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
}
|
|
19
|
+
interface AgentRun {
|
|
20
|
+
id: string;
|
|
21
|
+
conversation_id: string;
|
|
22
|
+
success: boolean;
|
|
23
|
+
output?: any;
|
|
24
|
+
error?: string;
|
|
25
|
+
latency_ms: number;
|
|
26
|
+
tokens_used: number;
|
|
27
|
+
}
|
|
28
|
+
declare class AgentClient {
|
|
29
|
+
private config;
|
|
30
|
+
private client;
|
|
31
|
+
constructor(config: {
|
|
32
|
+
apiKey: string;
|
|
33
|
+
baseUrl?: string;
|
|
34
|
+
});
|
|
35
|
+
list(workspaceId?: string): Promise<Agent[]>;
|
|
36
|
+
execute(agentId: string, input: any, messages?: any[], conversationId?: string): Promise<AgentRun>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type agent_Agent = Agent;
|
|
40
|
+
type agent_AgentClient = AgentClient;
|
|
41
|
+
declare const agent_AgentClient: typeof AgentClient;
|
|
42
|
+
type agent_AgentRun = AgentRun;
|
|
43
|
+
declare namespace agent {
|
|
44
|
+
export { type agent_Agent as Agent, agent_AgentClient as AgentClient, type agent_AgentRun as AgentRun };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { type Agent, AgentClient, type AgentRun, agent as AgentTypes };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,3 +4,44 @@ export { Langvision } from 'langvision';
|
|
|
4
4
|
import * as langtune from 'langtune';
|
|
5
5
|
export { langtune as Text };
|
|
6
6
|
export { Langtune } from 'langtune';
|
|
7
|
+
|
|
8
|
+
interface Agent {
|
|
9
|
+
id: string;
|
|
10
|
+
workspace_id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
model_id?: string;
|
|
14
|
+
config: any;
|
|
15
|
+
is_active: boolean;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
}
|
|
19
|
+
interface AgentRun {
|
|
20
|
+
id: string;
|
|
21
|
+
conversation_id: string;
|
|
22
|
+
success: boolean;
|
|
23
|
+
output?: any;
|
|
24
|
+
error?: string;
|
|
25
|
+
latency_ms: number;
|
|
26
|
+
tokens_used: number;
|
|
27
|
+
}
|
|
28
|
+
declare class AgentClient {
|
|
29
|
+
private config;
|
|
30
|
+
private client;
|
|
31
|
+
constructor(config: {
|
|
32
|
+
apiKey: string;
|
|
33
|
+
baseUrl?: string;
|
|
34
|
+
});
|
|
35
|
+
list(workspaceId?: string): Promise<Agent[]>;
|
|
36
|
+
execute(agentId: string, input: any, messages?: any[], conversationId?: string): Promise<AgentRun>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type agent_Agent = Agent;
|
|
40
|
+
type agent_AgentClient = AgentClient;
|
|
41
|
+
declare const agent_AgentClient: typeof AgentClient;
|
|
42
|
+
type agent_AgentRun = AgentRun;
|
|
43
|
+
declare namespace agent {
|
|
44
|
+
export { type agent_Agent as Agent, agent_AgentClient as AgentClient, type agent_AgentRun as AgentRun };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { type Agent, AgentClient, type AgentRun, agent as AgentTypes };
|
package/dist/index.js
CHANGED
|
@@ -1125,6 +1125,8 @@ var require_merge_stream2 = __commonJS({
|
|
|
1125
1125
|
// src/index.ts
|
|
1126
1126
|
var index_exports = {};
|
|
1127
1127
|
__export(index_exports, {
|
|
1128
|
+
AgentClient: () => AgentClient,
|
|
1129
|
+
AgentTypes: () => agent_exports,
|
|
1128
1130
|
Langtune: () => Langtune,
|
|
1129
1131
|
Langvision: () => Langvision,
|
|
1130
1132
|
Text: () => dist_exports2,
|
|
@@ -6791,6 +6793,13 @@ var FinetuneConfigSchema = external_exports.object({
|
|
|
6791
6793
|
var Langvision = class {
|
|
6792
6794
|
constructor(options = {}) {
|
|
6793
6795
|
this.cliPath = options.cliPath || "langvision";
|
|
6796
|
+
this.apiKey = options.apiKey;
|
|
6797
|
+
}
|
|
6798
|
+
getEnv() {
|
|
6799
|
+
return {
|
|
6800
|
+
...process.env,
|
|
6801
|
+
LANGVISION_API_KEY: this.apiKey || process.env.LANGVISION_API_KEY
|
|
6802
|
+
};
|
|
6794
6803
|
}
|
|
6795
6804
|
/**
|
|
6796
6805
|
* Run a fine-tuning job using the local CLI
|
|
@@ -6815,7 +6824,10 @@ var Langvision = class {
|
|
|
6815
6824
|
validated.outputDir
|
|
6816
6825
|
];
|
|
6817
6826
|
try {
|
|
6818
|
-
await execa(this.cliPath, args, {
|
|
6827
|
+
await execa(this.cliPath, args, {
|
|
6828
|
+
stdio: "inherit",
|
|
6829
|
+
env: this.getEnv()
|
|
6830
|
+
});
|
|
6819
6831
|
} catch (error) {
|
|
6820
6832
|
throw new Error(`Langvision fine-tuning failed: ${error}`);
|
|
6821
6833
|
}
|
|
@@ -6838,7 +6850,9 @@ var Langvision = class {
|
|
|
6838
6850
|
args.push("--temperature", options.temperature.toString());
|
|
6839
6851
|
}
|
|
6840
6852
|
try {
|
|
6841
|
-
const { stdout } = await execa(this.cliPath, args
|
|
6853
|
+
const { stdout } = await execa(this.cliPath, args, {
|
|
6854
|
+
env: this.getEnv()
|
|
6855
|
+
});
|
|
6842
6856
|
return stdout;
|
|
6843
6857
|
} catch (error) {
|
|
6844
6858
|
throw new Error(`Langvision generation failed: ${error}`);
|
|
@@ -12508,6 +12522,13 @@ var FinetuneConfigSchema2 = external_exports2.object({
|
|
|
12508
12522
|
var Langtune = class {
|
|
12509
12523
|
constructor(options = {}) {
|
|
12510
12524
|
this.cliPath = options.cliPath || "langtune";
|
|
12525
|
+
this.apiKey = options.apiKey;
|
|
12526
|
+
}
|
|
12527
|
+
getEnv() {
|
|
12528
|
+
return {
|
|
12529
|
+
...process.env,
|
|
12530
|
+
LANGTUNE_API_KEY: this.apiKey || process.env.LANGTUNE_API_KEY
|
|
12531
|
+
};
|
|
12511
12532
|
}
|
|
12512
12533
|
/**
|
|
12513
12534
|
* Run a fine-tuning job using the local CLI
|
|
@@ -12540,7 +12561,10 @@ var Langtune = class {
|
|
|
12540
12561
|
args.push("--use-lisa");
|
|
12541
12562
|
}
|
|
12542
12563
|
try {
|
|
12543
|
-
await execa2(this.cliPath, args, {
|
|
12564
|
+
await execa2(this.cliPath, args, {
|
|
12565
|
+
stdio: "inherit",
|
|
12566
|
+
env: this.getEnv()
|
|
12567
|
+
});
|
|
12544
12568
|
} catch (error) {
|
|
12545
12569
|
throw new Error(`Langtune fine-tuning failed: ${error}`);
|
|
12546
12570
|
}
|
|
@@ -12563,15 +12587,52 @@ var Langtune = class {
|
|
|
12563
12587
|
args.push("--temperature", options.temperature.toString());
|
|
12564
12588
|
}
|
|
12565
12589
|
try {
|
|
12566
|
-
const { stdout } = await execa2(this.cliPath, args
|
|
12590
|
+
const { stdout } = await execa2(this.cliPath, args, {
|
|
12591
|
+
env: this.getEnv()
|
|
12592
|
+
});
|
|
12567
12593
|
return stdout;
|
|
12568
12594
|
} catch (error) {
|
|
12569
12595
|
throw new Error(`Langtune generation failed: ${error}`);
|
|
12570
12596
|
}
|
|
12571
12597
|
}
|
|
12572
12598
|
};
|
|
12599
|
+
|
|
12600
|
+
// src/agent.ts
|
|
12601
|
+
var agent_exports = {};
|
|
12602
|
+
__export(agent_exports, {
|
|
12603
|
+
AgentClient: () => AgentClient
|
|
12604
|
+
});
|
|
12605
|
+
var import_axios = __toESM(require("axios"));
|
|
12606
|
+
var AgentClient = class {
|
|
12607
|
+
constructor(config) {
|
|
12608
|
+
this.config = config;
|
|
12609
|
+
this.client = import_axios.default.create({
|
|
12610
|
+
baseURL: config.baseUrl || "https://api.langtrain.ai/api/v1",
|
|
12611
|
+
headers: {
|
|
12612
|
+
"X-API-Key": config.apiKey,
|
|
12613
|
+
"Content-Type": "application/json"
|
|
12614
|
+
}
|
|
12615
|
+
});
|
|
12616
|
+
}
|
|
12617
|
+
async list(workspaceId) {
|
|
12618
|
+
const params = {};
|
|
12619
|
+
if (workspaceId) params.workspace_id = workspaceId;
|
|
12620
|
+
const response = await this.client.get("/agents", { params });
|
|
12621
|
+
return response.data.agents;
|
|
12622
|
+
}
|
|
12623
|
+
async execute(agentId, input, messages = [], conversationId) {
|
|
12624
|
+
const response = await this.client.post(`/agents/${agentId}/execute`, {
|
|
12625
|
+
input,
|
|
12626
|
+
messages,
|
|
12627
|
+
conversation_id: conversationId
|
|
12628
|
+
});
|
|
12629
|
+
return response.data;
|
|
12630
|
+
}
|
|
12631
|
+
};
|
|
12573
12632
|
// Annotate the CommonJS export names for ESM import in node:
|
|
12574
12633
|
0 && (module.exports = {
|
|
12634
|
+
AgentClient,
|
|
12635
|
+
AgentTypes,
|
|
12575
12636
|
Langtune,
|
|
12576
12637
|
Langvision,
|
|
12577
12638
|
Text,
|