Compare commits

...

4 Commits

Author SHA1 Message Date
leehuwuj 37569f7506 remove exit in notifyUpdate 2024-01-30 09:54:53 +07:00
leehuwuj 65e384fd9c fix missing await for install deps 2024-01-30 08:41:20 +07:00
leehuwuj 8492d64c15 add missing copy test data for example pdf option 2024-01-30 07:32:45 +07:00
leehuwuj 900a032aa6 fix url & breaking options 2024-01-29 18:55:05 +07:00
4 changed files with 37 additions and 10 deletions
+11 -4
View File
@@ -94,7 +94,11 @@ const installDependencies = async (
if (framework === "fastapi") {
if (hasOpenAiKey && vectorDb === "none" && isHavingPoetryLockFile()) {
console.log(`Running ${runGenerate} to generate the context data.`);
tryPoetryRun("python app/engine/generate.py");
let result = tryPoetryRun("python app/engine/generate.py");
if (!result) {
console.log(`Failed to run ${runGenerate}.`);
process.exit(1);
}
return;
}
} else {
@@ -188,10 +192,13 @@ export const installTemplate = async (
if (props.engine === "context") {
if (props.dataSource?.type === "file") {
// Copy test pdf file
await copyTestData(props.root, props.framework);
if ("contextFile" in props.dataSource.config) {
await copyTestData(props.root, props.dataSource.config.contextFile);
} else {
await copyTestData(props.root);
}
}
installDependencies(
await installDependencies(
props.framework,
props.packageManager,
props.openAiKey,
+1 -1
View File
@@ -181,7 +181,7 @@ export const installPythonTemplate = async ({
parents: true,
cwd: VectorDBPath,
});
if (dataSource?.type !== "none" && dataSource?.type !== undefined) {
if (dataSource?.type !== undefined) {
const loaderPath = path.join(
compPath,
"loaders",
-1
View File
@@ -278,7 +278,6 @@ async function notifyUpdate(): Promise<void> {
"\n",
);
}
process.exit();
} catch {
// ignore error
}
+25 -4
View File
@@ -153,7 +153,10 @@ export const askQuestions = async (
];
const hasOpenAiKey = program.openAiKey || process.env["OPENAI_API_KEY"];
if (program.vectorDb === "none" && hasOpenAiKey) {
if (
(program.vectorDb === "none" || program.vectorDb === undefined) &&
hasOpenAiKey
) {
actionChoices.push({
title:
"Generate code, install dependencies, and run the app (~2 min)",
@@ -405,6 +408,7 @@ export const askQuestions = async (
break;
case "exampleFile":
program.engine = "context";
program.dataSource = { type: "file", config: {} };
break;
case "localFile":
program.engine = "context";
@@ -423,18 +427,35 @@ export const askQuestions = async (
}
if (program.dataSource?.type === "web" && program.framework === "fastapi") {
const { baseUrl } = await prompts(
let { baseUrl } = await prompts(
{
type: "text",
name: "baseUrl",
message: "Please provide base URL of the website:",
initial: "https://ts.llamaindex.ai/modules/",
initial: "https://www.llamaindex.ai",
},
handlers,
);
try {
if (!baseUrl.includes("://")) {
baseUrl = `https://${baseUrl}`;
}
let checkUrl = new URL(baseUrl);
if (checkUrl.protocol !== "https:" && checkUrl.protocol !== "http:") {
throw new Error("Invalid protocol");
}
} catch (error) {
console.log(
red(
"Invalid URL provided! Please provide a valid URL (e.g. https://ts.llamaindex.ai)",
),
);
process.exit(1);
}
console.log("baseUrl: ", baseUrl);
program.dataSource.config = {
baseUrl: baseUrl,
depth: 2,
depth: 1,
};
}
if (program.engine !== "simple" && !program.vectorDb) {