Compare commits

..

4 Commits

Author SHA1 Message Date
yisding 25257f49d7 changeset 2023-11-14 14:50:27 -08:00
yisding dd615f106d fix #182 (thanks @RayFernando1337)
add license
make contextchatengine the default
change git commit message
2023-11-14 14:48:08 -08:00
yisding 5db64d61e0 Merge pull request #155 from team-dev-docs/avb-is-me-patch-1
Add Interactive Tutorials Using Codespaces
2023-11-14 12:08:07 -08:00
avb-is-me a5ae1eea30 Update end_to_end.md
Adds interactive Dev-Docs Tutorials
2023-10-27 16:04:32 -07:00
11 changed files with 49 additions and 79 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"create-llama": patch
---
Fix issue where it doesn't find OpenAI Key when running npm run generate (#182) (thanks @RayFernando1337)
-27
View File
@@ -1,27 +0,0 @@
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.OS }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.OS }}-node-
- run: pnpm install
- run: pnpm eslint --fix "./**/*.ts" "./**/*.js"
- run: pnpm run test
+2 -12
View File
@@ -31,21 +31,11 @@ PNPM's has documentation on its [workspace feature](https://pnpm.io/workspaces)
### Running Typescript
When we publish to NPM we will have a tsc compiled version of the library in JS. For now, the easiest thing to do is use ts-node. To run a TypeScript file, use the following command:
```
pnpx ts-node {file_path}
```
When we publish to NPM we will have a tsc compiled version of the library in JS. For now, the easiest thing to do is use ts-node.
### Test cases
Before running the tests, compile the TypeScript files to JavaScript. This can be done by running the following command:
```
pnpm run build
```
After the build process is complete, you can run the tests with:
To run them, run
```
pnpm run test
+2
View File
@@ -6,6 +6,8 @@ sidebar_position: 4
We include several end-to-end examples using LlamaIndex.TS in the repository
Check out the examples below or try them out and complete them in minutes with interactive Github Codespace tutorials provided by Dev-Docs [here](https://codespaces.new/team-dev-docs/lits-dev-docs-playground?devcontainer_path=.devcontainer%2Fjavascript_ltsquickstart%2Fdevcontainer.json):
## [Chat Engine](https://github.com/run-llama/LlamaIndexTS/blob/main/apps/simple/chatEngine.ts)
Read a file and chat about it with the LLM.
@@ -1,12 +0,0 @@
import { Response } from './Response';
import { BaseQueryEngine } from './QueryEngine';
import { ResponseEvaluator } from './ResponseEvaluator';
export class QueryResponseEvaluator {
evaluate(query: string, response: Response, queryEngine: BaseQueryEngine): number {
const evaluator = new ResponseEvaluator(queryEngine);
const binaryEvaluation = evaluator.binaryEvaluation(query, response);
const nodeEvaluation = evaluator.nodeEvaluation(query, response);
return binaryEvaluation && nodeEvaluation ? 1 : 0;
}
}
-12
View File
@@ -1,12 +0,0 @@
import { Response } from './Response';
import { BaseNode } from './Node';
export class ResponseEvaluator {
binaryEvaluation(response: Response, context: string): boolean {
return response.toString() === context;
}
nodeEvaluation(query: string, node: BaseNode): boolean {
return node.toString().includes(query);
}
}
+9
View File
@@ -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.
+7 -6
View File
@@ -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)
+1 -1
View File
@@ -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;
+7 -4
View File
@@ -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!")) +
+16 -5
View File
@@ -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`,
);
}
}
};