langcode
Version:
A Plugin-Based Framework for Managing and Using LangChain
105 lines (104 loc) • 3.5 kB
JavaScript
#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const inquirer_1 = __importDefault(require("inquirer"));
const chalk_1 = __importDefault(require("chalk"));
const __1 = require("..");
const program = new commander_1.Command();
program
.name("langcode")
.description("🧠 langcode: Plugin tabanlı LangChain SDK CLI")
.version("0.1.0");
program
.command("chat")
.description("OpenAI ile terminalden sohbet başlat")
.action(async () => {
console.log(chalk_1.default.bold.cyan("🤖 LangChain + OpenAI Sohbet Modu\n"));
const { apiKey } = await inquirer_1.default.prompt([
{
type: "password",
name: "apiKey",
message: "OpenAI API anahtarınızı girin:",
mask: "*",
},
]);
const manager = await (0, __1.langcode)([
{
pluginName: __1.plugins.openai,
config: {
apiKey,
modelName: "gpt-4o",
temperature: 0.7,
},
},
]);
console.log(chalk_1.default.green("✅ Chat hazır! Çıkmak için 'exit' yazın.\n"));
while (true) {
const { prompt } = await inquirer_1.default.prompt([
{
type: "input",
name: "prompt",
message: chalk_1.default.blue("🗨️ Siz:"),
},
]);
if (prompt.toLowerCase() === "exit") {
console.log(chalk_1.default.gray("👋 Görüşmek üzere!"));
break;
}
const response = await manager.run(__1.plugins.openai, { prompt });
console.log(chalk_1.default.yellow("🤖 LLM:"), response);
}
});
program
.command("image")
.description("DALL·E ile görsel oluştur")
.action(async () => {
console.log(chalk_1.default.bold.magenta("🖼️ Görsel Üretim Modu (DALL·E)\n"));
const { apiKey, prompt, outputPath } = await inquirer_1.default.prompt([
{
type: "password",
name: "apiKey",
message: "OpenAI API anahtarınızı girin:",
mask: "*",
},
{
type: "input",
name: "prompt",
message: "🎨 Görsel için prompt:",
},
{
type: "input",
name: "outputPath",
message: "💾 Kayıt yolu (örnek: ./output/image.png):",
default: "./output/image.png",
},
]);
const manager = await (0, __1.langcode)([
{
pluginName: __1.plugins.dalle,
config: {
apiKey,
size: "1024x1024",
},
},
]);
const imageUrl = await manager.run(__1.plugins.dalle, { prompt, outputPath });
console.log(chalk_1.default.green("✅ Görsel oluşturuldu!"));
console.log(chalk_1.default.gray(imageUrl));
});
program
.command("list")
.description("Mevcut pluginleri listele")
.action(async () => {
const list = await (0, __1.getPlugins)();
console.log(chalk_1.default.bold("\n📦 Yüklü Pluginler:\n"));
list.forEach((plugin) => {
console.log(chalk_1.default.green(`- ${plugin.name}`));
console.log(" ", chalk_1.default.gray(plugin.description));
});
});
program.parse(process.argv);