Compare commits

...

9 Commits

Author SHA1 Message Date
sweep-ai[bot] 19452df531 Merge main into sweep/vercel-edge-runtime-support_1 2023-10-18 02:56:58 +00:00
sweep-ai[bot] d26dc414a4 Merge main into sweep/vercel-edge-runtime-support_1 2023-10-17 23:13:56 +00:00
sweep-ai[bot] dc3c423b18 Merge main into sweep/vercel-edge-runtime-support_1 2023-10-16 16:29:23 +00:00
sweep-ai[bot] 17b840dd38 Merge main into sweep/vercel-edge-runtime-support_1 2023-10-16 16:23:15 +00:00
sweep-ai[bot] 29b17d17d3 Merge main into sweep/vercel-edge-runtime-support_1 2023-10-13 01:02:27 +00:00
sweep-ai[bot] 4853a74e9f feat: Add support for Vercel Edge Runtime using @d 2023-10-11 08:17:45 +00:00
sweep-ai[bot] 8128b6ae74 feat: Updated packages/eslint-config-custom/packag 2023-10-11 08:12:23 +00:00
sweep-ai[bot] 0577bd2e4a feat: Updated README.md 2023-10-11 08:11:31 +00:00
sweep-ai[bot] 8b5725b420 feat: Updated apps/docs/docs/environments.md 2023-10-11 08:10:32 +00:00
4 changed files with 32 additions and 7 deletions
+6 -4
View File
@@ -84,12 +84,12 @@ Check out our NextJS playground at https://llama-playground.vercel.app/. The sou
- [SimplePrompt](/packages/core/src/Prompt.ts): A simple standardized function call definition that takes in inputs and formats them in a template literal. SimplePrompts can be specialized using currying and combined using other SimplePrompt functions.
## Note: NextJS:
## Note: NextJS and Vercel Edge Runtime:
If you're using NextJS App Router, you'll need to use the NodeJS runtime (default) and add the follow config to your next.config.js to have it use imports/exports in the same way Node does.
If you're using NextJS App Router, you'll need to use the NodeJS runtime (default). For Vercel Edge Runtime, you'll need to use the "vercel" runtime and add the `@dqbd/tiktoken` package to your `next.config.js` to have it use imports/exports in the same way Node does.
```js
export const runtime = "nodejs" // default
export const runtime = "vercel" // for Vercel Edge Runtime
```
```js
@@ -97,13 +97,15 @@ export const runtime = "nodejs" // default
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ["pdf-parse"], // Puts pdf-parse in actual NodeJS mode with NextJS App Router
serverComponentsExternalPackages: ["pdf-parse", "@dqbd/tiktoken"], // Puts pdf-parse and @dqbd/tiktoken in actual NodeJS mode with NextJS App Router
},
};
module.exports = nextConfig;
```
For detailed instructions, please refer to the [Environments](/apps/docs/docs/environments.md) section.
## Supported LLMs:
- OpenAI GPT-3.5-turbo and GPT-4
+10 -2
View File
@@ -11,7 +11,7 @@ LlamaIndex currently officially supports NodeJS 18 and NodeJS 20.
If you're using NextJS App Router route handlers/serverless functions, you'll need to use the NodeJS mode:
```js
export const runtime = "nodejs" // default
export const runtime = "vercel" // updated to support Vercel Edge Runtime
```
and you'll need to add an exception for pdf-parse in your next.config.js
@@ -21,7 +21,15 @@ and you'll need to add an exception for pdf-parse in your next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ["pdf-parse"], // Puts pdf-parse in actual NodeJS mode with NextJS App Router
// next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ["pdf-parse", "@dqbd/tiktoken"], // Added @dqbd/tiktoken to the list
},
};
module.exports = nextConfig;
},
};
+2 -1
View File
@@ -8,7 +8,8 @@
"eslint-config-next": "^13.4.1",
"eslint-config-prettier": "^8.3.0",
"eslint-config-turbo": "^1.9.3",
"eslint-plugin-react": "7.28.0"
"eslint-plugin-react": "7.28.0",
"@dqbd/tiktoken": "^1.0.7"
},
"publishConfig": {
"access": "public"
+14
View File
@@ -0,0 +1,14 @@
// src/api/v1/llamaIndex/route.ts
import { NextApiRequest, NextApiResponse } from 'next';
import { Tiktoken } from '@dqbd/tiktoken';
import fs from 'fs';
import path from 'path';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
// Initialize the encoder with the required WASM binary file
import tiktoken_bg from '@dqbd/tiktoken/tiktoken_bg.wasm?module';
const tiktoken = new Tiktoken({ wasmBinary: tiktoken_bg });
// Existing route handler logic...
}