langtrain 0.1.10 → 0.1.11
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 +1 -1
- package/dist/cli.js +105 -0
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +105 -0
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/agent.ts +30 -0
- package/src/cli.ts +129 -1
- package/src/index.ts +1 -1
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/index.d.mts +0 -47
- package/dist/index.d.ts +0 -47
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/langtrain-ai/langtrain-sdk/main/public/langtrain-black.svg">
|
|
5
5
|
<img alt="Langtrain Logo" src="https://raw.githubusercontent.com/langtrain-ai/langtrain-sdk/main/public/langtrain-black.svg" width="250">
|
|
6
6
|
</picture>
|
|
7
|
-
<
|
|
7
|
+
<h3>Langtrain SDK</h3>
|
|
8
8
|
<p>
|
|
9
9
|
The unified intelligence layer for JavaScript applications. <br/>
|
|
10
10
|
Combine computer vision and LLM fine-tuning in a single, high-performance SDK.
|
package/dist/cli.js
CHANGED
|
@@ -12595,6 +12595,17 @@ var AgentClient = class {
|
|
|
12595
12595
|
const response = await this.client.get("/agents", { params });
|
|
12596
12596
|
return response.data.agents;
|
|
12597
12597
|
}
|
|
12598
|
+
async get(agentId) {
|
|
12599
|
+
const response = await this.client.get(`/agents/${agentId}`);
|
|
12600
|
+
return response.data;
|
|
12601
|
+
}
|
|
12602
|
+
async create(agent) {
|
|
12603
|
+
const response = await this.client.post("/agents/", agent);
|
|
12604
|
+
return response.data;
|
|
12605
|
+
}
|
|
12606
|
+
async delete(agentId) {
|
|
12607
|
+
await this.client.delete(`/agents/${agentId}`);
|
|
12608
|
+
}
|
|
12598
12609
|
async execute(agentId, input, messages = [], conversationId) {
|
|
12599
12610
|
const response = await this.client.post(`/agents/${agentId}/execute`, {
|
|
12600
12611
|
input,
|
|
@@ -12655,6 +12666,8 @@ async function main() {
|
|
|
12655
12666
|
"vision-finetune": (c) => handleVisionFinetune(c.vision),
|
|
12656
12667
|
"vision-generate": (c) => handleVisionGenerate(c.vision),
|
|
12657
12668
|
"agent-list": (c) => handleAgentList(c.agent),
|
|
12669
|
+
"agent-create": (c) => handleAgentCreate(c.agent),
|
|
12670
|
+
"agent-delete": (c) => handleAgentDelete(c.agent),
|
|
12658
12671
|
"exit": async () => {
|
|
12659
12672
|
(0, import_prompts.outro)("Goodbye!");
|
|
12660
12673
|
process.exit(0);
|
|
@@ -12666,6 +12679,8 @@ async function main() {
|
|
|
12666
12679
|
options: [
|
|
12667
12680
|
{ value: "group-agents", label: "\u{1F916} Agents (Server)", hint: "Chat with custom agents" },
|
|
12668
12681
|
{ value: "agent-list", label: " \u21B3 List & Run Agents" },
|
|
12682
|
+
{ value: "agent-create", label: " \u21B3 Create New Agent" },
|
|
12683
|
+
{ value: "agent-delete", label: " \u21B3 Delete Agent" },
|
|
12669
12684
|
{ value: "group-tune", label: "\u{1F9E0} Langtune (LLM)", hint: "Fine-tuning & Text Generation" },
|
|
12670
12685
|
{ value: "tune-finetune", label: " \u21B3 Fine-tune Text Model" },
|
|
12671
12686
|
{ value: "tune-generate", label: " \u21B3 Generate Text" },
|
|
@@ -12714,6 +12729,96 @@ async function handleLogin() {
|
|
|
12714
12729
|
saveConfig({ ...config, apiKey });
|
|
12715
12730
|
(0, import_prompts.intro)((0, import_colors.green)("API Key updated successfully!"));
|
|
12716
12731
|
}
|
|
12732
|
+
async function handleAgentCreate(client) {
|
|
12733
|
+
const name = await (0, import_prompts.text)({
|
|
12734
|
+
message: "Agent Name:",
|
|
12735
|
+
placeholder: "e.g. Support Bot",
|
|
12736
|
+
validate(value) {
|
|
12737
|
+
if (value.length === 0) return "Name is required!";
|
|
12738
|
+
}
|
|
12739
|
+
});
|
|
12740
|
+
if ((0, import_prompts.isCancel)(name)) return;
|
|
12741
|
+
const description = await (0, import_prompts.text)({
|
|
12742
|
+
message: "Description:",
|
|
12743
|
+
placeholder: "e.g. A helpful support assistant"
|
|
12744
|
+
});
|
|
12745
|
+
if ((0, import_prompts.isCancel)(description)) return;
|
|
12746
|
+
const systemPrompt = await (0, import_prompts.text)({
|
|
12747
|
+
message: "System Prompt:",
|
|
12748
|
+
placeholder: "e.g. You are a helpful assistant.",
|
|
12749
|
+
initialValue: "You are a helpful assistant."
|
|
12750
|
+
});
|
|
12751
|
+
if ((0, import_prompts.isCancel)(systemPrompt)) return;
|
|
12752
|
+
const s = (0, import_prompts.spinner)();
|
|
12753
|
+
s.start("Creating agent...");
|
|
12754
|
+
try {
|
|
12755
|
+
const agents = await client.list();
|
|
12756
|
+
let workspaceId = "";
|
|
12757
|
+
if (agents.length > 0) {
|
|
12758
|
+
workspaceId = agents[0].workspace_id;
|
|
12759
|
+
} else {
|
|
12760
|
+
s.stop((0, import_colors.yellow)("Workspace ID needed (no existing agents found)."));
|
|
12761
|
+
const wid = await (0, import_prompts.text)({
|
|
12762
|
+
message: "Enter Workspace ID (UUID):",
|
|
12763
|
+
validate(value) {
|
|
12764
|
+
if (value.length === 0) return "Required";
|
|
12765
|
+
}
|
|
12766
|
+
});
|
|
12767
|
+
if ((0, import_prompts.isCancel)(wid)) return;
|
|
12768
|
+
workspaceId = wid;
|
|
12769
|
+
s.start("Creating agent...");
|
|
12770
|
+
}
|
|
12771
|
+
const agent = await client.create({
|
|
12772
|
+
workspace_id: workspaceId,
|
|
12773
|
+
name,
|
|
12774
|
+
description,
|
|
12775
|
+
config: {
|
|
12776
|
+
system_prompt: systemPrompt,
|
|
12777
|
+
model: "gpt-4o"
|
|
12778
|
+
// Default or prompt? simplified
|
|
12779
|
+
}
|
|
12780
|
+
});
|
|
12781
|
+
s.stop((0, import_colors.green)(`Agent "${agent.name}" created successfully! ID: ${agent.id}`));
|
|
12782
|
+
} catch (e) {
|
|
12783
|
+
s.stop((0, import_colors.red)("Failed to create agent."));
|
|
12784
|
+
throw e;
|
|
12785
|
+
}
|
|
12786
|
+
}
|
|
12787
|
+
async function handleAgentDelete(client) {
|
|
12788
|
+
const s = (0, import_prompts.spinner)();
|
|
12789
|
+
s.start("Fetching agents...");
|
|
12790
|
+
const agents = await client.list();
|
|
12791
|
+
s.stop(`Found ${agents.length} agents`);
|
|
12792
|
+
if (agents.length === 0) {
|
|
12793
|
+
(0, import_prompts.intro)((0, import_colors.yellow)("No agents to delete."));
|
|
12794
|
+
return;
|
|
12795
|
+
}
|
|
12796
|
+
const agentId = await (0, import_prompts.select)({
|
|
12797
|
+
message: "Select an agent to DELETE:",
|
|
12798
|
+
options: agents.map((a) => ({ value: a.id, label: a.name, hint: a.description || "No description" }))
|
|
12799
|
+
});
|
|
12800
|
+
if ((0, import_prompts.isCancel)(agentId)) return;
|
|
12801
|
+
const confirm = await (0, import_prompts.select)({
|
|
12802
|
+
message: `Are you sure you want to delete this agent?`,
|
|
12803
|
+
options: [
|
|
12804
|
+
{ value: "yes", label: "Yes, delete it", hint: "Cannot be undone" },
|
|
12805
|
+
{ value: "no", label: "No, keep it" }
|
|
12806
|
+
]
|
|
12807
|
+
});
|
|
12808
|
+
if (confirm !== "yes") {
|
|
12809
|
+
(0, import_prompts.intro)((0, import_colors.gray)("Deletion cancelled."));
|
|
12810
|
+
return;
|
|
12811
|
+
}
|
|
12812
|
+
const d = (0, import_prompts.spinner)();
|
|
12813
|
+
d.start("Deleting agent...");
|
|
12814
|
+
try {
|
|
12815
|
+
await client.delete(agentId);
|
|
12816
|
+
d.stop((0, import_colors.green)("Agent deleted successfully."));
|
|
12817
|
+
} catch (e) {
|
|
12818
|
+
d.stop((0, import_colors.red)("Failed to delete agent."));
|
|
12819
|
+
throw e;
|
|
12820
|
+
}
|
|
12821
|
+
}
|
|
12717
12822
|
async function handleAgentList(client) {
|
|
12718
12823
|
const s = (0, import_prompts.spinner)();
|
|
12719
12824
|
s.start("Fetching agents...");
|