Compare commits

..

9 Commits

Author SHA1 Message Date
sweep-ai[bot] 0dfe7f3ce2 Merge main into sweep/model-selection 2023-11-15 23:56:51 +00:00
sweep-ai[bot] abb17a5acc Merge main into sweep/model-selection 2023-11-15 04:55:22 +00:00
sweep-ai[bot] a259b22811 Merge main into sweep/model-selection 2023-11-15 04:49:35 +00:00
sweep-ai[bot] a001c3097a Merge main into sweep/model-selection 2023-11-15 01:24:45 +00:00
sweep-ai[bot] 33d22d62ff feat: Updated packages/create-llama/templates/READ 2023-11-15 00:55:42 +00:00
sweep-ai[bot] cc6605565e feat: Updated packages/create-llama/.npmrc 2023-11-15 00:51:51 +00:00
sweep-ai[bot] df8746c66a feat/fix: the commit message 2023-11-15 00:43:02 +00:00
sweep-ai[bot] 3862ab7305 feat: Updated packages/create-llama/README.md 2023-11-15 00:39:28 +00:00
sweep-ai[bot] 8d48230808 feat: Updated packages/create-llama/README.md 2023-11-15 00:34:08 +00:00
23 changed files with 43 additions and 121 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
### Patch Changes
- 63f2108: Add multimodal support (thanks @marcusschiesser)
- 63f2108: Add multimodal support (thanks Marcus)
## 0.0.34
+1
View File
@@ -0,0 +1 @@
+4 -16
View File
@@ -1,22 +1,10 @@
# create-llama
## 0.0.8
### Patch Changes
- 8cdb07f: Fix Next deployment (thanks @seldo and @marcusschiesser)
## 0.0.7
### Patch Changes
- 9f9f293: Added more to README and made it easier to switch models (thanks @seldo)
## 0.0.6
### Patch Changes
- 4431ec7: Label bug fix (thanks @marcusschiesser)
- 4431ec7: Label bug fix
## 0.0.5
@@ -28,16 +16,16 @@
### Patch Changes
- 031e926: Update create-llama readme (thanks @logan-markewich)
- 031e926: Update create-llama readme (thanks Logan)
## 0.0.3
### Patch Changes
- 91b42a3: change version (thanks @marcusschiesser)
- 91b42a3: change version (thanks Marcus)
## 0.0.2
### Patch Changes
- e2a6805: Hello Create Llama (thanks @marcusschiesser)
- e2a6805: Hello Create Llama (thanks Marcus!)
+22 -6
View File
@@ -67,13 +67,7 @@ You can also replace OpenAI with one of our [dozens of other supported LLMs](htt
The simplest thing to do is run `create-llama` in interactive mode:
```bash
npx create-llama@latest
# or
npm create llama@latest
# or
yarn create llama
# or
pnpm create llama@latest
```
You will be asked for the name of your project, along with other configuration options, something like this:
@@ -86,10 +80,32 @@ 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? Shadcn
✔ Which chat engine would you like to use? SimpleChatEngine
✔ **Please provide your llm of choice (leave blank to skip): …**
✔ Please select a model Model1 / Model2 / Model3
✔ Please provide your API key (leave blank to skip): …
✔ Would you like to use ESLint? … No / Yes
✔ Which chat engine would you like to use? ContextChatEngine
✔ 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.
```
Here is an example:
```bash
>> npm create llama
Need to install the following packages:
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): …
✔ Would you like to use ESLint? … No / Yes
✔ Please select a model Model1 / Model2 / Model3
Creating a new LlamaIndex app in /home/my-app.
```
+1 -1
View File
@@ -88,7 +88,7 @@ export async function createApp({
path.join(root, "README.md"),
);
} else {
await installTemplate({ ...args, backend: true, forBackend: framework });
await installTemplate({ ...args, backend: true });
}
process.chdir(root);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "create-llama",
"version": "0.0.8",
"version": "0.0.6",
"keywords": [
"rag",
"llamaindex",
@@ -16,3 +16,8 @@ To learn more about LlamaIndex, take a look at the following resources:
- [LlamaIndexTS Documentation](https://ts.llamaindex.ai) - learn about LlamaIndex (Typescript features).
You can check out [the LlamaIndexTS GitHub repository](https://github.com/run-llama/LlamaIndexTS) - your feedback and contributions are welcome!
+
+ ### Model Selection
+
+ When creating a new LlamaIndex app, you can select a model to use. The available models are Model1, Model2, and Model3. The selected model will be used in the generated code.
-21
View File
@@ -103,7 +103,6 @@ const installTSTemplate = async ({
ui,
eslint,
customApiPath,
forBackend,
}: InstallTemplateArgs) => {
console.log(bold(`Using ${packageManager}.`));
@@ -121,26 +120,6 @@ const installTSTemplate = async ({
rename,
});
/**
* If the backend is next.js, rename next.config.app.js to next.config.js
* If not, rename next.config.static.js to next.config.js
*/
if (framework == "nextjs" && forBackend === "nextjs") {
const nextConfigAppPath = path.join(root, "next.config.app.js");
const nextConfigPath = path.join(root, "next.config.js");
await fs.rename(nextConfigAppPath, nextConfigPath);
// delete next.config.static.js
const nextConfigStaticPath = path.join(root, "next.config.static.js");
await fs.rm(nextConfigStaticPath);
} else if (framework == "nextjs" && typeof forBackend === "undefined") {
const nextConfigStaticPath = path.join(root, "next.config.static.js");
const nextConfigPath = path.join(root, "next.config.js");
await fs.rename(nextConfigStaticPath, nextConfigPath);
// delete next.config.app.js
const nextConfigAppPath = path.join(root, "next.config.app.js");
await fs.rm(nextConfigAppPath);
}
/**
* Copy the selected chat engine files to the target directory and reference it.
*/
-1
View File
@@ -17,5 +17,4 @@ export interface InstallTemplateArgs {
eslint: boolean;
customApiPath?: string;
openAIKey?: string;
forBackend?: string;
}
@@ -1,2 +0,0 @@
# local env files
.env
@@ -8,24 +8,12 @@ const port = 8000;
const env = process.env["NODE_ENV"];
const isDevelopment = !env || env === "development";
const prodCorsOrigin = process.env["PROD_CORS_ORIGIN"];
if (isDevelopment) {
console.warn("Running in development mode - allowing CORS for all origins");
app.use(cors());
} else if (prodCorsOrigin) {
console.log(
`Running in production mode - allowing CORS for domain: ${prodCorsOrigin}`,
);
const corsOptions = {
origin: prodCorsOrigin, // Restrict to production domain
};
app.use(cors(corsOptions));
} else {
console.warn("Production CORS origin not set, defaulting to no CORS.");
}
app.use(express.text());
app.use(express.json());
app.get("/", (req: Request, res: Response) => {
res.send("LlamaIndex Express Server");
@@ -4,7 +4,7 @@ import { createChatEngine } from "./engine";
export const chat = async (req: Request, res: Response, next: NextFunction) => {
try {
const { messages }: { messages: ChatMessage[] } = JSON.parse(req.body);
const { messages }: { messages: ChatMessage[] } = req.body;
const lastMessage = messages.pop();
if (!messages || !lastMessage || lastMessage.role !== "user") {
return res.status(400).json({
@@ -15,10 +15,9 @@ STORAGE_DIR = "./storage" # directory to cache the generated index
DATA_DIR = "./data" # directory containing the documents to index
service_context = ServiceContext.from_defaults(
llm=OpenAI(model="gpt-3.5-turbo")
llm=OpenAI("gpt-3.5-turbo")
)
def get_index():
logger = logging.getLogger("uvicorn")
# check if storage already exists
@@ -1,4 +1,3 @@
from pathlib import Path
import logging
import os
import uvicorn
@@ -7,9 +6,7 @@ from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from dotenv import load_dotenv
load_dotenv(Path('.env'))
print(f"OPENAI_API_KEY: {os.getenv('OPENAI_API_KEY')}")
load_dotenv()
app = FastAPI()
@@ -2,9 +2,6 @@
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ["llamaindex"],
outputFileTracingIncludes: {
"/*": ["./cache/**/*"],
},
},
};
@@ -1,13 +0,0 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "export",
images: { unoptimized: true },
experimental: {
serverComponentsExternalPackages: ["llamaindex"],
outputFileTracingIncludes: {
"/*": ["./cache/**/*"],
},
},
};
module.exports = nextConfig;
@@ -1,2 +0,0 @@
# local env files
.env
@@ -8,24 +8,12 @@ const port = 8000;
const env = process.env["NODE_ENV"];
const isDevelopment = !env || env === "development";
const prodCorsOrigin = process.env["PROD_CORS_ORIGIN"];
if (isDevelopment) {
console.warn("Running in development mode - allowing CORS for all origins");
app.use(cors());
} else if (prodCorsOrigin) {
console.log(
`Running in production mode - allowing CORS for domain: ${prodCorsOrigin}`,
);
const corsOptions = {
origin: prodCorsOrigin, // Restrict to production domain
};
app.use(cors(corsOptions));
} else {
console.warn("Production CORS origin not set, defaulting to no CORS.");
}
app.use(express.text());
app.use(express.json());
app.get("/", (req: Request, res: Response) => {
res.send("LlamaIndex Express Server");
@@ -6,7 +6,7 @@ import { LlamaIndexStream } from "./llamaindex-stream";
export const chat = async (req: Request, res: Response, next: NextFunction) => {
try {
const { messages }: { messages: ChatMessage[] } = JSON.parse(req.body);
const { messages }: { messages: ChatMessage[] } = req.body;
const lastMessage = messages.pop();
if (!messages || !lastMessage || lastMessage.role !== "user") {
return res.status(400).json({
@@ -15,7 +15,7 @@ STORAGE_DIR = "./storage" # directory to cache the generated index
DATA_DIR = "./data" # directory containing the documents to index
service_context = ServiceContext.from_defaults(
llm=OpenAI(model="gpt-3.5-turbo")
llm=OpenAI("gpt-3.5-turbo")
)
def get_index():
@@ -1,4 +1,3 @@
from pathlib import Path
import logging
import os
import uvicorn
@@ -7,8 +6,7 @@ from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from dotenv import load_dotenv
load_dotenv(Path('.env'))
print(f"OPENAI_API_KEY: {os.getenv('OPENAI_API_KEY')}")
load_dotenv()
app = FastAPI()
@@ -2,9 +2,6 @@
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ["llamaindex"],
outputFileTracingIncludes: {
"/*": ["./cache/**/*"],
},
},
};
@@ -1,13 +0,0 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "export",
images: { unoptimized: true },
experimental: {
serverComponentsExternalPackages: ["llamaindex"],
outputFileTracingIncludes: {
"/*": ["./cache/**/*"],
},
},
};
module.exports = nextConfig;