From ed85da77652ece2d2d398594d388a3062648b52e Mon Sep 17 00:00:00 2001 From: thucpn <thucsh2@gmail.com> Date: Thu, 28 Dec 2023 14:03:35 +0700 Subject: [PATCH] feat: question to select vectordb for python template --- questions.ts | 40 ++++++++++++++++++---------------------- templates/index.ts | 13 +++++++++++-- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/questions.ts b/questions.ts index d3709601..72c1e075 100644 --- a/questions.ts +++ b/questions.ts @@ -239,28 +239,24 @@ export const askQuestions = async ( if (ciInfo.isCI) { program.vectorDb = getPrefOrDefault("vectorDb"); } else { - if (program.framework === "fastapi") { - program.vectorDb = "none"; - } else { - const { vectorDb } = await prompts( - { - type: "select", - name: "vectorDb", - message: "Would you like to use a vector database?", - choices: [ - { - title: "No, just store the data in the file system", - value: "none", - }, - { title: "MongoDB", value: "mongo" }, - ], - initial: 0, - }, - handlers, - ); - program.vectorDb = vectorDb; - preferences.vectorDb = vectorDb; - } + const { vectorDb } = await prompts( + { + type: "select", + name: "vectorDb", + message: "Would you like to use a vector database?", + choices: [ + { + title: "No, just store the data in the file system", + value: "none", + }, + { title: "MongoDB", value: "mongo" }, + ], + initial: 0, + }, + handlers, + ); + program.vectorDb = vectorDb; + preferences.vectorDb = vectorDb; } } diff --git a/templates/index.ts b/templates/index.ts index ff9ed0ae..169dd2ec 100644 --- a/templates/index.ts +++ b/templates/index.ts @@ -317,7 +317,11 @@ const installPythonTemplate = async ({ template, framework, engine, -}: Pick<InstallTemplateArgs, "root" | "framework" | "template" | "engine">) => { + vectorDb, +}: Pick< + InstallTemplateArgs, + "root" | "framework" | "template" | "engine" | "vectorDb" +>) => { console.log("\nInitializing Python project with template:", template, "\n"); const templatePath = path.join(__dirname, "types", template, framework); await copy("**", root, { @@ -342,7 +346,12 @@ const installPythonTemplate = async ({ if (engine === "context") { const compPath = path.join(__dirname, "components"); - const VectorDBPath = path.join(compPath, "vectordbs", "python", "none"); + const VectorDBPath = path.join( + compPath, + "vectordbs", + "python", + vectorDb || "none", + ); await copy("**", path.join(root, "app", "engine"), { parents: true, cwd: VectorDBPath, -- GitLab