diff --git a/packages/create-llama/LICENSE.md b/packages/create-llama/LICENSE.md new file mode 100644 index 0000000000000000000000000000000000000000..c16e650c0ed5197b51ab46b3d4abfdee5069383b --- /dev/null +++ b/packages/create-llama/LICENSE.md @@ -0,0 +1,9 @@ +The MIT License (MIT) + +Copyright (c) 2023 LlamaIndex, Vercel, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packages/create-llama/README.md b/packages/create-llama/README.md index e326767377837c1dc6c339a6352fb585946c450e..5c04f3499b9edc6ec57f393982cf0c0d37645571 100644 --- a/packages/create-llama/README.md +++ b/packages/create-llama/README.md @@ -1,6 +1,6 @@ # Create LlamaIndex App -The easiest way to get started with [LlamaIndex](https://www.llamaindex.ai/) is by using `create-llama`. This CLI tool enables you to quickly start building a new LlamaIndex application, with everything set up for you. +The easiest way to get started with [LlamaIndex](https://www.llamaindex.ai/) is by using `create-llama`. This CLI tool enables you to quickly start building a new LlamaIndex application, with everything set up for you. ## Features @@ -19,11 +19,11 @@ You can create a new project interactively by running: ```bash npx create-llama@latest # or -npm create llama +npm create llama@latest # or yarn create llama # or -pnpm create llama +pnpm create llama@latest ``` You will be asked for the name of your project, along with other configuration options. @@ -33,14 +33,14 @@ Here is an example: ```bash >> npm create llama Need to install the following packages: - create-llama@0.0.3 + create-llama@latest Ok to proceed? (y) y ✔ What is your project named? … my-app ✔ Which template would you like to use? › Chat with streaming ✔ Which framework would you like to use? › NextJS ✔ Which UI would you like to use? › Just HTML ✔ Which chat engine would you like to use? › ContextChatEngine -✔ Please provide your OpenAI API key (leave blank to skip): … +✔ Please provide your OpenAI API key (leave blank to skip): … ✔ Would you like to use ESLint? … No / Yes Creating a new LlamaIndex app in /home/my-app. ``` @@ -55,7 +55,6 @@ create-llama <project-directory> [options] Options: -V, --version output the version number - --use-npm @@ -75,3 +74,5 @@ Options: - [TS/JS docs](https://ts.llamaindex.ai/) - [Python docs](https://docs.llamaindex.ai/en/stable/) + +Inspired by and adapted from [create-next-app](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) diff --git a/packages/create-llama/helpers/git.ts b/packages/create-llama/helpers/git.ts index fc27e609953251dff5ffb898bb7ad92039a1ca53..2cdfe8dc34baefd0c092bbefe6fe071bd4729e0c 100644 --- a/packages/create-llama/helpers/git.ts +++ b/packages/create-llama/helpers/git.ts @@ -43,7 +43,7 @@ export function tryGitInit(root: string): boolean { } execSync("git add -A", { stdio: "ignore" }); - execSync('git commit -m "Initial commit from Create Next App"', { + execSync('git commit -m "Initial commit from Create Llama"', { stdio: "ignore", }); return true; diff --git a/packages/create-llama/index.ts b/packages/create-llama/index.ts index b1009a4dbd043960edeb018c04b6f265bf57d3c6..bcd1507d55e3e89adc6820d53d0216d64cebb2f6 100644 --- a/packages/create-llama/index.ts +++ b/packages/create-llama/index.ts @@ -288,8 +288,11 @@ async function run(): Promise<void> { name: "engine", message: "Which chat engine would you like to use?", choices: [ - { title: "SimpleChatEngine", value: "simple" }, { title: "ContextChatEngine", value: "context" }, + { + title: "SimpleChatEngine", + value: "simple (no data, just chat)", + }, ], initial: 0, }, @@ -359,10 +362,10 @@ async function notifyUpdate(): Promise<void> { if (res?.latest) { const updateMessage = packageManager === "yarn" - ? "yarn global add create-llama" + ? "yarn global add create-llama@latest" : packageManager === "pnpm" - ? "pnpm add -g create-llama" - : "npm i -g create-llama"; + ? "pnpm add -g create-llama@latest" + : "npm i -g create-llama@latest"; console.log( yellow(bold("A new version of `create-llama` is available!")) + diff --git a/packages/create-llama/templates/index.ts b/packages/create-llama/templates/index.ts index e45167e01fc096359f8367b5b362750f27401a31..d6e5cd61fd75351abde00cebb7d07d0c7a6acb1f 100644 --- a/packages/create-llama/templates/index.ts +++ b/packages/create-llama/templates/index.ts @@ -33,6 +33,7 @@ const createEnvLocalFile = async ( `OPENAI_API_KEY=${openAIKey}\n`, ); console.log(`Created '${envFileName}' file containing OPENAI_API_KEY`); + process.env["OPENAI_API_KEY"] = openAIKey; } }; @@ -53,11 +54,21 @@ const copyTestData = async ( } if (packageManager && engine === "context") { - console.log( - `\nRunning ${cyan("npm run generate")} to generate the context data.\n`, - ); - await callPackageManager(packageManager, true, ["run", "generate"]); - console.log(); + if (process.env["OPENAI_API_KEY"]) { + console.log( + `\nRunning ${cyan( + `${packageManager} run generate`, + )} to generate the context data.\n`, + ); + await callPackageManager(packageManager, true, ["run", "generate"]); + console.log(); + } else { + console.log( + `\nAfter setting your OpenAI key, run ${cyan( + `${packageManager} run generate`, + )} to generate the context data.\n`, + ); + } } };