langtrain 0.1.9 → 0.1.10

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.mjs CHANGED
@@ -12631,9 +12631,11 @@ function saveConfig(config) {
12631
12631
  }
12632
12632
  fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
12633
12633
  }
12634
+ var packageJson = __require(path5.join(__dirname, "../package.json"));
12634
12635
  async function main() {
12635
12636
  const program = new Command();
12636
- program.name("langtrain").description("Langtrain CLI for AI Model Fine-tuning and Generation").version("0.1.9");
12637
+ const version = packageJson.version;
12638
+ program.name("langtrain").description(packageJson.description || "Langtrain CLI for AI Model Fine-tuning and Generation").version(version);
12637
12639
  program.action(async () => {
12638
12640
  console.clear();
12639
12641
  const banner = `
@@ -12645,23 +12647,24 @@ async function main() {
12645
12647
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D
12646
12648
  `;
12647
12649
  console.log(gradient(["#00DC82", "#36E4DA", "#0047E1"])(banner));
12648
- intro(`${bgCyan(black(" Langtrain SDK v0.1.9 "))}`);
12650
+ intro(`${bgCyan(black(` Langtrain SDK v${version} `))}`);
12649
12651
  const config = getConfig();
12650
12652
  if (!config.apiKey) {
12651
12653
  intro(yellow("Authentication required"));
12652
- const apiKey = await password({
12653
- message: "Enter your Langtrain API Key:",
12654
- validate(value) {
12655
- if (!value || value.length === 0) return "API Key is required";
12656
- }
12657
- });
12658
- if (isCancel(apiKey)) {
12659
- cancel("Operation cancelled");
12654
+ await handleLogin();
12655
+ }
12656
+ const handlers = {
12657
+ "login": handleLogin,
12658
+ "tune-finetune": (c) => handleTuneFinetune(c.tune),
12659
+ "tune-generate": (c) => handleTuneGenerate(c.tune),
12660
+ "vision-finetune": (c) => handleVisionFinetune(c.vision),
12661
+ "vision-generate": (c) => handleVisionGenerate(c.vision),
12662
+ "agent-list": (c) => handleAgentList(c.agent),
12663
+ "exit": async () => {
12664
+ outro("Goodbye!");
12660
12665
  process.exit(0);
12661
12666
  }
12662
- saveConfig({ ...config, apiKey });
12663
- intro(green("Successfully logged in!"));
12664
- }
12667
+ };
12665
12668
  while (true) {
12666
12669
  const operation = await select({
12667
12670
  message: "Select an operation:",
@@ -12679,33 +12682,26 @@ async function main() {
12679
12682
  { value: "exit", label: " \u21B3 Exit" }
12680
12683
  ]
12681
12684
  });
12682
- if (isCancel(operation) || operation === "exit") {
12685
+ if (isCancel(operation)) {
12683
12686
  outro("Goodbye!");
12684
12687
  process.exit(0);
12685
12688
  }
12686
- if (typeof operation === "string" && operation.startsWith("group-")) {
12687
- continue;
12688
- }
12689
- try {
12690
- const currentConfig = getConfig();
12691
- const currentVision = new Langvision({ apiKey: currentConfig.apiKey });
12692
- const currentTune = new Langtune({ apiKey: currentConfig.apiKey });
12693
- const currentAgent = new AgentClient({ apiKey: currentConfig.apiKey, baseUrl: currentConfig.baseUrl });
12694
- if (operation === "login") {
12695
- await handleLogin();
12696
- } else if (operation === "tune-finetune") {
12697
- await handleTuneFinetune(currentTune);
12698
- } else if (operation === "tune-generate") {
12699
- await handleTuneGenerate(currentTune);
12700
- } else if (operation === "vision-finetune") {
12701
- await handleVisionFinetune(currentVision);
12702
- } else if (operation === "vision-generate") {
12703
- await handleVisionGenerate(currentVision);
12704
- } else if (operation === "agent-list") {
12705
- await handleAgentList(currentAgent);
12706
- }
12707
- } catch (error) {
12708
- outro(red(`Error: ${error.message}`));
12689
+ if (typeof operation === "string") {
12690
+ if (operation.startsWith("group-")) continue;
12691
+ const handler = handlers[operation];
12692
+ if (handler) {
12693
+ try {
12694
+ const currentConfig = getConfig();
12695
+ const clients = {
12696
+ vision: new Langvision({ apiKey: currentConfig.apiKey }),
12697
+ tune: new Langtune({ apiKey: currentConfig.apiKey }),
12698
+ agent: new AgentClient({ apiKey: currentConfig.apiKey, baseUrl: currentConfig.baseUrl })
12699
+ };
12700
+ await handler(clients);
12701
+ } catch (error) {
12702
+ outro(red(`Error: ${error.message}`));
12703
+ }
12704
+ }
12709
12705
  }
12710
12706
  }
12711
12707
  });