Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ca75c81bc0 | |||
| 691c5bcaf1 | |||
| 9ab998c5d5 | |||
| 938b417028 | |||
| fa60fc66ae | |||
| 5607ed2fec | |||
| f57ad6150e | |||
| 2486bd8f41 | |||
| e2a0876ddd | |||
| a75d899a57 | |||
| 809a6e7eea | |||
| da6eb6474b | |||
| cd83f8ee4f | |||
| 534d5505cb | |||
| eb87b96518 | |||
| 9510d45046 | |||
| 9b5b012fdf | |||
| a5a75f618d | |||
| 051faddefd | |||
| 9f22aae57c | |||
| e9a111d9d3 | |||
| bb7622e4d4 | |||
| 06f632b2cb | |||
| 76b925e62a | |||
| 0493f679a4 | |||
| 0e0a627c9a | |||
| 4ba2cfe7ab | |||
| c1578a19d9 | |||
| ae49ff4e15 | |||
| a75af835a5 | |||
| 7c7cd34908 | |||
| f651891196 | |||
| 04714c886f | |||
| cf28574f51 | |||
| 24d065f054 | |||
| b8719586e3 | |||
| 07a40aca49 | |||
| 33b562938d | |||
| 723b41c23c | |||
| 4c38c1be0b | |||
| 0dde0ca27f | |||
| f3e0d07f48 | |||
| 1364e8eeed | |||
| 96fc69cc61 | |||
| 3b7736f763 | |||
| a7a7afe66e | |||
| c646ee2eca | |||
| 5729bd92fd | |||
| e0e52cf879 | |||
| 6f75306c17 | |||
| 94cb4ad810 | |||
| 1ea4014746 | |||
| 6a9a7b1458 | |||
| 1c168cd531 | |||
| 62cba5236d | |||
| d265e96420 | |||
| d30bbf799f | |||
| 53fd00a7c3 | |||
| 83f2848d47 | |||
| 313071e9cd | |||
| 5f6782038a | |||
| fe08d0451b | |||
| 59c5e5c3d4 | |||
| ee697fb1b3 | |||
| cf3320a4ea | |||
| f2ed69f2f8 | |||
| 3489e7de84 | |||
| 468bda594e | |||
| 6f3a31caf6 | |||
| 63e9846e97 | |||
| b7382b0d24 | |||
| 2a8241328d | |||
| 0b20ff9f17 | |||
| 1fc26046e3 | |||
| b17d439d6d |
@@ -0,0 +1,46 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ""
|
||||
labels: bug
|
||||
assignees: ""
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Code to reproduce the behavior:
|
||||
|
||||
```ts
|
||||
// paste the code here
|
||||
```
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
|
||||
- OS: [e.g. macOS, Linux]
|
||||
- JS Runtime / Framework / Bundler (select all applicable)
|
||||
- [ ] Node.js
|
||||
- [ ] Deno
|
||||
- [ ] Bun
|
||||
- [ ] Next.js
|
||||
- [ ] ESBuild
|
||||
- [ ] Rollup
|
||||
- [ ] Webpack
|
||||
- [ ] Turbopack
|
||||
- [ ] Vite
|
||||
- [ ] Waku
|
||||
- [ ] Edge Runtime
|
||||
- [ ] AWS Lambda
|
||||
- [ ] Cloudflare Worker
|
||||
- [ ] Others (please elaborate on this)
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -25,4 +25,4 @@ jobs:
|
||||
run: pnpm run build
|
||||
|
||||
- name: Pre Release
|
||||
run: pnpx pkg-pr-new publish ./packages/*
|
||||
run: pnpx pkg-pr-new publish ./packages/* ./packages/providers/*
|
||||
|
||||
@@ -136,27 +136,26 @@ jobs:
|
||||
run: pnpm run build
|
||||
- name: Copy examples
|
||||
run: rsync -rv --exclude=node_modules ./examples ${{ runner.temp }}
|
||||
- name: Pack @llamaindex/cloud
|
||||
run: pnpm pack --pack-destination ${{ runner.temp }}
|
||||
working-directory: packages/cloud
|
||||
- name: Pack @llamaindex/openai
|
||||
run: pnpm pack --pack-destination ${{ runner.temp }}
|
||||
working-directory: packages/llm/openai
|
||||
- name: Pack @llamaindex/groq
|
||||
run: pnpm pack --pack-destination ${{ runner.temp }}
|
||||
working-directory: packages/llm/groq
|
||||
- name: Pack @llamaindex/ollama
|
||||
run: pnpm pack --pack-destination ${{ runner.temp }}
|
||||
working-directory: packages/llm/ollama
|
||||
- name: Pack @llamaindex/core
|
||||
run: pnpm pack --pack-destination ${{ runner.temp }}
|
||||
working-directory: packages/core
|
||||
- name: Pack @llamaindex/env
|
||||
run: pnpm pack --pack-destination ${{ runner.temp }}
|
||||
working-directory: packages/env
|
||||
- name: Pack llamaindex
|
||||
run: pnpm pack --pack-destination ${{ runner.temp }}
|
||||
working-directory: packages/llamaindex
|
||||
- name: Pack packages
|
||||
run: |
|
||||
for dir in packages/*; do
|
||||
if [ -d "$dir" ] && [ -f "$dir/package.json" ] && [[ ! "$dir" =~ autotool ]]; then
|
||||
echo "Packing $dir"
|
||||
pnpm pack --pack-destination ${{ runner.temp }} -C $dir
|
||||
else
|
||||
echo "Skipping $dir, no package.json found"
|
||||
fi
|
||||
done
|
||||
- name: Pack provider packages
|
||||
run: |
|
||||
for dir in packages/providers/*; do
|
||||
if [ -d "$dir" ] && [ -f "$dir/package.json" ]; then
|
||||
echo "Packing $dir"
|
||||
pnpm pack --pack-destination ${{ runner.temp }} -C $dir
|
||||
else
|
||||
echo "Skipping $dir, no package.json found"
|
||||
fi
|
||||
done
|
||||
- name: Install
|
||||
run: npm add ${{ runner.temp }}/*.tgz
|
||||
working-directory: ${{ runner.temp }}/examples
|
||||
|
||||
@@ -4,3 +4,4 @@ pnpm-lock.yaml
|
||||
lib/
|
||||
dist/
|
||||
.docusaurus/
|
||||
.source/
|
||||
|
||||
@@ -13,5 +13,6 @@
|
||||
},
|
||||
"[json]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
}
|
||||
},
|
||||
"prettier.prettierPath": "./node_modules/prettier"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,147 @@
|
||||
# docs
|
||||
|
||||
## 0.0.101
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
|
||||
## 0.0.100
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.8
|
||||
|
||||
## 0.0.99
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2486bd8]
|
||||
- @llamaindex/examples@0.0.10
|
||||
- llamaindex@0.7.7
|
||||
|
||||
## 0.0.98
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [534d550]
|
||||
- llamaindex@0.7.6
|
||||
|
||||
## 0.0.97
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e9a111d]
|
||||
- Updated dependencies [9f22aae]
|
||||
- llamaindex@0.7.5
|
||||
|
||||
## 0.0.96
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.4
|
||||
|
||||
## 0.0.95
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.3
|
||||
|
||||
## 0.0.94
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.2
|
||||
|
||||
## 0.0.93
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ae49ff4]
|
||||
- Updated dependencies [4c38c1b]
|
||||
- Updated dependencies [a75af83]
|
||||
- Updated dependencies [a75af83]
|
||||
- llamaindex@0.7.1
|
||||
|
||||
## 0.0.92
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [1364e8e]
|
||||
- Updated dependencies [3b7736f]
|
||||
- Updated dependencies [96fc69c]
|
||||
- llamaindex@0.7.0
|
||||
- @llamaindex/examples@0.0.9
|
||||
|
||||
## 0.0.91
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5729bd9]
|
||||
- llamaindex@0.6.22
|
||||
|
||||
## 0.0.90
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6f75306]
|
||||
- Updated dependencies [94cb4ad]
|
||||
- llamaindex@0.6.21
|
||||
|
||||
## 0.0.89
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6a9a7b1]
|
||||
- llamaindex@0.6.20
|
||||
|
||||
## 0.0.88
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [62cba52]
|
||||
- Updated dependencies [d265e96]
|
||||
- Updated dependencies [d30bbf7]
|
||||
- Updated dependencies [53fd00a]
|
||||
- llamaindex@0.6.19
|
||||
|
||||
## 0.0.87
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5f67820]
|
||||
- Updated dependencies [fe08d04]
|
||||
- llamaindex@0.6.18
|
||||
|
||||
## 0.0.86
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ee697fb]
|
||||
- llamaindex@0.6.17
|
||||
|
||||
## 0.0.85
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [63e9846]
|
||||
- Updated dependencies [6f3a31c]
|
||||
- llamaindex@0.6.16
|
||||
|
||||
## 0.0.84
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2a82413]
|
||||
- llamaindex@0.6.15
|
||||
|
||||
## 0.0.83
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.6.14
|
||||
|
||||
## 0.0.82
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -31,7 +31,34 @@ META_LLAMA3_8B_INSTRUCT = "meta.llama3-8b-instruct-v1:0";
|
||||
META_LLAMA3_70B_INSTRUCT = "meta.llama3-70b-instruct-v1:0";
|
||||
META_LLAMA3_1_8B_INSTRUCT = "meta.llama3-1-8b-instruct-v1:0"; // available on us-west-2
|
||||
META_LLAMA3_1_70B_INSTRUCT = "meta.llama3-1-70b-instruct-v1:0"; // available on us-west-2
|
||||
META_LLAMA3_1_405B_INSTRUCT = "meta.llama3-1-405b-instruct-v1:0"; // preview only, available on us-west-2, tool calling supported
|
||||
META_LLAMA3_1_405B_INSTRUCT = "meta.llama3-1-405b-instruct-v1:0"; // available on us-west-2, tool calling supported
|
||||
META_LLAMA3_2_1B_INSTRUCT = "meta.llama3-2-1b-instruct-v1:0"; // only available via inference endpoints (see below)
|
||||
META_LLAMA3_2_3B_INSTRUCT = "meta.llama3-2-3b-instruct-v1:0"; // only available via inference endpoints (see below)
|
||||
META_LLAMA3_2_11B_INSTRUCT = "meta.llama3-2-11b-instruct-v1:0"; // only available via inference endpoints (see below), multimodal and function call supported
|
||||
META_LLAMA3_2_90B_INSTRUCT = "meta.llama3-2-90b-instruct-v1:0"; // only available via inference endpoints (see below), multimodal and function call supported
|
||||
```
|
||||
|
||||
You can also use Bedrock's Inference endpoints by using the model names:
|
||||
|
||||
```ts
|
||||
// US
|
||||
US_ANTHROPIC_CLAUDE_3_HAIKU = "us.anthropic.claude-3-haiku-20240307-v1:0";
|
||||
US_ANTHROPIC_CLAUDE_3_OPUS = "us.anthropic.claude-3-opus-20240229-v1:0";
|
||||
US_ANTHROPIC_CLAUDE_3_SONNET = "us.anthropic.claude-3-sonnet-20240229-v1:0";
|
||||
US_ANTHROPIC_CLAUDE_3_5_SONNET = "us.anthropic.claude-3-5-sonnet-20240620-v1:0";
|
||||
US_ANTHROPIC_CLAUDE_3_5_SONNET_V2 =
|
||||
"us.anthropic.claude-3-5-sonnet-20241022-v2:0";
|
||||
US_META_LLAMA_3_2_1B_INSTRUCT = "us.meta.llama3-2-1b-instruct-v1:0";
|
||||
US_META_LLAMA_3_2_3B_INSTRUCT = "us.meta.llama3-2-3b-instruct-v1:0";
|
||||
US_META_LLAMA_3_2_11B_INSTRUCT = "us.meta.llama3-2-11b-instruct-v1:0";
|
||||
US_META_LLAMA_3_2_90B_INSTRUCT = "us.meta.llama3-2-90b-instruct-v1:0";
|
||||
|
||||
// EU
|
||||
EU_ANTHROPIC_CLAUDE_3_HAIKU = "eu.anthropic.claude-3-haiku-20240307-v1:0";
|
||||
EU_ANTHROPIC_CLAUDE_3_SONNET = "eu.anthropic.claude-3-sonnet-20240229-v1:0";
|
||||
EU_ANTHROPIC_CLAUDE_3_5_SONNET = "eu.anthropic.claude-3-5-sonnet-20240620-v1:0";
|
||||
EU_META_LLAMA_3_2_1B_INSTRUCT = "eu.meta.llama3-2-1b-instruct-v1:0";
|
||||
EU_META_LLAMA_3_2_3B_INSTRUCT = "eu.meta.llama3-2-3b-instruct-v1:0";
|
||||
```
|
||||
|
||||
Sonnet, Haiku and Opus are multimodal, image_url only supports base64 data url format, e.g. `data:image/jpeg;base64,SGVsbG8sIFdvcmxkIQ==`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docs",
|
||||
"version": "0.0.82",
|
||||
"version": "0.0.101",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"docusaurus": "docusaurus",
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# deps
|
||||
/node_modules
|
||||
|
||||
# generated content
|
||||
.contentlayer
|
||||
.content-collections
|
||||
.source
|
||||
|
||||
# test & build
|
||||
/coverage
|
||||
/.next/
|
||||
/out/
|
||||
/build
|
||||
*.tsbuildinfo
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
/.pnp
|
||||
.pnp.js
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# others
|
||||
.env*.local
|
||||
.vercel
|
||||
next-env.d.ts
|
||||
|
||||
# build
|
||||
/src/content/docs/cloud/api
|
||||
@@ -0,0 +1,26 @@
|
||||
# next
|
||||
|
||||
This is a Next.js application generated with
|
||||
[Create Fumadocs](https://github.com/fuma-nama/fumadocs).
|
||||
|
||||
Run development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
pnpm dev
|
||||
# or
|
||||
yarn dev
|
||||
```
|
||||
|
||||
Open http://localhost:3000 with your browser to see the result.
|
||||
|
||||
## Learn More
|
||||
|
||||
To learn more about Next.js and Fumadocs, take a look at the following
|
||||
resources:
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js
|
||||
features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
- [Fumadocs](https://fumadocs.vercel.app) - learn about Fumadocs
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "new-york",
|
||||
"rsc": true,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "tailwind.config.js",
|
||||
"css": "app/global.css",
|
||||
"baseColor": "neutral",
|
||||
"cssVariables": true,
|
||||
"prefix": ""
|
||||
},
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"utils": "@/lib/utils",
|
||||
"ui": "@/components/ui",
|
||||
"lib": "@/lib",
|
||||
"hooks": "@/hooks"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { createMDX } from "fumadocs-mdx/next";
|
||||
|
||||
const withMDX = createMDX();
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const config = {
|
||||
reactStrictMode: true,
|
||||
};
|
||||
|
||||
export default withMDX(config);
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "@llamaindex/doc",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "pnpm run build:docs && next build",
|
||||
"dev": "next dev",
|
||||
"start": "next start",
|
||||
"postinstall": "fumadocs-mdx",
|
||||
"build:docs": "node ./scripts/generate-docs.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@icons-pack/react-simple-icons": "^10.1.0",
|
||||
"@radix-ui/react-icons": "^1.3.0",
|
||||
"@radix-ui/react-slot": "^1.1.0",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"clsx": "2.1.1",
|
||||
"foxact": "^0.2.39",
|
||||
"fumadocs-core": "14.0.2",
|
||||
"fumadocs-mdx": "11.0.0",
|
||||
"fumadocs-openapi": "^5.5.3",
|
||||
"fumadocs-ui": "14.0.2",
|
||||
"hast-util-to-jsx-runtime": "^2.3.2",
|
||||
"lucide-react": "^0.436.0",
|
||||
"next": "15.0.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-icons": "^5.3.0",
|
||||
"react-text-transition": "^3.1.0",
|
||||
"rimraf": "^6.0.1",
|
||||
"shiki": "^1.22.0",
|
||||
"tailwind-merge": "^2.5.2",
|
||||
"tailwindcss-animate": "^1.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mdx": "^2.0.13",
|
||||
"@types/node": "22.7.8",
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"postcss": "^8.4.47",
|
||||
"tailwindcss": "^3.4.14",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
|
After Width: | Height: | Size: 867 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,22 @@
|
||||
import * as OpenAPI from "fumadocs-openapi";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { rimrafSync } from "rimraf";
|
||||
|
||||
const out = "./src/content/docs/cloud/api";
|
||||
|
||||
// clean generated files
|
||||
rimrafSync(out, {
|
||||
filter(v) {
|
||||
return !v.endsWith("index.mdx") && !v.endsWith("meta.json");
|
||||
},
|
||||
});
|
||||
|
||||
void OpenAPI.generateFiles({
|
||||
input: [
|
||||
fileURLToPath(
|
||||
new URL("../../../packages/cloud/openapi.json", import.meta.url),
|
||||
),
|
||||
],
|
||||
output: out,
|
||||
groupBy: "tag",
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import { defineConfig, defineDocs } from "fumadocs-mdx/config";
|
||||
|
||||
export const { docs, meta } = defineDocs({
|
||||
dir: "./src/content/docs",
|
||||
});
|
||||
|
||||
export default defineConfig();
|
||||
@@ -0,0 +1,19 @@
|
||||
import { baseOptions } from "@/app/layout.config";
|
||||
import { Footer } from "@/components/website/Footer";
|
||||
import { HomeLayout } from "fumadocs-ui/layouts/home";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}): React.ReactElement {
|
||||
return (
|
||||
<HomeLayout {...baseOptions}>
|
||||
{children}
|
||||
<div className="container">
|
||||
<Footer />
|
||||
</div>
|
||||
</HomeLayout>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { CodeBlock } from "@/components/code-block";
|
||||
import { Contributing } from "@/components/contribution";
|
||||
import { CreateAppAnimation } from "@/components/create-app-animation";
|
||||
import { Feature } from "@/components/feature";
|
||||
import { NpmInstall } from "@/components/npm-install";
|
||||
import { TextEffect } from "@/components/text-effect";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { SiStackblitz } from "@icons-pack/react-simple-icons";
|
||||
import { Bot, Terminal } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
|
||||
export default function HomePage() {
|
||||
return (
|
||||
<main className="container mx-auto px-4 py-12">
|
||||
<h1 className="text-4xl md:text-6xl font-bold text-center mb-4">
|
||||
Build RAG Web App using
|
||||
<br /> <span className="text-blue-500">LlamaIndex.TS</span>
|
||||
</h1>
|
||||
<p className="text-xl text-center text-fd-muted-foreground mb-12 ">
|
||||
LlamaIndex.TS is the JS/TS library from our popular Python library
|
||||
llama-index for building LLM applications
|
||||
</p>
|
||||
<div className="text-center text-lg text-fd-muted-foreground mb-12">
|
||||
<span>Designed for building web applications under </span>
|
||||
<TextEffect />
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap justify-center gap-4">
|
||||
<Link href="/docs/llamaindex">
|
||||
<Button variant="outline">Get Started</Button>
|
||||
</Link>
|
||||
<NpmInstall />
|
||||
<Link
|
||||
href="https://stackblitz.com/github/run-llama/LlamaIndexTS/tree/main/examples"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
<Button className="bg-blue-500 text-white hover:bg-blue-600">
|
||||
<SiStackblitz />
|
||||
Playground
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
<div className="mt-4" />
|
||||
<div className="grid grid-cols-1 border-r md:grid-cols-2">
|
||||
<Feature
|
||||
icon={Bot}
|
||||
subheading="Agent"
|
||||
heading="Build agent for RAG"
|
||||
description="Build agents for RAG using LlamaIndex.TS. Agents are the core building blocks of RAG applications."
|
||||
>
|
||||
<CodeBlock
|
||||
code={`
|
||||
import { FunctionTool } from "llamaindex";
|
||||
import { OpenAIAgent } from "@llamaindex/openai";
|
||||
|
||||
const interpreterTool = FunctionTool.from(...);
|
||||
const systemPrompt = \`...\`;
|
||||
|
||||
const agent = new OpenAIAgent({
|
||||
llm,
|
||||
tools: [interpreterTool],
|
||||
systemPrompt,
|
||||
});
|
||||
|
||||
await agent.chat('...');`}
|
||||
lang="ts"
|
||||
/>
|
||||
</Feature>
|
||||
<Feature
|
||||
icon={Terminal}
|
||||
subheading="Create Llama CLI"
|
||||
heading="CLI for starting RAG app with one line"
|
||||
description="A command line tool to generate LlamaIndex apps, the easiest way to get started with LlamaIndex."
|
||||
>
|
||||
<div className="my-6">
|
||||
<CreateAppAnimation />
|
||||
</div>
|
||||
</Feature>
|
||||
</div>
|
||||
<Contributing />
|
||||
<div className="border-b" />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { source } from "@/lib/source";
|
||||
import { createFromSource } from "fumadocs-core/search/server";
|
||||
|
||||
export const { GET } = createFromSource(source);
|
||||
@@ -0,0 +1,51 @@
|
||||
import { openapi, source } from "@/lib/source";
|
||||
import defaultMdxComponents from "fumadocs-ui/mdx";
|
||||
import {
|
||||
DocsBody,
|
||||
DocsDescription,
|
||||
DocsPage,
|
||||
DocsTitle,
|
||||
} from "fumadocs-ui/page";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
export default async function Page(props: {
|
||||
params: Promise<{ slug?: string[] }>;
|
||||
}) {
|
||||
const params = await props.params;
|
||||
const page = source.getPage(params.slug);
|
||||
if (!page) notFound();
|
||||
|
||||
const MDX = page.data.body;
|
||||
|
||||
return (
|
||||
<DocsPage toc={page.data.toc} full={page.data.full}>
|
||||
<DocsTitle>{page.data.title}</DocsTitle>
|
||||
<DocsDescription>{page.data.description}</DocsDescription>
|
||||
<DocsBody>
|
||||
<MDX
|
||||
components={{
|
||||
...defaultMdxComponents,
|
||||
APIPage: openapi.APIPage,
|
||||
}}
|
||||
/>
|
||||
</DocsBody>
|
||||
</DocsPage>
|
||||
);
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
return source.generateParams();
|
||||
}
|
||||
|
||||
export async function generateMetadata(props: {
|
||||
params: Promise<{ slug?: string[] }>;
|
||||
}) {
|
||||
const params = await props.params;
|
||||
const page = source.getPage(params.slug);
|
||||
if (!page) notFound();
|
||||
|
||||
return {
|
||||
title: page.data.title,
|
||||
description: page.data.description,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { baseOptions } from "@/app/layout.config";
|
||||
import { source } from "@/lib/source";
|
||||
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
export default function Layout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<DocsLayout tree={source.pageTree} {...baseOptions}>
|
||||
{children}
|
||||
</DocsLayout>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
@layer base {
|
||||
:root {
|
||||
--page-max-width: 1840px;
|
||||
--plus-icon: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTEiIGhlaWdodD0iMTEiIHZpZXdCb3g9IjAgMCAxMSAxMSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDFDNyAwLjQ0NzcxNSA2LjU1MjI4IDAgNiAwSDVDNC40NDc3MiAwIDQgMC40NDc3MTUgNCAxVjNDNCAzLjU1MjI5IDMuNTUyMjggNCAzIDRIMUMwLjQ0NzcxNSA0IDAgNC40NDc3MiAwIDVWNkMwIDYuNTUyMjggMC40NDc3MTUgNyAxIDdIM0MzLjU1MjI4IDcgNCA3LjQ0NzcyIDQgOFYxMEM0IDEwLjU1MjMgNC40NDc3MiAxMSA1IDExSDZDNi41NTIyOCAxMSA3IDEwLjU1MjMgNyAxMFY4QzcgNy40NDc3MSA3LjQ0NzcyIDcgOCA3SDEwQzEwLjU1MjMgNyAxMSA2LjU1MjI4IDExIDZWNUMxMSA0LjQ0NzcyIDEwLjU1MjMgNCAxMCA0SDhDNy40NDc3MiA0IDcgMy41NTIyOCA3IDNWMVoiIGZpbGw9IiNBREE4QzQiLz4KPC9zdmc+Cg==");
|
||||
|
||||
--color-neutral-000: #ffffff;
|
||||
--color-neutral-100: #f7f6fc;
|
||||
--color-neutral-200: #cac6dd;
|
||||
--color-neutral-400: #757185;
|
||||
--color-neutral-800: #252134;
|
||||
--color-neutral-900: #0e0c15;
|
||||
|
||||
--color-purple-400: #858dff;
|
||||
--color-red-400: #ff776f;
|
||||
--color-green-400: #7adb78;
|
||||
--color-yellow-400: #ffc876;
|
||||
--color-violet-400: #ac6aff;
|
||||
--color-pink-400: #ff98e2;
|
||||
|
||||
--background: 0 0% 100%;
|
||||
--foreground: 0 0% 3.9%;
|
||||
--card: 0 0% 100%;
|
||||
--card-foreground: 0 0% 3.9%;
|
||||
--popover: 0 0% 100%;
|
||||
--popover-foreground: 0 0% 3.9%;
|
||||
--primary: 0 0% 9%;
|
||||
--primary-foreground: 0 0% 98%;
|
||||
--secondary: 0 0% 96.1%;
|
||||
--secondary-foreground: 0 0% 9%;
|
||||
--muted: 0 0% 96.1%;
|
||||
--muted-foreground: 0 0% 45.1%;
|
||||
--accent: 0 0% 96.1%;
|
||||
--accent-foreground: 0 0% 9%;
|
||||
--destructive: 0 84.2% 60.2%;
|
||||
--destructive-foreground: 0 0% 98%;
|
||||
--border: 0 0% 89.8%;
|
||||
--input: 0 0% 89.8%;
|
||||
--ring: 0 0% 3.9%;
|
||||
--chart-1: 12 76% 61%;
|
||||
--chart-2: 173 58% 39%;
|
||||
--chart-3: 197 37% 24%;
|
||||
--chart-4: 43 74% 66%;
|
||||
--chart-5: 27 87% 67%;
|
||||
--radius: 0.5rem;
|
||||
}
|
||||
.dark {
|
||||
--color-neutral-000: #0e0c15;
|
||||
--color-neutral-100: #252134;
|
||||
--color-neutral-200: #757185;
|
||||
--color-neutral-400: #cac6dd;
|
||||
--color-neutral-800: #f7f6fc;
|
||||
--color-neutral-900: #ffffff;
|
||||
|
||||
--color-purple-400: #858dff;
|
||||
--color-red-400: #ff776f;
|
||||
--color-green-400: #7adb78;
|
||||
--color-yellow-400: #ffc876;
|
||||
--color-violet-400: #ac6aff;
|
||||
--color-pink-400: #ff98e2;
|
||||
|
||||
--background: 0 0% 3.9%;
|
||||
--foreground: 0 0% 98%;
|
||||
--card: 0 0% 3.9%;
|
||||
--card-foreground: 0 0% 98%;
|
||||
--popover: 0 0% 3.9%;
|
||||
--popover-foreground: 0 0% 98%;
|
||||
--primary: 0 0% 98%;
|
||||
--primary-foreground: 0 0% 9%;
|
||||
--secondary: 0 0% 14.9%;
|
||||
--secondary-foreground: 0 0% 98%;
|
||||
--muted: 0 0% 14.9%;
|
||||
--muted-foreground: 0 0% 63.9%;
|
||||
--accent: 0 0% 14.9%;
|
||||
--accent-foreground: 0 0% 98%;
|
||||
--destructive: 0 62.8% 30.6%;
|
||||
--destructive-foreground: 0 0% 98%;
|
||||
--border: 0 0% 14.9%;
|
||||
--input: 0 0% 14.9%;
|
||||
--ring: 0 0% 83.1%;
|
||||
--chart-1: 220 70% 50%;
|
||||
--chart-2: 160 60% 45%;
|
||||
--chart-3: 30 80% 55%;
|
||||
--chart-4: 280 65% 60%;
|
||||
--chart-5: 340 75% 55%;
|
||||
}
|
||||
}
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-border;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { BaseLayoutProps } from "fumadocs-ui/layouts/shared";
|
||||
|
||||
/**
|
||||
* Shared layout configurations
|
||||
*
|
||||
* you can configure layouts individually from:
|
||||
* Home Layout: app/(home)/layout.tsx
|
||||
* Docs Layout: app/docs/layout.tsx
|
||||
*/
|
||||
export const baseOptions: BaseLayoutProps = {
|
||||
nav: {
|
||||
title: "LlamaIndex.TS",
|
||||
},
|
||||
links: [
|
||||
{
|
||||
text: "Documentation",
|
||||
url: "/docs/llamaindex",
|
||||
active: "nested-url",
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
import { RootProvider } from "fumadocs-ui/provider";
|
||||
import { Inter } from "next/font/google";
|
||||
import type { ReactNode } from "react";
|
||||
import "./global.css";
|
||||
|
||||
const inter = Inter({
|
||||
subsets: ["latin"],
|
||||
});
|
||||
|
||||
export default function Layout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<html lang="en" className={inter.className} suppressHydrationWarning>
|
||||
<head>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="180x180"
|
||||
href="/apple-touch-icon.png"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="32x32"
|
||||
href="/favicon-32x32.png"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="16x16"
|
||||
href="/favicon-16x16.png"
|
||||
/>
|
||||
</head>
|
||||
<body className="flex flex-col min-h-screen">
|
||||
<RootProvider>{children}</RootProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import * as Base from "fumadocs-ui/components/codeblock";
|
||||
import { toJsxRuntime, type Jsx } from "hast-util-to-jsx-runtime";
|
||||
import { Fragment } from "react";
|
||||
import { jsx, jsxs } from "react/jsx-runtime";
|
||||
import { codeToHast } from "shiki";
|
||||
|
||||
export interface CodeBlockProps {
|
||||
code: string;
|
||||
wrapper?: Base.CodeBlockProps;
|
||||
lang: "bash" | "ts" | "tsx";
|
||||
}
|
||||
|
||||
export async function CodeBlock({
|
||||
code,
|
||||
lang,
|
||||
wrapper,
|
||||
}: CodeBlockProps): Promise<React.ReactElement> {
|
||||
const hast = await codeToHast(code, {
|
||||
lang,
|
||||
defaultColor: false,
|
||||
themes: {
|
||||
light: "github-light",
|
||||
dark: "vesper",
|
||||
},
|
||||
transformers: [
|
||||
{
|
||||
name: "rehype-code:pre-process",
|
||||
line(node) {
|
||||
if (node.children.length === 0) {
|
||||
// Keep the empty lines when using grid layout
|
||||
node.children.push({
|
||||
type: "text",
|
||||
value: " ",
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const rendered = toJsxRuntime(hast, {
|
||||
jsx: jsx as Jsx,
|
||||
jsxs: jsxs as Jsx,
|
||||
Fragment,
|
||||
development: false,
|
||||
components: {
|
||||
// @ts-expect-error -- JSX component
|
||||
pre: Base.Pre,
|
||||
},
|
||||
});
|
||||
|
||||
return <Base.CodeBlock {...wrapper}>{rendered}</Base.CodeBlock>;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import ContributorCounter from "@/components/contributor-count";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Heart } from "lucide-react";
|
||||
import { ReactElement } from "react";
|
||||
|
||||
export function Contributing(): ReactElement {
|
||||
return (
|
||||
<div className="flex flex-col items-center border-x border-t px-4 py-16 text-center">
|
||||
<Heart className="mb-4" />
|
||||
<h2 className="mb-4 text-xl font-semibold sm:text-2xl">
|
||||
Made Possible by You.
|
||||
</h2>
|
||||
<p className="mb-4 text-fd-muted-foreground">
|
||||
LlamaIndex.TS is powered by the open source community.
|
||||
</p>
|
||||
<div className="mb-8 flex flex-row items-center gap-2">
|
||||
<a
|
||||
href="https://github.com/run-llama/LlamaIndexTS/graphs/contributors"
|
||||
rel="noreferrer noopener"
|
||||
className={cn(buttonVariants({ variant: "ghost" }))}
|
||||
>
|
||||
See Contributors
|
||||
</a>
|
||||
</div>
|
||||
<ContributorCounter repoOwner="run-llama" repoName="LlamaIndexTS" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import { fetchContributors } from "@/lib/get-contributors";
|
||||
import { cn } from "@/lib/utils";
|
||||
import Image from "next/image";
|
||||
import type { HTMLAttributes, ReactElement } from "react";
|
||||
|
||||
export interface ContributorCounterProps
|
||||
extends HTMLAttributes<HTMLDivElement> {
|
||||
repoOwner: string;
|
||||
repoName: string;
|
||||
displayCount?: number;
|
||||
}
|
||||
|
||||
export default async function ContributorCounter({
|
||||
repoOwner,
|
||||
repoName,
|
||||
displayCount = 20,
|
||||
...props
|
||||
}: ContributorCounterProps): Promise<ReactElement> {
|
||||
const contributors = await fetchContributors(repoOwner, repoName);
|
||||
const topContributors = contributors
|
||||
.filter((contributor) => contributor.login !== repoOwner)
|
||||
.slice(0, displayCount);
|
||||
|
||||
return (
|
||||
<div
|
||||
{...props}
|
||||
className={cn("flex flex-col items-center gap-4", props.className)}
|
||||
>
|
||||
<div className="flex flex-row flex-wrap items-center justify-center md:pe-4">
|
||||
{topContributors.map((contributor, i) => (
|
||||
<a
|
||||
key={contributor.login}
|
||||
href={`https://github.com/${contributor.login}`}
|
||||
rel="noreferrer noopener"
|
||||
target="_blank"
|
||||
className="size-10 overflow-hidden rounded-full border-4 border-fd-background bg-fd-background md:-mr-4 md:size-12"
|
||||
style={{
|
||||
zIndex: topContributors.length - i,
|
||||
}}
|
||||
>
|
||||
<Image
|
||||
src={contributor.avatar_url}
|
||||
alt={`${contributor.login}'s avatar`}
|
||||
unoptimized
|
||||
width={48}
|
||||
height={48}
|
||||
/>
|
||||
</a>
|
||||
))}
|
||||
{displayCount < contributors.length ? (
|
||||
<div className="size-12 content-center rounded-full bg-fd-secondary text-center">
|
||||
+{contributors.length - displayCount}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="text-center text-sm text-fd-muted-foreground">
|
||||
Some of our best contributors.
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
"use client";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { TerminalIcon } from "lucide-react";
|
||||
import {
|
||||
Fragment,
|
||||
HTMLAttributes,
|
||||
ReactElement,
|
||||
ReactNode,
|
||||
useEffect,
|
||||
useState,
|
||||
} from "react";
|
||||
import { Input } from "./ui/input";
|
||||
|
||||
export function CreateAppAnimation(): React.ReactElement {
|
||||
const installCmd = "npx create-llama@latest";
|
||||
const tickTime = 100;
|
||||
const timeCommandEnter = installCmd.length;
|
||||
const timeCommandRun = timeCommandEnter + 3;
|
||||
const timeCommandEnd = timeCommandRun + 3;
|
||||
const timeWindowOpen = timeCommandEnd + 1;
|
||||
const timeEnd = timeWindowOpen + 1;
|
||||
|
||||
const [tick, setTick] = useState(timeEnd);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => {
|
||||
setTick((prev) => (prev >= timeEnd ? prev : prev + 1));
|
||||
}, tickTime);
|
||||
|
||||
return () => {
|
||||
clearInterval(timer);
|
||||
};
|
||||
}, [timeEnd]);
|
||||
|
||||
const lines: ReactElement[] = [];
|
||||
|
||||
lines.push(
|
||||
<span key="command_type">
|
||||
{installCmd.substring(0, tick)}
|
||||
{tick < timeCommandEnter && (
|
||||
<div className="inline-block h-3 w-1 animate-pulse bg-white" />
|
||||
)}
|
||||
</span>,
|
||||
);
|
||||
|
||||
if (tick >= timeCommandEnter) {
|
||||
lines.push(<span key="space"> </span>);
|
||||
}
|
||||
|
||||
if (tick > timeCommandRun)
|
||||
lines.push(
|
||||
<Fragment key="command_response">
|
||||
<span className="font-bold">┌ Create Llama</span>
|
||||
<span>│</span>
|
||||
{tick > timeCommandRun + 1 && (
|
||||
<>
|
||||
<span className="font-bold">◇ What is your project named?</span>
|
||||
<span>│ my-app</span>
|
||||
</>
|
||||
)}
|
||||
{tick > timeCommandRun + 2 && (
|
||||
<>
|
||||
<span>│</span>
|
||||
<span className="font-bold">◆ What app do you want to build?</span>
|
||||
</>
|
||||
)}
|
||||
{tick > timeCommandRun + 3 && (
|
||||
<>
|
||||
<span>│ ● Agentic RAG</span>
|
||||
<span>│ ○ Data Scientist</span>
|
||||
</>
|
||||
)}
|
||||
</Fragment>,
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="relative"
|
||||
onMouseEnter={() => {
|
||||
if (tick >= timeEnd) {
|
||||
setTick(0);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{tick > timeWindowOpen && (
|
||||
<LaunchAppWindow className="absolute bottom-5 right-4 z-10 animate-in fade-in slide-in-from-top-10" />
|
||||
)}
|
||||
<pre className="overflow-hidden rounded-xl border text-xs">
|
||||
<div className="flex flex-row items-center gap-2 border-b px-4 py-2">
|
||||
<TerminalIcon className="size-4" />{" "}
|
||||
<span className="font-bold">Terminal</span>
|
||||
<div className="grow" />
|
||||
<div className="size-2 rounded-full bg-red-400" />
|
||||
</div>
|
||||
<div className="min-h-[200px] bg-gradient-to-b from-fd-secondary [mask-image:linear-gradient(to_bottom,white,transparent)]">
|
||||
<code className="grid p-4">{lines}</code>
|
||||
</div>
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function UserMessage({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<div className="group relative flex items-start">
|
||||
<div className="flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md border shadow-sm bg-background">
|
||||
<IconUser />
|
||||
</div>
|
||||
<div className="ml-4 flex-1 space-y-2 overflow-hidden px-1">
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function BotMessage({
|
||||
children,
|
||||
className,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className={cn("group relative flex items-start", className)}>
|
||||
<div className="flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md border shadow-sm bg-primary text-primary-foreground">
|
||||
<IconAI />
|
||||
</div>
|
||||
<div className="ml-4 flex-1 space-y-2 overflow-hidden px-1">
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ChatExample() {
|
||||
const userMessageFull =
|
||||
"Hello, please summarize the article on the file I uploaded.";
|
||||
const botMessageFull = "Processing...";
|
||||
|
||||
const tickTime = 100;
|
||||
const userMessageDuration = userMessageFull.length;
|
||||
const botMessageDelay = userMessageDuration + 10;
|
||||
const botMessageDuration = botMessageDelay + botMessageFull.length;
|
||||
const totalDuration = botMessageDuration + 10;
|
||||
|
||||
const [tick, setTick] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
// Increment tick every tickTime milliseconds
|
||||
const timer = setInterval(() => {
|
||||
setTick((prev) => (prev >= totalDuration ? prev : prev + 1));
|
||||
}, tickTime);
|
||||
|
||||
return () => {
|
||||
clearInterval(timer);
|
||||
};
|
||||
}, [totalDuration]);
|
||||
|
||||
const userMessageLength = Math.min(tick, userMessageFull.length);
|
||||
const botMessageLength = Math.max(
|
||||
0,
|
||||
Math.min(tick - botMessageDelay, botMessageFull.length),
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="max-w-64">
|
||||
<div className="flex flex-col px-4 gap-2">
|
||||
{userMessageLength === userMessageFull.length && (
|
||||
<UserMessage>
|
||||
<span>{userMessageFull}</span>
|
||||
</UserMessage>
|
||||
)}
|
||||
{tick > botMessageDelay && (
|
||||
<BotMessage>
|
||||
<div>
|
||||
<p>
|
||||
{botMessageFull.substring(0, botMessageLength)}
|
||||
{tick - botMessageDelay < botMessageFull.length && (
|
||||
<span className="inline-block h-3 w-1 animate-pulse bg-white" />
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</BotMessage>
|
||||
)}
|
||||
</div>
|
||||
<Input
|
||||
className="mt-4"
|
||||
value={
|
||||
userMessageFull.substring(0, userMessageLength) === userMessageFull
|
||||
? ""
|
||||
: userMessageFull.substring(0, userMessageLength)
|
||||
}
|
||||
readOnly
|
||||
placeholder="Input message..."
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function LaunchAppWindow(
|
||||
props: HTMLAttributes<HTMLDivElement>,
|
||||
): React.ReactElement {
|
||||
return (
|
||||
<div
|
||||
{...props}
|
||||
className={cn(
|
||||
"overflow-hidden rounded-md border bg-fd-background shadow-xl",
|
||||
props.className,
|
||||
)}
|
||||
>
|
||||
<div className="relative flex h-6 flex-row items-center border-b bg-fd-muted px-4 text-xs text-fd-muted-foreground">
|
||||
<p className="absolute inset-x-0 text-center">localhost:8080</p>
|
||||
</div>
|
||||
<div className="p-4 text-sm">
|
||||
<ChatExample />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function IconUser({ className, ...props }: React.ComponentProps<"svg">) {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 256 256"
|
||||
fill="currentColor"
|
||||
className={cn("h-4 w-4", className)}
|
||||
{...props}
|
||||
>
|
||||
<path d="M230.92 212c-15.23-26.33-38.7-45.21-66.09-54.16a72 72 0 1 0-73.66 0c-27.39 8.94-50.86 27.82-66.09 54.16a8 8 0 1 0 13.85 8c18.84-32.56 52.14-52 89.07-52s70.23 19.44 89.07 52a8 8 0 1 0 13.85-8ZM72 96a56 56 0 1 1 56 56 56.06 56.06 0 0 1-56-56Z" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
function IconAI({ className, ...props }: React.ComponentProps<"svg">) {
|
||||
return (
|
||||
<svg
|
||||
fill="currentColor"
|
||||
viewBox="0 0 256 256"
|
||||
role="img"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className={cn("h-4 w-4", className)}
|
||||
{...props}
|
||||
>
|
||||
<path d="M197.58,129.06l-51.61-19-19-51.65a15.92,15.92,0,0,0-29.88,0L78.07,110l-51.65,19a15.92,15.92,0,0,0,0,29.88L78,178l19,51.62a15.92,15.92,0,0,0,29.88,0l19-51.61,51.65-19a15.92,15.92,0,0,0,0-29.88ZM140.39,163a15.87,15.87,0,0,0-9.43,9.43l-19,51.46L93,172.39A15.87,15.87,0,0,0,83.61,163h0L32.15,144l51.46-19A15.87,15.87,0,0,0,93,115.61l19-51.46,19,51.46a15.87,15.87,0,0,0,9.43,9.43l51.46,19ZM144,40a8,8,0,0,1,8-8h16V16a8,8,0,0,1,16,0V32h16a8,8,0,0,1,0,16H184V64a8,8,0,0,1-16,0V48H152A8,8,0,0,1,144,40ZM248,88a8,8,0,0,1-8,8h-8v8a8,8,0,0,1-16,0V96h-8a8,8,0,0,1,0-16h8V72a8,8,0,0,1,16,0v8h8A8,8,0,0,1,248,88Z"></path>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
import { LucideIcon } from "lucide-react";
|
||||
import { HTMLAttributes, ReactElement, ReactNode } from "react";
|
||||
|
||||
export function Feature({
|
||||
className,
|
||||
icon: Icon,
|
||||
heading,
|
||||
subheading,
|
||||
description,
|
||||
...props
|
||||
}: HTMLAttributes<HTMLDivElement> & {
|
||||
icon: LucideIcon;
|
||||
subheading: ReactNode;
|
||||
heading: ReactNode;
|
||||
description: ReactNode;
|
||||
}): ReactElement {
|
||||
return (
|
||||
<div
|
||||
className={cn("border-l border-t px-6 py-12 md:py-16", className)}
|
||||
{...props}
|
||||
>
|
||||
<div className="mb-4 inline-flex items-center gap-2 text-sm font-medium text-fd-muted-foreground">
|
||||
<Icon className="size-4" />
|
||||
<p>{subheading}</p>
|
||||
</div>
|
||||
<h2 className="mb-2 text-lg font-semibold">{heading}</h2>
|
||||
<p className="text-fd-muted-foreground">{description}</p>
|
||||
|
||||
{props.children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
"use client";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useClipboard } from "foxact/use-clipboard";
|
||||
import { Check, Copy } from "lucide-react";
|
||||
import { useCallback, useState } from "react";
|
||||
|
||||
export const NpmInstall = () => {
|
||||
const { copy } = useClipboard();
|
||||
const [hasCheckIcon, setHasCheckIcon] = useState(false);
|
||||
|
||||
return (
|
||||
<Button
|
||||
onClick={useCallback(() => {
|
||||
copy("npm i llamaindex")
|
||||
.then(() => {
|
||||
setHasCheckIcon(true);
|
||||
|
||||
setTimeout(() => {
|
||||
setHasCheckIcon(false);
|
||||
}, 1000);
|
||||
})
|
||||
.catch(console.error);
|
||||
}, [copy])}
|
||||
variant="outline"
|
||||
className="flex flex-row items-center justify-center"
|
||||
>
|
||||
<code className="mr-2">$ npm i llamaindex</code>
|
||||
<div className="relative cursor-pointer bg-transparent w-4 h-4">
|
||||
<div
|
||||
className={`absolute inset-0 transform transition-all duration-300 ${
|
||||
hasCheckIcon ? "scale-0 opacity-0" : "scale-100 opacity-100"
|
||||
}`}
|
||||
>
|
||||
<Copy className="h-4 w-4 text-zinc-800 dark:text-zinc-200" />
|
||||
</div>
|
||||
<div
|
||||
className={`absolute inset-0 transform transition-all duration-300 ${
|
||||
hasCheckIcon ? "scale-100 opacity-100" : "scale-0 opacity-0"
|
||||
}`}
|
||||
>
|
||||
<Check className="h-4 w-4 text-zinc-800 dark:text-zinc-200" />
|
||||
</div>
|
||||
</div>
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
"use client";
|
||||
import { useEffect, useState } from "react";
|
||||
import ReactTextTransition from "react-text-transition";
|
||||
|
||||
const supports = [
|
||||
"Next.js",
|
||||
"Node.js",
|
||||
"Hono",
|
||||
"Express.js",
|
||||
"Deno",
|
||||
"Nest.js",
|
||||
"Waku",
|
||||
];
|
||||
|
||||
export const TextEffect = () => {
|
||||
const [counter, setCounter] = useState(0);
|
||||
useEffect(() => {
|
||||
const id = setInterval(() => {
|
||||
setCounter(
|
||||
(Math.floor(Math.random() * supports.length) + 1) % supports.length,
|
||||
);
|
||||
}, 4000);
|
||||
return () => {
|
||||
clearInterval(id);
|
||||
};
|
||||
}, []);
|
||||
return <ReactTextTransition inline>{supports[counter]}</ReactTextTransition>;
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const buttonVariants = cva(
|
||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
||||
destructive:
|
||||
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
||||
outline:
|
||||
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
||||
ghost: "hover:bg-accent hover:text-accent-foreground",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
default: "h-9 px-4 py-2",
|
||||
sm: "h-8 rounded-md px-3 text-xs",
|
||||
lg: "h-10 rounded-md px-8",
|
||||
icon: "h-9 w-9",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
export interface ButtonProps
|
||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||
VariantProps<typeof buttonVariants> {
|
||||
asChild?: boolean;
|
||||
}
|
||||
|
||||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
({ className, variant, size, asChild = false, ...props }, ref) => {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
return (
|
||||
<Comp
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
Button.displayName = "Button";
|
||||
|
||||
export { Button, buttonVariants };
|
||||
@@ -0,0 +1,25 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface InputProps
|
||||
extends React.InputHTMLAttributes<HTMLInputElement> {}
|
||||
|
||||
const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
||||
({ className, type, ...props }, ref) => {
|
||||
return (
|
||||
<input
|
||||
type={type}
|
||||
className={cn(
|
||||
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
Input.displayName = "Input";
|
||||
|
||||
export { Input };
|
||||
@@ -0,0 +1,151 @@
|
||||
.footer {
|
||||
width: 100%;
|
||||
max-width: var(--page-max-width);
|
||||
margin-inline: auto;
|
||||
margin-top: 6em;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.navContainer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
row-gap: 3em;
|
||||
border-bottom: 1px var(--color-neutral-200) solid;
|
||||
margin-bottom: 2em;
|
||||
padding-bottom: 2em;
|
||||
}
|
||||
|
||||
.logoContainer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
gap: 5em;
|
||||
margin-bottom: 2em;
|
||||
flex-wrap: wrap;
|
||||
gap: 3em;
|
||||
row-gap: 2em;
|
||||
text-align: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.nav ul {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5em;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.nav ul a {
|
||||
color: var(--color-neutral-400);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav ul a:hover {
|
||||
color: var(--color-neutral-900);
|
||||
}
|
||||
|
||||
.nav ul a:hover span {
|
||||
color: var(--color-neutral-900);
|
||||
}
|
||||
|
||||
.nav ul a span {
|
||||
transition: color 300ms cubic-bezier(0.72, 0, 0.12, 1);
|
||||
}
|
||||
|
||||
.navHeader,
|
||||
.navHeader a {
|
||||
color: var(--color-neutral-900);
|
||||
text-decoration: none;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.navHeader a {
|
||||
transition: color 300ms cubic-bezier(0.72, 0, 0.12, 1);
|
||||
}
|
||||
|
||||
.navHeader a:hover {
|
||||
color: var(--color-neutral-800);
|
||||
}
|
||||
|
||||
.navHeader {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.socialContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.copyright {
|
||||
text-align: center;
|
||||
color: var(--color-neutral-400);
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.copyright a {
|
||||
color: currentColor;
|
||||
text-decoration: none;
|
||||
transition: color 300ms cubic-bezier(0.72, 0, 0.12, 1);
|
||||
}
|
||||
|
||||
.copyright a:hover {
|
||||
color: var(--color-neutral-800);
|
||||
}
|
||||
|
||||
.copyrightContainer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
column-gap: 2em;
|
||||
row-gap: 1em;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 3em;
|
||||
}
|
||||
|
||||
.legalNav {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 1em;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.footer {
|
||||
padding: 0 2em;
|
||||
}
|
||||
|
||||
.footer::before,
|
||||
.footer::after {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 450px) {
|
||||
.navContainer {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.nav {
|
||||
text-align: left;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.logoContainer {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.copyright {
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1300px) {
|
||||
.navContainer {
|
||||
flex-direction: row;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
import Image from "next/image";
|
||||
|
||||
import { Text } from "@/components/website/Text";
|
||||
|
||||
import { Socials } from "@/components/website/Socials";
|
||||
import styles from "./Footer.module.css";
|
||||
|
||||
const Footer = () => {
|
||||
return (
|
||||
<footer className={styles.footer}>
|
||||
<div className={styles.navContainer}>
|
||||
<div className={styles.logoContainer}>
|
||||
<Image
|
||||
src="/llamaindex.svg"
|
||||
alt="LlamaIndex"
|
||||
width={213}
|
||||
height={42}
|
||||
/>
|
||||
<div className={styles.socialContainer}>
|
||||
<Socials />
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.nav}>
|
||||
<div>
|
||||
<Text size={20} weight={600} as="h3" className={styles.navHeader}>
|
||||
<a href="https://llamaindex.ai">LlamaIndex</a>
|
||||
</Text>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://llamaindex.ai/blog">
|
||||
<Text as="span">Blog</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://llamaindex.ai/partners">
|
||||
<Text as="span">Partners</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://llamaindex.ai/careers">
|
||||
<Text as="span">Careers</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://llamaindex.ai/contact">
|
||||
<Text as="span">Contact</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://llamaindex.statuspage.io" target="_blank">
|
||||
<Text as="span">Status</Text>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<Text size={20} weight={600} as="h3" className={styles.navHeader}>
|
||||
<a href="https://llamaindex.ai/enterprise">Enterprise</a>
|
||||
</Text>
|
||||
<ul>
|
||||
<li>
|
||||
<a
|
||||
href="https://cloud.llamaindex.ai"
|
||||
data-tracking-variant="link"
|
||||
data-tracking-section="footer"
|
||||
>
|
||||
<Text as="span">LlamaCloud</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://cloud.llamaindex.ai/parse"
|
||||
data-tracking-variant="link"
|
||||
data-tracking-section="footer"
|
||||
>
|
||||
<Text as="span">LlamaParse</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://llamaindex.ai/llamacloud-sharepoint-data-loading-for-generative-ai"
|
||||
data-tracking-variant="link"
|
||||
data-tracking-section="footer"
|
||||
>
|
||||
<Text as="span">SharePoint</Text>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<Text size={20} weight={600} as="h3" className={styles.navHeader}>
|
||||
<a href="https://llamaindex.ai/open-source">Open Source</a>
|
||||
</Text>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://pypi.org/project/llama-index/">
|
||||
<Text as="span">Python package</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://docs.llamaindex.ai">
|
||||
<Text as="span">Python docs</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.npmjs.com/package/llamaindex">
|
||||
<Text as="span">TypeScript package</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://ts.llamaindex.ai">
|
||||
<Text as="span">TypeScript docs</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://llamahub.ai">
|
||||
<Text as="span">LlamaHub</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/run-llama">
|
||||
<Text as="span">GitHub</Text>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<Text size={20} weight={600} as="h3" className={styles.navHeader}>
|
||||
<a href="https://llamaindex.ai/community">Community</a>
|
||||
</Text>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://llamaindex.ai/community#newsletter">
|
||||
<Text as="span">Newsletter</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://discord.com/invite/eN6D2HQ4aX">
|
||||
<Text as="span">Discord</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://twitter.com/llama_index">
|
||||
<Text as="span">Twitter/X</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.linkedin.com/company/91154103/">
|
||||
<Text as="span">LinkedIn</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.youtube.com/@LlamaIndex">
|
||||
<Text as="span">YouTube</Text>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<Text size={20} weight={600} as="h3" className={styles.navHeader}>
|
||||
Starter projects
|
||||
</Text>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://www.npmjs.com/package/create-llama">
|
||||
<Text as="span">create-llama</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://secinsights.ai">
|
||||
<Text as="span">SEC Insights</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://chat.llamaindex.ai/">
|
||||
<Text as="span">Chat LlamaIndex</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/run-llama/llamabot">
|
||||
<Text as="span">LlamaBot</Text>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://docs.llamaindex.ai/en/stable/use_cases/q_and_a/rag_cli.html">
|
||||
<Text as="span">RAG CLI</Text>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.copyrightContainer}>
|
||||
<Text className={styles.copyright} size={14}>
|
||||
© {new Date().getFullYear()} LlamaIndex
|
||||
</Text>
|
||||
<div className={styles.legalNav}>
|
||||
<Text className={styles.copyright} size={14}>
|
||||
<a href="https://llamaindex.ai/files/privacy-notice.pdf">
|
||||
Privacy Notice
|
||||
</a>
|
||||
</Text>
|
||||
<Text className={styles.copyright} size={14}>
|
||||
<a href="https://llamaindex.ai/files/terms-of-service.pdf">
|
||||
Terms of Service
|
||||
</a>
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
export { Footer };
|
||||
@@ -0,0 +1,4 @@
|
||||
.underline {
|
||||
display: inline-grid;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { ReactNode } from "react";
|
||||
|
||||
import styles from "./HeadingUnderline.module.css";
|
||||
|
||||
interface HeadingUnderlineProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
const HeadingUnderline = ({ children }: HeadingUnderlineProps) => (
|
||||
<span className={styles.underline}>
|
||||
{children}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 352 16"
|
||||
fill="none"
|
||||
preserveAspectRatio="none"
|
||||
>
|
||||
<path
|
||||
fill="url(#paint0_angular_57_743)"
|
||||
fillRule="evenodd"
|
||||
d="M350.974 15.007C216.288-1.307 61.29 8.211.669 15.01L0 9.048C60.879 2.22 216.381-7.34 351.695 9.05l-.721 5.956Z"
|
||||
clipRule="evenodd"
|
||||
/>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="paint0_angular_57_743"
|
||||
x1={172}
|
||||
x2={180.5}
|
||||
y1={32.5}
|
||||
y2={-24.5}
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#BB8DEB" />
|
||||
<stop offset={0.291} stopColor="#F8DFD8" />
|
||||
<stop offset={0.632} stopColor="#FFA6EA" />
|
||||
<stop offset={0.881} stopColor="#45DFF8" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
</span>
|
||||
);
|
||||
|
||||
export { HeadingUnderline };
|
||||
@@ -0,0 +1,53 @@
|
||||
.socials {
|
||||
--background-color: var(--color-neutral-100);
|
||||
--icon-color: var(--color-neutral-400);
|
||||
|
||||
list-style: none;
|
||||
display: flex;
|
||||
gap: 2em;
|
||||
}
|
||||
|
||||
.socials a {
|
||||
width: 2.5em;
|
||||
height: 2.5em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
background-color: var(--background-color);
|
||||
color: var(--icon-color);
|
||||
transition:
|
||||
color 300ms cubic-bezier(0.72, 0, 0.12, 1),
|
||||
background 300ms cubic-bezier(0.72, 0, 0.12, 1);
|
||||
}
|
||||
|
||||
.socials a:hover {
|
||||
background-color: var(--icon-color);
|
||||
color: var(--background-color);
|
||||
}
|
||||
|
||||
.socials-theme-dark {
|
||||
--background-color: #dedceb;
|
||||
}
|
||||
|
||||
.socialsWithDescription {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.socialsWithDescription li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1em;
|
||||
}
|
||||
|
||||
.icons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5em;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.socials {
|
||||
gap: 1em;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
import clsx from "clsx";
|
||||
|
||||
import {
|
||||
FaDiscord,
|
||||
FaGithub,
|
||||
FaLinkedin,
|
||||
FaPython,
|
||||
FaYoutube,
|
||||
} from "react-icons/fa";
|
||||
import { FaXTwitter } from "react-icons/fa6";
|
||||
import { SiTypescript } from "react-icons/si";
|
||||
|
||||
import { Text } from "@/components/website/Text";
|
||||
|
||||
import styles from "./Socials.module.css";
|
||||
|
||||
interface SocialsProps {
|
||||
className?: string;
|
||||
showDescription?: boolean;
|
||||
theme?: "light" | "dark";
|
||||
}
|
||||
|
||||
const Socials = ({
|
||||
theme = "light",
|
||||
showDescription = false,
|
||||
className,
|
||||
}: SocialsProps) => (
|
||||
<>
|
||||
{!showDescription && <IconsList theme={theme} className={className} />}
|
||||
{showDescription && (
|
||||
<IconsWithDescription theme={theme} className={className} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
const IconsList = ({ theme, className }: SocialsProps) => (
|
||||
<ul
|
||||
className={clsx(
|
||||
styles.socials,
|
||||
styles[`socials-theme-${theme}`],
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<li>
|
||||
<a href="https://github.com/run-llama/llama_index">
|
||||
<FaGithub />
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://discord.com/invite/eN6D2HQ4aX">
|
||||
<FaDiscord />
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://twitter.com/llama_index">
|
||||
<FaXTwitter />
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.linkedin.com/company/91154103/">
|
||||
<FaLinkedin />
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.youtube.com/@LlamaIndex">
|
||||
<FaYoutube />
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
);
|
||||
|
||||
const IconsWithDescription = ({ theme, className }: SocialsProps) => (
|
||||
<ul
|
||||
className={clsx(
|
||||
styles.socials,
|
||||
styles.socialsWithDescription,
|
||||
styles[`socials-theme-${theme}`],
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<li>
|
||||
<div className={styles.icons}>
|
||||
<a href="https://github.com/run-llama/llama_index">
|
||||
<FaPython />
|
||||
</a>
|
||||
<a href="https://github.com/run-llama/LlamaIndexTS">
|
||||
<SiTypescript />
|
||||
</a>
|
||||
</div>
|
||||
<Text>File issues and contribute patches</Text>
|
||||
</li>
|
||||
<li>
|
||||
<div className={styles.icons}>
|
||||
<a href="https://twitter.com/llama_index">
|
||||
<FaXTwitter />
|
||||
</a>
|
||||
<a href="https://www.linkedin.com/company/91154103/">
|
||||
<FaLinkedin />
|
||||
</a>
|
||||
</div>
|
||||
<Text>Follow us on social media for the latest updates</Text>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://discord.com/invite/eN6D2HQ4aX">
|
||||
<FaDiscord />
|
||||
</a>
|
||||
<Text>Get help from LlamaIndex and your peers</Text>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="https://www.youtube.com/@LlamaIndex">
|
||||
<FaYoutube />
|
||||
</a>
|
||||
<Text>Dive in to our tutorials and webinars</Text>
|
||||
</li>
|
||||
</ul>
|
||||
);
|
||||
|
||||
export { Socials };
|
||||
@@ -0,0 +1,96 @@
|
||||
.text {
|
||||
font-family: var(--font-inter);
|
||||
font-size: clamp(0.875rem, -0.4286rem + 4.5714vw, 1rem); /* 14px -> 16px */
|
||||
line-height: 1.6;
|
||||
letter-spacing: -0.04em;
|
||||
}
|
||||
|
||||
.text-size-12,
|
||||
.text-size-16,
|
||||
.text-size-18,
|
||||
.text-size-20 {
|
||||
color: var(--color-neutral-400);
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.text-size-32,
|
||||
.text-size-36,
|
||||
.text-size-40,
|
||||
.text-size-48,
|
||||
.text-size-60 {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.text-weight-400 {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.text-weight-500 {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.text-weight-600 {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.text-align-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.text-size-12 {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
.text-size-14 {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
|
||||
.text-size-18 {
|
||||
font-size: clamp(1rem, -0.4286rem + 4.5714vw, 1.125rem); /* 16px -> 18px */
|
||||
}
|
||||
|
||||
.text-size-20 {
|
||||
font-size: clamp(1rem, -0.4286rem + 4.5714vw, 1.25rem); /* 16px -> 20px */
|
||||
}
|
||||
|
||||
.text-size-24 {
|
||||
font-size: clamp(1.25rem, -0.4286rem + 4.5714vw, 1.5rem); /* 20px -> 24px */
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.text-size-28 {
|
||||
font-size: clamp(1.25rem, -0.4286rem + 4.5714vw, 1.75rem);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.text-size-32 {
|
||||
font-size: clamp(1.25rem, -0.4286rem + 4.5714vw, 2rem); /* 20px -> 32px */
|
||||
}
|
||||
|
||||
.text-size-36 {
|
||||
font-size: clamp(1.5rem, -0.4286rem + 4.5714vw, 2.25rem); /* 24px -> 36px */
|
||||
}
|
||||
|
||||
.text-size-40 {
|
||||
line-height: 1.2;
|
||||
font-size: clamp(1.75rem, -0.4286rem + 4.5714vw, 2.5rem); /* 28px -> 40px */
|
||||
}
|
||||
|
||||
.text-size-48 {
|
||||
font-size: 3em;
|
||||
font-size: clamp(1.75rem, -0.4286rem + 4.5714vw, 3rem); /* 28px -> 48px */
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.text-size-60 {
|
||||
line-height: 1.2;
|
||||
font-size: clamp(1.75rem, -0.4286rem + 4.5714vw, 3.75rem); /* 28px -> 60px */
|
||||
}
|
||||
|
||||
.text-family-sourceCodePro {
|
||||
font-family: var(--font-source-code-pro);
|
||||
}
|
||||
|
||||
.text-family-spaceGrotesk {
|
||||
font-family: var(--font-space-grotesk);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import clsx from "clsx";
|
||||
import { Fragment, ReactNode } from "react";
|
||||
|
||||
import { HeadingUnderline } from "@/components/website/HeadingUnderline";
|
||||
|
||||
import styles from "./Text.module.css";
|
||||
|
||||
export interface TextProps {
|
||||
align?: "left" | "center" | "right";
|
||||
size?: 12 | 14 | 16 | 18 | 20 | 24 | 28 | 32 | 36 | 40 | 48 | 60;
|
||||
family?: "inter" | "spaceGrotesk" | "sourceCodePro";
|
||||
weight?: 400 | 500 | 600;
|
||||
children?: ReactNode;
|
||||
className?: string;
|
||||
as?: any;
|
||||
maximumWidth?: any;
|
||||
}
|
||||
|
||||
const Text = ({
|
||||
align = "left",
|
||||
weight,
|
||||
children,
|
||||
className,
|
||||
size = 16,
|
||||
family,
|
||||
maximumWidth,
|
||||
as = "p",
|
||||
}: TextProps) => {
|
||||
const Component = as;
|
||||
|
||||
const renderTextWithComponent = (substring: string) => {
|
||||
if (substring.startsWith("|") && substring.endsWith("|")) {
|
||||
const content = substring.slice(1, -1);
|
||||
|
||||
return <HeadingUnderline>{content}</HeadingUnderline>;
|
||||
}
|
||||
|
||||
return substring;
|
||||
};
|
||||
|
||||
const renderedString =
|
||||
children &&
|
||||
typeof children === "string" &&
|
||||
children
|
||||
.toString()
|
||||
.split(/(\|.*?\|)/g)
|
||||
.map((substring: string) => (
|
||||
<Fragment key={substring}>
|
||||
{renderTextWithComponent(substring)}
|
||||
</Fragment>
|
||||
));
|
||||
|
||||
return (
|
||||
<Component
|
||||
className={clsx(
|
||||
styles.text,
|
||||
align && styles[`text-align-${align}`],
|
||||
size && styles[`text-size-${size}`],
|
||||
weight && styles[`text-weight-${weight}`],
|
||||
family && styles[`text-family-${family}`],
|
||||
className,
|
||||
)}
|
||||
style={{ maxWidth: maximumWidth ? `${maximumWidth}px` : undefined }}
|
||||
>
|
||||
{renderedString || children}
|
||||
</Component>
|
||||
);
|
||||
};
|
||||
|
||||
export { Text };
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
title: LlamaCloud
|
||||
description: LlamaCloud is a new generation of managed parsing, ingestion, and retrieval services, designed to bring production-grade context-augmentation to your LLM and RAG applications.
|
||||
---
|
||||
|
||||
This is TypeScript binding for LlamaCloud API. It provides a simple way to interact with LlamaCloud API.
|
||||
|
||||
If you are looking for the official documentation, please visit the [Official Document](https://docs.cloud.llamaindex.ai/)
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"title": "LlamaCloud",
|
||||
"description": "The Cloud framework for LLM",
|
||||
"root": true,
|
||||
"pages": ["---Guide---", "index", "api"]
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
---
|
||||
title: What is LlamaIndex?
|
||||
description: LlamaIndex is a framework for building LLM-powered applications.
|
||||
---
|
||||
|
||||
import {
|
||||
SiGithub,
|
||||
SiNpm,
|
||||
SiX,
|
||||
SiDiscord,
|
||||
} from "@icons-pack/react-simple-icons";
|
||||
import { CodeBlock, Pre } from "fumadocs-ui/components/codeblock";
|
||||
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
||||
|
||||
LlamaIndex helps you ingest, structure, and access private or domain-specific data. It's available [as a Python package](https://docs.llamaindex.ai/en/stable/) and in TypeScript (this package).
|
||||
|
||||
LlamaIndex.TS offers the core features of LlamaIndex for JS Runtime-agnostic (Node.js, Deno, and Bun) applications.
|
||||
|
||||
## 🚀 Why LlamaIndex.TS?
|
||||
|
||||
LLMs offer a natural language interface between humans and inferred data. Widely available models come pre-trained on huge amounts of publicly available data, from Wikipedia and mailing lists to textbooks and source code.
|
||||
|
||||
Applications built on top of LLMs often require augmenting these models with private or domain-specific data. That data is often distributed across siloed applications and data stores. It's behind APIs, in SQL databases, or trapped in PDFs and slide decks.
|
||||
|
||||
LlamaIndex.TS helps you unlock that data and then build powerful applications with it.
|
||||
|
||||
## 🦙 What is LlamaIndex for?
|
||||
|
||||
LlamaIndex.TS handles several major use cases:
|
||||
|
||||
- **Structured Data Extraction**: turning complex, unstructured and semi-structured data into uniform, programmatically accessible formats.
|
||||
- **Retrieval-Augmented Generation (RAG)**: answering queries across your internal data by providing LLMs with up-to-date, semantically relevant context including Question and Answer systems and chat bots.
|
||||
- **Autonomous Agents**: building software that is capable of intelligently selecting and using tools to accomplish tasks in an interactive, unsupervised manner.
|
||||
|
||||
## 👨👩👧👦 Who is LlamaIndex for?
|
||||
|
||||
LlamaIndex targets the "AI Engineer": developers building software in any domain that can be enhanced by LLM-powered functionality, without needing to be an expert in machine learning or natural language processing.
|
||||
|
||||
Our high-level API allows beginner users to use LlamaIndex.TS to ingest, index, and query their data in just a few lines of code.
|
||||
|
||||
For more complex applications, our lower-level APIs allow advanced users to customize and extend any module—data connectors, indices, retrievers, and query engines, to fit their needs.
|
||||
|
||||
## Getting Started
|
||||
|
||||
<Tabs items={["npm", "yarn", "pnpm"]}>
|
||||
<Tab value="npm">
|
||||
<CodeBlock language="shell">
|
||||
<Pre>npm install llamaindex</Pre>
|
||||
</CodeBlock>
|
||||
</Tab>
|
||||
<Tab value="yarn">
|
||||
<CodeBlock language="shell">
|
||||
<Pre>yarn add llamaindex</Pre>
|
||||
</CodeBlock>
|
||||
</Tab>
|
||||
<Tab value="pnpm">
|
||||
<CodeBlock language="shell">
|
||||
<Pre>pnpm add llamaindex</Pre>
|
||||
</CodeBlock>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
Our documentation includes [Installation Instructions](./getting_started/installation.mdx) and a [Starter Tutorial](./getting_started/starter_tutorial/retrieval_augmented_generation.mdx) to build your first application.
|
||||
|
||||
Once you're up and running, [High-Level Concepts](./getting_started/concepts.md) has an overview of LlamaIndex's modular architecture. For more hands-on practical examples, look through our Examples section on the sidebar.
|
||||
|
||||
## 🗺️ Ecosystem
|
||||
|
||||
To download or contribute, find LlamaIndex on:
|
||||
|
||||
<Cards>
|
||||
<Card
|
||||
icon={<SiGithub />}
|
||||
title="GitHub"
|
||||
href="https://github.com/run-llama/LlamaIndexTS"
|
||||
/>
|
||||
<Card
|
||||
icon={<SiNpm />}
|
||||
title="NPM"
|
||||
href="https://www.npmjs.com/package/llamaindex"
|
||||
/>
|
||||
</Cards>
|
||||
|
||||
## Community
|
||||
|
||||
Need help? Have a feature suggestion? Join the LlamaIndex community:
|
||||
|
||||
<Cards>
|
||||
<Card icon={<SiX />} title="Twitter" href="https://twitter.com/llama_index" />
|
||||
<Card
|
||||
icon={<SiDiscord />}
|
||||
title="Discord"
|
||||
href="https://discord.gg/dGcwcsnxhU"
|
||||
/>
|
||||
</Cards>
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"title": "LlamaIndex",
|
||||
"description": "The Data framework for LLM",
|
||||
"root": true,
|
||||
"pages": ["---Guide---", "index"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"pages": ["llamaindex", "cloud"]
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
export interface Contributor {
|
||||
avatar_url: string;
|
||||
login: string;
|
||||
contributions: number;
|
||||
}
|
||||
|
||||
export async function fetchContributors(
|
||||
repoOwner: string,
|
||||
repoName: string,
|
||||
): Promise<Contributor[]> {
|
||||
const headers = new Headers();
|
||||
if (process.env.GITHUB_TOKEN)
|
||||
headers.set('Authorization', `Bearer ${process.env.GITHUB_TOKEN}`);
|
||||
|
||||
const response = await fetch(
|
||||
`https://api.github.com/repos/${repoOwner}/${repoName}/contributors?per_page=50`,
|
||||
{
|
||||
headers,
|
||||
next: { revalidate: 1000 * 1000 },
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch contributors: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const contributors = (await response.json()) as Contributor[];
|
||||
return contributors
|
||||
.filter((contributor) => !contributor.login.endsWith('[bot]'))
|
||||
.sort((a, b) => b.contributions - a.contributions);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { docs, meta } from '../../.source';
|
||||
import { createMDXSource } from 'fumadocs-mdx';
|
||||
import { loader } from 'fumadocs-core/source';
|
||||
import { createOpenAPI } from "fumadocs-openapi/server";
|
||||
|
||||
export const source = loader({
|
||||
baseUrl: '/docs',
|
||||
source: createMDXSource(docs, meta),
|
||||
});
|
||||
|
||||
export const openapi = createOpenAPI();
|
||||
@@ -0,0 +1,6 @@
|
||||
import { clsx, type ClassValue } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import { createPreset } from "fumadocs-ui/tailwind-plugin";
|
||||
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
darkMode: ["class"],
|
||||
content: [
|
||||
"./src/components/**/*.{ts,tsx}",
|
||||
"./src/app/**/*.{ts,tsx}",
|
||||
"./src/content/**/*.{md,mdx}",
|
||||
"./src/mdx-components.{ts,tsx}",
|
||||
"./node_modules/fumadocs-ui/dist/**/*.js",
|
||||
"./node_modules/fumadocs-openapi/dist/**/*.js",
|
||||
],
|
||||
presets: [createPreset()],
|
||||
plugins: [require("tailwindcss-animate")],
|
||||
theme: {
|
||||
extend: {
|
||||
borderRadius: {
|
||||
lg: "var(--radius)",
|
||||
md: "calc(var(--radius) - 2px)",
|
||||
sm: "calc(var(--radius) - 4px)",
|
||||
},
|
||||
colors: {
|
||||
background: "hsl(var(--background))",
|
||||
foreground: "hsl(var(--foreground))",
|
||||
card: {
|
||||
DEFAULT: "hsl(var(--card))",
|
||||
foreground: "hsl(var(--card-foreground))",
|
||||
},
|
||||
popover: {
|
||||
DEFAULT: "hsl(var(--popover))",
|
||||
foreground: "hsl(var(--popover-foreground))",
|
||||
},
|
||||
primary: {
|
||||
DEFAULT: "hsl(var(--primary))",
|
||||
foreground: "hsl(var(--primary-foreground))",
|
||||
},
|
||||
secondary: {
|
||||
DEFAULT: "hsl(var(--secondary))",
|
||||
foreground: "hsl(var(--secondary-foreground))",
|
||||
},
|
||||
muted: {
|
||||
DEFAULT: "hsl(var(--muted))",
|
||||
foreground: "hsl(var(--muted-foreground))",
|
||||
},
|
||||
accent: {
|
||||
DEFAULT: "hsl(var(--accent))",
|
||||
foreground: "hsl(var(--accent-foreground))",
|
||||
},
|
||||
destructive: {
|
||||
DEFAULT: "hsl(var(--destructive))",
|
||||
foreground: "hsl(var(--destructive-foreground))",
|
||||
},
|
||||
border: "hsl(var(--border))",
|
||||
input: "hsl(var(--input))",
|
||||
ring: "hsl(var(--ring))",
|
||||
chart: {
|
||||
1: "hsl(var(--chart-1))",
|
||||
2: "hsl(var(--chart-2))",
|
||||
3: "hsl(var(--chart-3))",
|
||||
4: "hsl(var(--chart-4))",
|
||||
5: "hsl(var(--chart-5))",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"target": "ESNext",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
]
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
@@ -1,5 +1,25 @@
|
||||
# examples
|
||||
|
||||
## 0.0.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 2486bd8: Add files_via_content example for LlamaCloud retrieval
|
||||
- Updated dependencies [e2a0876]
|
||||
- @llamaindex/core@0.3.4
|
||||
- llamaindex@0.7.7
|
||||
|
||||
## 0.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [1364e8e]
|
||||
- Updated dependencies [96fc69c]
|
||||
- Updated dependencies [3b7736f]
|
||||
- Updated dependencies [96fc69c]
|
||||
- llamaindex@0.7.0
|
||||
- @llamaindex/core@0.3.0
|
||||
|
||||
## 0.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -13,7 +13,7 @@ import { FunctionTool, OpenAI, ToolCallOptions } from "llamaindex";
|
||||
}
|
||||
})();
|
||||
|
||||
async function callLLM(init: Partial<OpenAI>) {
|
||||
async function callLLM(init: { model: string }) {
|
||||
const csvData =
|
||||
"Country,Average Height (cm)\nNetherlands,156\nDenmark,158\nNorway,160";
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
AstraDBVectorStore,
|
||||
Document,
|
||||
MetadataFilters,
|
||||
storageContextFromDefaults,
|
||||
VectorStoreIndex,
|
||||
} from "llamaindex";
|
||||
@@ -42,8 +43,10 @@ async function main() {
|
||||
const index = await VectorStoreIndex.fromDocuments(docs, {
|
||||
storageContext: ctx,
|
||||
});
|
||||
|
||||
const queryEngine = index.asQueryEngine();
|
||||
const preFilters: MetadataFilters = {
|
||||
filters: [{ key: "id", operator: "in", value: [123, 789] }],
|
||||
}; // try changing the filters to see the different results
|
||||
const queryEngine = index.asQueryEngine({ preFilters });
|
||||
const response = await queryEngine.query({
|
||||
query: "Describe AstraDB.",
|
||||
});
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import {
|
||||
DefaultAzureCredential,
|
||||
getBearerTokenProvider,
|
||||
} from "@azure/identity";
|
||||
import "dotenv/config";
|
||||
import { OpenAI, OpenAIEmbedding } from "llamaindex";
|
||||
|
||||
const AZURE_COGNITIVE_SERVICES_SCOPE =
|
||||
"https://cognitiveservices.azure.com/.default";
|
||||
|
||||
(async () => {
|
||||
const credential = new DefaultAzureCredential();
|
||||
const azureADTokenProvider = getBearerTokenProvider(
|
||||
credential,
|
||||
AZURE_COGNITIVE_SERVICES_SCOPE,
|
||||
);
|
||||
|
||||
const azure = {
|
||||
azureADTokenProvider,
|
||||
deployment: process.env.AZURE_DEPLOYMENT_NAME ?? "gpt-35-turbo",
|
||||
};
|
||||
const llm = new OpenAI({ azure });
|
||||
// complete api
|
||||
const response1 = await llm.complete({ prompt: "How are you?" });
|
||||
console.log(response1.text);
|
||||
|
||||
// chat api
|
||||
const response2 = await llm.chat({
|
||||
messages: [{ content: "Tell me a joke.", role: "user" }],
|
||||
});
|
||||
console.log(response2.message.content);
|
||||
|
||||
// embeddings
|
||||
const embedModel = new OpenAIEmbedding({
|
||||
azure: {
|
||||
...azure,
|
||||
deployment: process.env.EMBEDDING_MODEL,
|
||||
},
|
||||
});
|
||||
|
||||
const texts = ["hello", "world"];
|
||||
const embeddings = await embedModel.getTextEmbeddingsBatch(texts);
|
||||
console.log(`\nWe have ${embeddings.length} embeddings`);
|
||||
})();
|
||||
@@ -1,57 +1,83 @@
|
||||
import {
|
||||
ChromaVectorStore,
|
||||
Document,
|
||||
MetadataFilters,
|
||||
VectorStoreIndex,
|
||||
storageContextFromDefaults,
|
||||
} from "llamaindex";
|
||||
|
||||
const collectionName = "dog_colors";
|
||||
const collectionName = "dogs_with_color";
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const docs = [
|
||||
new Document({
|
||||
text: "The dog is brown",
|
||||
metadata: {
|
||||
dogId: "1",
|
||||
},
|
||||
}),
|
||||
new Document({
|
||||
text: "The dog is red",
|
||||
metadata: {
|
||||
dogId: "2",
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
console.log("Creating ChromaDB vector store");
|
||||
const chromaVS = new ChromaVectorStore({ collectionName });
|
||||
const ctx = await storageContextFromDefaults({ vectorStore: chromaVS });
|
||||
const index = await VectorStoreIndex.fromVectorStore(chromaVS);
|
||||
|
||||
console.log("Embedding documents and adding to index");
|
||||
const index = await VectorStoreIndex.fromDocuments(docs, {
|
||||
storageContext: ctx,
|
||||
});
|
||||
const queryFn = async (filters?: MetadataFilters) => {
|
||||
console.log("\nQuerying dogs by filters: ", JSON.stringify(filters));
|
||||
const query = "List all colors of dogs";
|
||||
const queryEngine = index.asQueryEngine({
|
||||
preFilters: filters,
|
||||
similarityTopK: 3,
|
||||
});
|
||||
const response = await queryEngine.query({ query });
|
||||
console.log(response.toString());
|
||||
};
|
||||
|
||||
console.log("Querying index");
|
||||
const queryEngine = index.asQueryEngine({
|
||||
preFilters: {
|
||||
filters: [
|
||||
{
|
||||
key: "dogId",
|
||||
value: "2",
|
||||
operator: "==",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const response = await queryEngine.query({
|
||||
query: "What is the color of the dog?",
|
||||
});
|
||||
console.log(response.toString());
|
||||
await queryFn(); // red, brown, yellow
|
||||
await queryFn({ filters: [{ key: "dogId", value: "1", operator: "==" }] }); // brown
|
||||
await queryFn({ filters: [{ key: "dogId", value: "1", operator: "!=" }] }); // red, yellow
|
||||
await queryFn({
|
||||
filters: [
|
||||
{ key: "dogId", value: "1", operator: "==" },
|
||||
{ key: "dogId", value: "3", operator: "==" },
|
||||
],
|
||||
condition: "or",
|
||||
}); // brown, yellow
|
||||
await queryFn({
|
||||
filters: [{ key: "dogId", value: ["1", "2"], operator: "in" }],
|
||||
}); // red, brown
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
void main();
|
||||
async function generate() {
|
||||
const docs = [
|
||||
new Document({
|
||||
id_: "doc1",
|
||||
text: "The dog is brown",
|
||||
metadata: {
|
||||
dogId: "1",
|
||||
},
|
||||
}),
|
||||
new Document({
|
||||
id_: "doc2",
|
||||
text: "The dog is red",
|
||||
metadata: {
|
||||
dogId: "2",
|
||||
},
|
||||
}),
|
||||
new Document({
|
||||
id_: "doc3",
|
||||
text: "The dog is yellow",
|
||||
metadata: {
|
||||
dogId: "3",
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
console.log("Creating ChromaDB vector store");
|
||||
const chromaVS = new ChromaVectorStore({ collectionName });
|
||||
const ctx = await storageContextFromDefaults({ vectorStore: chromaVS });
|
||||
|
||||
console.log("Embedding documents and adding to index");
|
||||
await VectorStoreIndex.fromDocuments(docs, {
|
||||
storageContext: ctx,
|
||||
});
|
||||
}
|
||||
|
||||
(async () => {
|
||||
await generate();
|
||||
await main();
|
||||
})();
|
||||
|
||||
@@ -12,7 +12,8 @@ async function main() {
|
||||
});
|
||||
|
||||
const queryEngine = index.asQueryEngine({
|
||||
similarityTopK: 5,
|
||||
// retrieve the whole content of a file instead of just chunks of the file
|
||||
retrieval_mode: "files_via_content",
|
||||
});
|
||||
|
||||
const rl = readline.createInterface({ input, output });
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import {
|
||||
Document,
|
||||
MetadataFilters,
|
||||
Settings,
|
||||
SimpleDocumentStore,
|
||||
VectorStoreIndex,
|
||||
storageContextFromDefaults,
|
||||
} from "llamaindex";
|
||||
|
||||
async function getDataSource() {
|
||||
const docs = [
|
||||
new Document({ text: "The dog is brown", metadata: { dogId: "1" } }),
|
||||
new Document({ text: "The dog is yellow", metadata: { dogId: "2" } }),
|
||||
];
|
||||
const storageContext = await storageContextFromDefaults({
|
||||
persistDir: "./cache",
|
||||
});
|
||||
const numberOfDocs = Object.keys(
|
||||
(storageContext.docStore as SimpleDocumentStore).toDict(),
|
||||
).length;
|
||||
if (numberOfDocs === 0) {
|
||||
return await VectorStoreIndex.fromDocuments(docs, { storageContext });
|
||||
}
|
||||
return await VectorStoreIndex.init({
|
||||
storageContext,
|
||||
});
|
||||
}
|
||||
|
||||
Settings.callbackManager.on("retrieve-end", (event) => {
|
||||
const { nodes, query } = event.detail;
|
||||
console.log(`${query.query} - Number of retrieved nodes:`, nodes.length);
|
||||
});
|
||||
|
||||
async function main() {
|
||||
const index = await getDataSource();
|
||||
const filters: MetadataFilters = {
|
||||
filters: [{ key: "dogId", value: "2", operator: "==" }],
|
||||
};
|
||||
|
||||
const retriever = index.asRetriever({ similarityTopK: 3, filters });
|
||||
const queryEngine = index.asQueryEngine({
|
||||
similarityTopK: 3,
|
||||
preFilters: filters,
|
||||
});
|
||||
|
||||
console.log("Retriever and query engine should only retrieve 1 node:");
|
||||
await retriever.retrieve({ query: "Retriever: get dog" });
|
||||
await queryEngine.query({ query: "QueryEngine: get dog" });
|
||||
}
|
||||
|
||||
void main();
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@llamaindex/examples",
|
||||
"private": true,
|
||||
"version": "0.0.8",
|
||||
"version": "0.0.10",
|
||||
"dependencies": {
|
||||
"@aws-crypto/sha256-js": "^5.2.0",
|
||||
"@azure/identity": "^4.4.1",
|
||||
"@datastax/astra-db-ts": "^1.4.1",
|
||||
"@llamaindex/core": "^0.2.0",
|
||||
"@llamaindex/core": "^0.3.4",
|
||||
"@notionhq/client": "^2.2.15",
|
||||
"@pinecone-database/pinecone": "^3.0.2",
|
||||
"@vercel/postgres": "^0.10.0",
|
||||
@@ -15,7 +15,7 @@
|
||||
"commander": "^12.1.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"js-tiktoken": "^1.0.14",
|
||||
"llamaindex": "^0.6.0",
|
||||
"llamaindex": "^0.7.7",
|
||||
"mongodb": "^6.7.0",
|
||||
"pathe": "^1.1.2",
|
||||
"postgres": "^3.4.4"
|
||||
|
||||
@@ -39,6 +39,12 @@ async function main() {
|
||||
dogId: "2",
|
||||
},
|
||||
}),
|
||||
new Document({
|
||||
text: "The dog is black",
|
||||
metadata: {
|
||||
dogId: "3",
|
||||
},
|
||||
}),
|
||||
];
|
||||
console.log("Creating QdrantDB vector store");
|
||||
const qdrantVs = new QdrantVectorStore({ url: qdrantUrl, collectionName });
|
||||
@@ -73,6 +79,42 @@ async function main() {
|
||||
query: "What is the color of the dog?",
|
||||
});
|
||||
console.log("Filter with dogId 2 response:", response.toString());
|
||||
|
||||
console.log("Querying index with dogId !=2: Expected output: Not red");
|
||||
const queryEngineNotDogId2 = index.asQueryEngine({
|
||||
preFilters: {
|
||||
filters: [
|
||||
{
|
||||
key: "dogId",
|
||||
value: "2",
|
||||
operator: "!=",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const responseNotDogId2 = await queryEngineNotDogId2.query({
|
||||
query: "What is the color of the dog?",
|
||||
});
|
||||
console.log(responseNotDogId2.toString());
|
||||
|
||||
console.log(
|
||||
"Querying index with dogId 2 or 3: Expected output: Red, Black",
|
||||
);
|
||||
const queryEngineIn = index.asQueryEngine({
|
||||
preFilters: {
|
||||
filters: [
|
||||
{
|
||||
key: "dogId",
|
||||
value: ["2", "3"],
|
||||
operator: "in",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const responseIn = await queryEngineIn.query({
|
||||
query: "List all dogs",
|
||||
});
|
||||
console.log(responseIn.toString());
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import { Language, LlamaParseReader } from "llamaindex";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
type LlamaParseReaderParams = Partial<
|
||||
Omit<LlamaParseReader, "language" | "apiKey">
|
||||
> & {
|
||||
language?: Language | Language[] | undefined;
|
||||
apiKey?: string | undefined;
|
||||
};
|
||||
|
||||
async function main() {
|
||||
const filePath = "../data/pto_policy_employee.docx";
|
||||
if (!fs.existsSync(filePath)) {
|
||||
console.error(`File ${filePath} does not exist`);
|
||||
process.exit(1);
|
||||
} else {
|
||||
console.log(`File ${filePath} exists`);
|
||||
}
|
||||
|
||||
const params: LlamaParseReaderParams = {
|
||||
verbose: true,
|
||||
parsingInstruction:
|
||||
"Extract the text from the document a long with any images and tables. This is a document for a course and the contents of the images are important.",
|
||||
fastMode: false,
|
||||
gpt4oMode: true,
|
||||
useVendorMultimodalModel: true,
|
||||
vendorMultimodalModelName: "anthropic-sonnet-3.5",
|
||||
premiumMode: true,
|
||||
resultType: "markdown",
|
||||
apiKey: process.env.LLAMA_CLOUD_API_KEY,
|
||||
doNotCache: true,
|
||||
};
|
||||
|
||||
// set up the llamaparse reader
|
||||
const reader = new LlamaParseReader(params);
|
||||
|
||||
const buffer = fs.readFileSync(filePath);
|
||||
const documents = await reader.loadDataAsContent(
|
||||
new Uint8Array(buffer),
|
||||
path.basename(filePath),
|
||||
);
|
||||
|
||||
let allText = "";
|
||||
documents.forEach((doc) => {
|
||||
allText += doc.text;
|
||||
});
|
||||
|
||||
console.log(allText);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -25,12 +25,9 @@ async function main() {
|
||||
similarityCutoff: 0.7,
|
||||
});
|
||||
// TODO: cannot pass responseSynthesizer into retriever query engine
|
||||
const queryEngine = new RetrieverQueryEngine(
|
||||
retriever,
|
||||
undefined,
|
||||
undefined,
|
||||
[nodePostprocessor],
|
||||
);
|
||||
const queryEngine = new RetrieverQueryEngine(retriever, undefined, [
|
||||
nodePostprocessor,
|
||||
]);
|
||||
|
||||
const response = await queryEngine.query({
|
||||
query: "What did the author do growing up?",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
BaseVectorStore,
|
||||
getResponseSynthesizer,
|
||||
OpenAI,
|
||||
OpenAIEmbedding,
|
||||
@@ -6,7 +7,6 @@ import {
|
||||
Settings,
|
||||
TextNode,
|
||||
VectorIndexRetriever,
|
||||
VectorStore,
|
||||
VectorStoreIndex,
|
||||
VectorStoreQuery,
|
||||
VectorStoreQueryResult,
|
||||
@@ -24,7 +24,7 @@ Settings.llm = new OpenAI({
|
||||
* Please do not use this class in production; it's only for demonstration purposes.
|
||||
*/
|
||||
class PineconeVectorStore<T extends RecordMetadata = RecordMetadata>
|
||||
implements VectorStore
|
||||
implements BaseVectorStore
|
||||
{
|
||||
storesText = true;
|
||||
isEmbeddingQuery = false;
|
||||
@@ -165,9 +165,7 @@ async function main() {
|
||||
});
|
||||
|
||||
const responseSynthesizer = getResponseSynthesizer("tree_summarize");
|
||||
return new RetrieverQueryEngine(retriever, responseSynthesizer, {
|
||||
filter,
|
||||
});
|
||||
return new RetrieverQueryEngine(retriever, responseSynthesizer);
|
||||
};
|
||||
|
||||
// whatever is a key from your metadata
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"name": "@llamaindex/monorepo",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "turbo run build",
|
||||
"build:release": "turbo run build --filter=\"./packages/*\"",
|
||||
"build": "turbo run build --filter=\"./packages/*\"",
|
||||
"dev": "turbo run dev --filter=\"./packages/*\"",
|
||||
"format": "prettier --ignore-unknown --cache --check .",
|
||||
"format:write": "prettier --ignore-unknown --write .",
|
||||
@@ -13,10 +12,10 @@
|
||||
"test": "turbo run test",
|
||||
"type-check": "tsc -b --diagnostics",
|
||||
"circular-check": "madge --circular ./packages/**/**/dist/index.js",
|
||||
"release": "pnpm run build:release && changeset publish",
|
||||
"release-snapshot": "pnpm run build:release && changeset publish --tag snapshot",
|
||||
"new-version": "changeset version && pnpm format:write && pnpm run build:release",
|
||||
"new-snapshot": "pnpm run build:release && changeset version --snapshot"
|
||||
"release": "pnpm run build && changeset publish",
|
||||
"release-snapshot": "pnpm run build && changeset publish --tag snapshot",
|
||||
"new-version": "changeset version && pnpm format:write && pnpm run build",
|
||||
"new-snapshot": "pnpm run build && changeset version --snapshot"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@changesets/cli": "^2.27.5",
|
||||
@@ -39,9 +38,6 @@
|
||||
"overrides": {
|
||||
"trim": "1.0.1",
|
||||
"protobufjs": "7.2.6"
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"python-format-js@1.4.3": "patches/python-format-js@1.4.3.patch"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
|
||||
@@ -1,5 +1,145 @@
|
||||
# @llamaindex/autotool
|
||||
|
||||
## 4.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
|
||||
## 4.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.8
|
||||
|
||||
## 4.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.7
|
||||
|
||||
## 4.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [534d550]
|
||||
- llamaindex@0.7.6
|
||||
|
||||
## 4.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e9a111d]
|
||||
- Updated dependencies [9f22aae]
|
||||
- llamaindex@0.7.5
|
||||
|
||||
## 4.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.4
|
||||
|
||||
## 4.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.3
|
||||
|
||||
## 4.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.2
|
||||
|
||||
## 4.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a75af83: refactor: move some llm and embedding to single package
|
||||
- Updated dependencies [ae49ff4]
|
||||
- Updated dependencies [4c38c1b]
|
||||
- Updated dependencies [a75af83]
|
||||
- Updated dependencies [a75af83]
|
||||
- llamaindex@0.7.1
|
||||
|
||||
## 4.0.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [1364e8e]
|
||||
- Updated dependencies [3b7736f]
|
||||
- Updated dependencies [96fc69c]
|
||||
- llamaindex@0.7.0
|
||||
|
||||
## 3.0.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5729bd9]
|
||||
- llamaindex@0.6.22
|
||||
|
||||
## 3.0.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6f75306]
|
||||
- Updated dependencies [94cb4ad]
|
||||
- llamaindex@0.6.21
|
||||
|
||||
## 3.0.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6a9a7b1]
|
||||
- llamaindex@0.6.20
|
||||
|
||||
## 3.0.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [62cba52]
|
||||
- Updated dependencies [d265e96]
|
||||
- Updated dependencies [d30bbf7]
|
||||
- Updated dependencies [53fd00a]
|
||||
- llamaindex@0.6.19
|
||||
|
||||
## 3.0.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5f67820]
|
||||
- Updated dependencies [fe08d04]
|
||||
- llamaindex@0.6.18
|
||||
|
||||
## 3.0.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ee697fb]
|
||||
- llamaindex@0.6.17
|
||||
|
||||
## 3.0.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [63e9846]
|
||||
- Updated dependencies [6f3a31c]
|
||||
- llamaindex@0.6.16
|
||||
|
||||
## 3.0.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2a82413]
|
||||
- llamaindex@0.6.15
|
||||
|
||||
## 3.0.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.6.14
|
||||
|
||||
## 3.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,5 +1,163 @@
|
||||
# @llamaindex/autotool-01-node-example
|
||||
|
||||
## 0.0.41
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
- @llamaindex/autotool@4.0.9
|
||||
|
||||
## 0.0.40
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.8
|
||||
- @llamaindex/autotool@4.0.8
|
||||
|
||||
## 0.0.39
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.7
|
||||
- @llamaindex/autotool@4.0.7
|
||||
|
||||
## 0.0.38
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [534d550]
|
||||
- llamaindex@0.7.6
|
||||
- @llamaindex/autotool@4.0.6
|
||||
|
||||
## 0.0.37
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e9a111d]
|
||||
- Updated dependencies [9f22aae]
|
||||
- llamaindex@0.7.5
|
||||
- @llamaindex/autotool@4.0.5
|
||||
|
||||
## 0.0.36
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.4
|
||||
- @llamaindex/autotool@4.0.4
|
||||
|
||||
## 0.0.35
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.3
|
||||
- @llamaindex/autotool@4.0.3
|
||||
|
||||
## 0.0.34
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.2
|
||||
- @llamaindex/autotool@4.0.2
|
||||
|
||||
## 0.0.33
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ae49ff4]
|
||||
- Updated dependencies [4c38c1b]
|
||||
- Updated dependencies [a75af83]
|
||||
- Updated dependencies [a75af83]
|
||||
- llamaindex@0.7.1
|
||||
- @llamaindex/autotool@4.0.1
|
||||
|
||||
## 0.0.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [1364e8e]
|
||||
- Updated dependencies [3b7736f]
|
||||
- Updated dependencies [96fc69c]
|
||||
- llamaindex@0.7.0
|
||||
- @llamaindex/autotool@4.0.0
|
||||
|
||||
## 0.0.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5729bd9]
|
||||
- llamaindex@0.6.22
|
||||
- @llamaindex/autotool@3.0.22
|
||||
|
||||
## 0.0.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6f75306]
|
||||
- Updated dependencies [94cb4ad]
|
||||
- llamaindex@0.6.21
|
||||
- @llamaindex/autotool@3.0.21
|
||||
|
||||
## 0.0.29
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6a9a7b1]
|
||||
- llamaindex@0.6.20
|
||||
- @llamaindex/autotool@3.0.20
|
||||
|
||||
## 0.0.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [62cba52]
|
||||
- Updated dependencies [d265e96]
|
||||
- Updated dependencies [d30bbf7]
|
||||
- Updated dependencies [53fd00a]
|
||||
- llamaindex@0.6.19
|
||||
- @llamaindex/autotool@3.0.19
|
||||
|
||||
## 0.0.27
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5f67820]
|
||||
- Updated dependencies [fe08d04]
|
||||
- llamaindex@0.6.18
|
||||
- @llamaindex/autotool@3.0.18
|
||||
|
||||
## 0.0.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ee697fb]
|
||||
- llamaindex@0.6.17
|
||||
- @llamaindex/autotool@3.0.17
|
||||
|
||||
## 0.0.25
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [63e9846]
|
||||
- Updated dependencies [6f3a31c]
|
||||
- llamaindex@0.6.16
|
||||
- @llamaindex/autotool@3.0.16
|
||||
|
||||
## 0.0.24
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2a82413]
|
||||
- llamaindex@0.6.15
|
||||
- @llamaindex/autotool@3.0.15
|
||||
|
||||
## 0.0.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.6.14
|
||||
- @llamaindex/autotool@3.0.14
|
||||
|
||||
## 0.0.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
"scripts": {
|
||||
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
|
||||
},
|
||||
"version": "0.0.22"
|
||||
"version": "0.0.41"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,163 @@
|
||||
# @llamaindex/autotool-02-next-example
|
||||
|
||||
## 0.1.85
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
- @llamaindex/autotool@4.0.9
|
||||
|
||||
## 0.1.84
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.8
|
||||
- @llamaindex/autotool@4.0.8
|
||||
|
||||
## 0.1.83
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.7
|
||||
- @llamaindex/autotool@4.0.7
|
||||
|
||||
## 0.1.82
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [534d550]
|
||||
- llamaindex@0.7.6
|
||||
- @llamaindex/autotool@4.0.6
|
||||
|
||||
## 0.1.81
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e9a111d]
|
||||
- Updated dependencies [9f22aae]
|
||||
- llamaindex@0.7.5
|
||||
- @llamaindex/autotool@4.0.5
|
||||
|
||||
## 0.1.80
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.4
|
||||
- @llamaindex/autotool@4.0.4
|
||||
|
||||
## 0.1.79
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.3
|
||||
- @llamaindex/autotool@4.0.3
|
||||
|
||||
## 0.1.78
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.7.2
|
||||
- @llamaindex/autotool@4.0.2
|
||||
|
||||
## 0.1.77
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ae49ff4]
|
||||
- Updated dependencies [4c38c1b]
|
||||
- Updated dependencies [a75af83]
|
||||
- Updated dependencies [a75af83]
|
||||
- llamaindex@0.7.1
|
||||
- @llamaindex/autotool@4.0.1
|
||||
|
||||
## 0.1.76
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [1364e8e]
|
||||
- Updated dependencies [3b7736f]
|
||||
- Updated dependencies [96fc69c]
|
||||
- llamaindex@0.7.0
|
||||
- @llamaindex/autotool@4.0.0
|
||||
|
||||
## 0.1.75
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5729bd9]
|
||||
- llamaindex@0.6.22
|
||||
- @llamaindex/autotool@3.0.22
|
||||
|
||||
## 0.1.74
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6f75306]
|
||||
- Updated dependencies [94cb4ad]
|
||||
- llamaindex@0.6.21
|
||||
- @llamaindex/autotool@3.0.21
|
||||
|
||||
## 0.1.73
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6a9a7b1]
|
||||
- llamaindex@0.6.20
|
||||
- @llamaindex/autotool@3.0.20
|
||||
|
||||
## 0.1.72
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [62cba52]
|
||||
- Updated dependencies [d265e96]
|
||||
- Updated dependencies [d30bbf7]
|
||||
- Updated dependencies [53fd00a]
|
||||
- llamaindex@0.6.19
|
||||
- @llamaindex/autotool@3.0.19
|
||||
|
||||
## 0.1.71
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5f67820]
|
||||
- Updated dependencies [fe08d04]
|
||||
- llamaindex@0.6.18
|
||||
- @llamaindex/autotool@3.0.18
|
||||
|
||||
## 0.1.70
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ee697fb]
|
||||
- llamaindex@0.6.17
|
||||
- @llamaindex/autotool@3.0.17
|
||||
|
||||
## 0.1.69
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [63e9846]
|
||||
- Updated dependencies [6f3a31c]
|
||||
- llamaindex@0.6.16
|
||||
- @llamaindex/autotool@3.0.16
|
||||
|
||||
## 0.1.68
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2a82413]
|
||||
- llamaindex@0.6.15
|
||||
- @llamaindex/autotool@3.0.15
|
||||
|
||||
## 0.1.67
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.6.14
|
||||
- @llamaindex/autotool@3.0.14
|
||||
|
||||
## 0.1.66
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/autotool-02-next-example",
|
||||
"private": true,
|
||||
"version": "0.1.66",
|
||||
"version": "0.1.85",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
@@ -25,8 +25,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.5.1",
|
||||
"@types/react": "^18.3.5",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@types/react-syntax-highlighter": "^15.5.11",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"cross-env": "^7.0.3",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/autotool",
|
||||
"type": "module",
|
||||
"version": "3.0.13",
|
||||
"version": "4.0.9",
|
||||
"description": "auto transpile your JS function to LLM Agent compatible",
|
||||
"files": [
|
||||
"dist",
|
||||
@@ -70,7 +70,7 @@
|
||||
"@swc/types": "^0.1.12",
|
||||
"@types/json-schema": "^7.0.15",
|
||||
"@types/node": "^22.5.1",
|
||||
"bunchee": "5.3.2",
|
||||
"bunchee": "5.5.1",
|
||||
"llamaindex": "workspace:*",
|
||||
"next": "14.2.11",
|
||||
"rollup": "^4.21.2",
|
||||
|
||||
@@ -1,5 +1,96 @@
|
||||
# @llamaindex/cloud
|
||||
|
||||
## 1.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
|
||||
## 1.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fa60fc6]
|
||||
- @llamaindex/env@0.1.16
|
||||
- @llamaindex/core@0.3.5
|
||||
|
||||
## 1.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e2a0876]
|
||||
- @llamaindex/core@0.3.4
|
||||
|
||||
## 1.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 06f632b: fix(cloud): allow filename in llama parse
|
||||
|
||||
## 1.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0493f67]
|
||||
- @llamaindex/core@0.3.3
|
||||
|
||||
## 1.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4ba2cfe]
|
||||
- @llamaindex/env@0.1.15
|
||||
- @llamaindex/core@0.3.2
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4c38c1b: fix(cloud): do not detect file type in llama parse
|
||||
- 24d065f: Log Parse Job Errors when verbose is enabled
|
||||
- a75af83: refactor: move some llm and embedding to single package
|
||||
- Updated dependencies [ae49ff4]
|
||||
- Updated dependencies [a75af83]
|
||||
- @llamaindex/env@0.1.14
|
||||
- @llamaindex/core@0.3.1
|
||||
|
||||
## 1.0.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [1364e8e]
|
||||
- Updated dependencies [96fc69c]
|
||||
- @llamaindex/core@0.3.0
|
||||
|
||||
## 0.2.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5f67820]
|
||||
- @llamaindex/core@0.2.12
|
||||
|
||||
## 0.2.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ee697fb]
|
||||
- @llamaindex/core@0.2.11
|
||||
|
||||
## 0.2.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3489e7d]
|
||||
- Updated dependencies [468bda5]
|
||||
- @llamaindex/core@0.2.10
|
||||
|
||||
## 0.2.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0b20ff9: fix: package.json format
|
||||
|
||||
## 0.2.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "@llamaindex/cloud",
|
||||
"version": "0.2.10",
|
||||
"version": "1.0.7",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"generate": "pnpx @hey-api/openapi-ts@0.53.0",
|
||||
"build": "pnpm run generate && bunchee"
|
||||
"generate": "pnpx @hey-api/openapi-ts@0.53.11",
|
||||
"build": "pnpm run generate && bunchee",
|
||||
"dev": "bunchee --watch"
|
||||
},
|
||||
"files": [
|
||||
"openapi.json",
|
||||
@@ -49,17 +50,14 @@
|
||||
"directory": "packages/cloud"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@hey-api/client-fetch": "^0.2.4",
|
||||
"@hey-api/openapi-ts": "^0.53.0",
|
||||
"@llamaindex/core": "workspace:^0.2.8",
|
||||
"@llamaindex/env": "workspace:^0.1.13",
|
||||
"bunchee": "5.3.2"
|
||||
"@hey-api/client-fetch": "^0.4.2",
|
||||
"@hey-api/openapi-ts": "^0.53.11",
|
||||
"@llamaindex/core": "workspace:*",
|
||||
"@llamaindex/env": "workspace:*",
|
||||
"bunchee": "5.5.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@llamaindex/core": "workspace:^0.2.8",
|
||||
"@llamaindex/env": "workspace:^0.1.13"
|
||||
},
|
||||
"dependencies": {
|
||||
"magic-bytes.js": "^1.10.0"
|
||||
"@llamaindex/core": "workspace:*",
|
||||
"@llamaindex/env": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { type Client, createClient, createConfig } from "@hey-api/client-fetch";
|
||||
import { Document, FileReader } from "@llamaindex/core/schema";
|
||||
import { fs, getEnv, path } from "@llamaindex/env";
|
||||
import { filetypeinfo } from "magic-bytes.js";
|
||||
import {
|
||||
type Body_upload_file_api_v1_parsing_upload_post,
|
||||
type ParserLanguages,
|
||||
@@ -13,99 +12,6 @@ export type Language = ParserLanguages;
|
||||
|
||||
export type ResultType = "text" | "markdown" | "json";
|
||||
|
||||
const SUPPORT_FILE_EXT: string[] = [
|
||||
".pdf",
|
||||
// document and presentations
|
||||
".602",
|
||||
".abw",
|
||||
".cgm",
|
||||
".cwk",
|
||||
".doc",
|
||||
".docx",
|
||||
".docm",
|
||||
".dot",
|
||||
".dotm",
|
||||
".hwp",
|
||||
".key",
|
||||
".lwp",
|
||||
".mw",
|
||||
".mcw",
|
||||
".pages",
|
||||
".pbd",
|
||||
".ppt",
|
||||
".pptm",
|
||||
".pptx",
|
||||
".pot",
|
||||
".potm",
|
||||
".potx",
|
||||
".rtf",
|
||||
".sda",
|
||||
".sdd",
|
||||
".sdp",
|
||||
".sdw",
|
||||
".sgl",
|
||||
".sti",
|
||||
".sxi",
|
||||
".sxw",
|
||||
".stw",
|
||||
".sxg",
|
||||
".txt",
|
||||
".uof",
|
||||
".uop",
|
||||
".uot",
|
||||
".vor",
|
||||
".wpd",
|
||||
".wps",
|
||||
".xml",
|
||||
".zabw",
|
||||
".epub",
|
||||
// images
|
||||
".jpg",
|
||||
".jpeg",
|
||||
".png",
|
||||
".gif",
|
||||
".bmp",
|
||||
".svg",
|
||||
".tiff",
|
||||
".webp",
|
||||
// web
|
||||
".htm",
|
||||
".html",
|
||||
// spreadsheets
|
||||
".xlsx",
|
||||
".xls",
|
||||
".xlsm",
|
||||
".xlsb",
|
||||
".xlw",
|
||||
".csv",
|
||||
".dif",
|
||||
".sylk",
|
||||
".slk",
|
||||
".prn",
|
||||
".numbers",
|
||||
".et",
|
||||
".ods",
|
||||
".fods",
|
||||
".uos1",
|
||||
".uos2",
|
||||
".dbf",
|
||||
".wk1",
|
||||
".wk2",
|
||||
".wk3",
|
||||
".wk4",
|
||||
".wks",
|
||||
".123",
|
||||
".wq1",
|
||||
".wq2",
|
||||
".wb1",
|
||||
".wb2",
|
||||
".wb3",
|
||||
".qpw",
|
||||
".xlr",
|
||||
".eth",
|
||||
".tsv",
|
||||
];
|
||||
|
||||
//todo: should move into @llamaindex/env
|
||||
type WriteStream = {
|
||||
write: (text: string) => void;
|
||||
@@ -178,6 +84,13 @@ export class LlamaParseReader extends FileReader {
|
||||
disableReconstruction?: boolean | undefined;
|
||||
inputS3Path?: string | undefined;
|
||||
outputS3PathPrefix?: string | undefined;
|
||||
continuousMode?: boolean | undefined;
|
||||
isFormattingInstruction?: boolean | undefined;
|
||||
annotateLinks?: boolean | undefined;
|
||||
azureOpenaiDeploymentName?: string | undefined;
|
||||
azureOpenaiEndpoint?: string | undefined;
|
||||
azureOpenaiApiVersion?: string | undefined;
|
||||
azureOpenaiKey?: string | undefined;
|
||||
|
||||
// numWorkers is implemented in SimpleDirectoryReader
|
||||
stdout?: WriteStream | undefined;
|
||||
@@ -238,18 +151,19 @@ export class LlamaParseReader extends FileReader {
|
||||
}
|
||||
|
||||
// Create a job for the LlamaParse API
|
||||
private async createJob(data: Uint8Array): Promise<string> {
|
||||
// Load data, set the mime type
|
||||
const { mime } = await LlamaParseReader.getMimeType(data);
|
||||
|
||||
async #createJob(data: Uint8Array, filename?: string): Promise<string> {
|
||||
if (this.verbose) {
|
||||
console.log("Started uploading the file");
|
||||
}
|
||||
|
||||
// todo: remove Blob usage when we drop Node.js 18 support
|
||||
const file: File | Blob =
|
||||
globalThis.File && filename
|
||||
? new File([data], filename)
|
||||
: new Blob([data]);
|
||||
|
||||
const body = {
|
||||
file: new Blob([data], {
|
||||
type: mime,
|
||||
}),
|
||||
file,
|
||||
language: this.language,
|
||||
parsing_instruction: this.parsingInstruction,
|
||||
skip_diagonal_text: this.skipDiagonalText,
|
||||
@@ -274,6 +188,13 @@ export class LlamaParseReader extends FileReader {
|
||||
disable_reconstruction: this.disableReconstruction,
|
||||
input_s3_path: this.inputS3Path,
|
||||
output_s3_path_prefix: this.outputS3PathPrefix,
|
||||
continuous_mode: this.continuousMode,
|
||||
is_formatting_instruction: this.isFormattingInstruction,
|
||||
annotate_links: this.annotateLinks,
|
||||
azure_openai_deployment_name: this.azureOpenaiDeploymentName,
|
||||
azure_openai_endpoint: this.azureOpenaiEndpoint,
|
||||
azure_openai_api_version: this.azureOpenaiApiVersion,
|
||||
azure_openai_key: this.azureOpenaiKey,
|
||||
} satisfies {
|
||||
[Key in keyof Body_upload_file_api_v1_parsing_upload_post]-?:
|
||||
| Body_upload_file_api_v1_parsing_upload_post[Key]
|
||||
@@ -368,6 +289,11 @@ export class LlamaParseReader extends FileReader {
|
||||
}
|
||||
tries++;
|
||||
} else {
|
||||
if (this.verbose) {
|
||||
console.error(
|
||||
`Recieved Error response ${status} for job ${jobId}. Got Error Code: ${data.error_code} and Error Message: ${data.error_message}`,
|
||||
);
|
||||
}
|
||||
throw new Error(
|
||||
`Failed to parse the file: ${jobId}, status: ${status}`,
|
||||
);
|
||||
@@ -380,10 +306,14 @@ export class LlamaParseReader extends FileReader {
|
||||
* To be used with resultType = "text" and "markdown"
|
||||
*
|
||||
* @param {Uint8Array} fileContent - The content of the file to be loaded.
|
||||
* @param {string} filename - The name of the file to be loaded.
|
||||
* @return {Promise<Document[]>} A Promise object that resolves to an array of Document objects.
|
||||
*/
|
||||
async loadDataAsContent(fileContent: Uint8Array): Promise<Document[]> {
|
||||
return this.createJob(fileContent)
|
||||
async loadDataAsContent(
|
||||
fileContent: Uint8Array,
|
||||
filename?: string,
|
||||
): Promise<Document[]> {
|
||||
return this.#createJob(fileContent, filename)
|
||||
.then(async (jobId) => {
|
||||
if (this.verbose) {
|
||||
console.log(`Started parsing the file under job id ${jobId}`);
|
||||
@@ -406,7 +336,9 @@ export class LlamaParseReader extends FileReader {
|
||||
})
|
||||
.catch((error) => {
|
||||
if (this.ignoreErrors) {
|
||||
console.warn(`Error while parsing the file: ${error.message}`);
|
||||
console.warn(
|
||||
`Error while parsing the file: ${error.message ?? error.detail}`,
|
||||
);
|
||||
return [];
|
||||
} else {
|
||||
throw error;
|
||||
@@ -430,7 +362,10 @@ export class LlamaParseReader extends FileReader {
|
||||
? await fs.readFile(filePathOrContent)
|
||||
: filePathOrContent;
|
||||
// Creates a job for the file
|
||||
jobId = await this.createJob(data);
|
||||
jobId = await this.#createJob(
|
||||
data,
|
||||
isFilePath ? path.basename(filePathOrContent) : undefined,
|
||||
);
|
||||
if (this.verbose) {
|
||||
console.log(`Started parsing the file under job id ${jobId}`);
|
||||
}
|
||||
@@ -564,24 +499,4 @@ export class LlamaParseReader extends FileReader {
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
static async getMimeType(
|
||||
data: Uint8Array,
|
||||
): Promise<{ mime: string; extension: string }> {
|
||||
const typeinfos = filetypeinfo(data);
|
||||
// find the first type info that matches the supported MIME types
|
||||
// It could be happened that docx file is recognized as zip file, so we need to check the mime type
|
||||
const info = typeinfos.find((info) => {
|
||||
if (info.extension && SUPPORT_FILE_EXT.includes(`.${info.extension}`)) {
|
||||
return info;
|
||||
}
|
||||
});
|
||||
if (!info || !info.mime || !info.extension) {
|
||||
const ext = SUPPORT_FILE_EXT.join(", ");
|
||||
throw new Error(
|
||||
`File has type which does not match supported MIME Types. Supported formats include: ${ext}`,
|
||||
);
|
||||
}
|
||||
return { mime: info.mime, extension: info.extension };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,95 @@
|
||||
# @llamaindex/community
|
||||
|
||||
## 0.0.55
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
|
||||
## 0.0.54
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fa60fc6]
|
||||
- @llamaindex/env@0.1.16
|
||||
- @llamaindex/core@0.3.5
|
||||
|
||||
## 0.0.53
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e2a0876]
|
||||
- @llamaindex/core@0.3.4
|
||||
|
||||
## 0.0.52
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a5a75f6: feat: added sonnet 3.5 v2
|
||||
|
||||
## 0.0.51
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0493f67]
|
||||
- @llamaindex/core@0.3.3
|
||||
|
||||
## 0.0.50
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4ba2cfe]
|
||||
- @llamaindex/env@0.1.15
|
||||
- @llamaindex/core@0.3.2
|
||||
|
||||
## 0.0.49
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a75af83: refactor: move some llm and embedding to single package
|
||||
- Updated dependencies [ae49ff4]
|
||||
- Updated dependencies [a75af83]
|
||||
- @llamaindex/env@0.1.14
|
||||
- @llamaindex/core@0.3.1
|
||||
|
||||
## 0.0.48
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [1364e8e]
|
||||
- Updated dependencies [96fc69c]
|
||||
- @llamaindex/core@0.3.0
|
||||
|
||||
## 0.0.47
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5f67820]
|
||||
- @llamaindex/core@0.2.12
|
||||
|
||||
## 0.0.46
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ee697fb]
|
||||
- @llamaindex/core@0.2.11
|
||||
|
||||
## 0.0.45
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3489e7d]
|
||||
- Updated dependencies [468bda5]
|
||||
- @llamaindex/core@0.2.10
|
||||
|
||||
## 0.0.44
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b17d439]
|
||||
- @llamaindex/core@0.2.9
|
||||
|
||||
## 0.0.43
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Current Features:
|
||||
|
||||
- Bedrock support for the Anthropic Claude Models [usage](https://ts.llamaindex.ai/modules/llms/available_llms/bedrock)
|
||||
- Bedrock support for the Anthropic Claude Models [usage](https://ts.llamaindex.ai/modules/llms/available_llms/bedrock) including the latest Sonnet 3.5 v2
|
||||
- Bedrock support for the Meta LLama 2, 3, 3.1 and 3.2 Models [usage](https://ts.llamaindex.ai/modules/llms/available_llms/bedrock)
|
||||
- Meta LLama3.1 405b and Llama3.2 tool call support
|
||||
- Meta 3.2 11B and 90B vision support
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/community",
|
||||
"description": "Community package for LlamaIndexTS",
|
||||
"version": "0.0.43",
|
||||
"version": "0.0.55",
|
||||
"type": "module",
|
||||
"types": "dist/type/index.d.ts",
|
||||
"main": "dist/cjs/index.js",
|
||||
@@ -43,11 +43,11 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.5.1",
|
||||
"bunchee": "5.3.2"
|
||||
"bunchee": "5.5.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-bedrock-runtime": "^3.642.0",
|
||||
"@aws-sdk/client-bedrock-agent-runtime": "^3.642.0",
|
||||
"@aws-sdk/client-bedrock-runtime": "^3.642.0",
|
||||
"@llamaindex/core": "workspace:*",
|
||||
"@llamaindex/env": "workspace:*"
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ export const BEDROCK_MODELS = {
|
||||
ANTHROPIC_CLAUDE_3_HAIKU: "anthropic.claude-3-haiku-20240307-v1:0",
|
||||
ANTHROPIC_CLAUDE_3_OPUS: "anthropic.claude-3-opus-20240229-v1:0",
|
||||
ANTHROPIC_CLAUDE_3_5_SONNET: "anthropic.claude-3-5-sonnet-20240620-v1:0",
|
||||
ANTHROPIC_CLAUDE_3_5_SONNET_V2: "anthropic.claude-3-5-sonnet-20241022-v2:0",
|
||||
META_LLAMA2_13B_CHAT: "meta.llama2-13b-chat-v1",
|
||||
META_LLAMA2_70B_CHAT: "meta.llama2-70b-chat-v1",
|
||||
META_LLAMA3_8B_INSTRUCT: "meta.llama3-8b-instruct-v1:0",
|
||||
@@ -89,6 +90,8 @@ export const INFERENCE_BEDROCK_MODELS = {
|
||||
US_ANTHROPIC_CLAUDE_3_SONNET: "us.anthropic.claude-3-sonnet-20240229-v1:0",
|
||||
US_ANTHROPIC_CLAUDE_3_5_SONNET:
|
||||
"us.anthropic.claude-3-5-sonnet-20240620-v1:0",
|
||||
US_ANTHROPIC_CLAUDE_3_5_SONNET_V2:
|
||||
"us.anthropic.claude-3-5-sonnet-20241022-v2:0",
|
||||
US_META_LLAMA_3_2_1B_INSTRUCT: "us.meta.llama3-2-1b-instruct-v1:0",
|
||||
US_META_LLAMA_3_2_3B_INSTRUCT: "us.meta.llama3-2-3b-instruct-v1:0",
|
||||
US_META_LLAMA_3_2_11B_INSTRUCT: "us.meta.llama3-2-11b-instruct-v1:0",
|
||||
@@ -117,6 +120,8 @@ export const INFERENCE_TO_BEDROCK_MAP: Record<
|
||||
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_SONNET,
|
||||
[INFERENCE_BEDROCK_MODELS.US_ANTHROPIC_CLAUDE_3_5_SONNET]:
|
||||
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET,
|
||||
[INFERENCE_BEDROCK_MODELS.US_ANTHROPIC_CLAUDE_3_5_SONNET_V2]:
|
||||
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET_V2,
|
||||
[INFERENCE_BEDROCK_MODELS.US_META_LLAMA_3_2_1B_INSTRUCT]:
|
||||
BEDROCK_MODELS.META_LLAMA3_2_1B_INSTRUCT,
|
||||
[INFERENCE_BEDROCK_MODELS.US_META_LLAMA_3_2_3B_INSTRUCT]:
|
||||
@@ -163,6 +168,7 @@ const CHAT_ONLY_MODELS = {
|
||||
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU]: 200000,
|
||||
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_OPUS]: 200000,
|
||||
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET]: 200000,
|
||||
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET_V2]: 200000,
|
||||
[BEDROCK_MODELS.META_LLAMA2_13B_CHAT]: 2048,
|
||||
[BEDROCK_MODELS.META_LLAMA2_70B_CHAT]: 4096,
|
||||
[BEDROCK_MODELS.META_LLAMA3_8B_INSTRUCT]: 8192,
|
||||
@@ -197,6 +203,7 @@ export const STREAMING_MODELS = new Set([
|
||||
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU,
|
||||
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_OPUS,
|
||||
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET,
|
||||
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET_V2,
|
||||
BEDROCK_MODELS.META_LLAMA2_13B_CHAT,
|
||||
BEDROCK_MODELS.META_LLAMA2_70B_CHAT,
|
||||
BEDROCK_MODELS.META_LLAMA3_8B_INSTRUCT,
|
||||
@@ -218,6 +225,7 @@ export const TOOL_CALL_MODELS: BEDROCK_MODELS[] = [
|
||||
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU,
|
||||
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_OPUS,
|
||||
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET,
|
||||
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET_V2,
|
||||
BEDROCK_MODELS.META_LLAMA3_1_405B_INSTRUCT,
|
||||
BEDROCK_MODELS.META_LLAMA3_2_1B_INSTRUCT,
|
||||
BEDROCK_MODELS.META_LLAMA3_2_3B_INSTRUCT,
|
||||
@@ -251,6 +259,7 @@ export const BEDROCK_MODEL_MAX_TOKENS: Partial<Record<BEDROCK_MODELS, number>> =
|
||||
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU]: 4096,
|
||||
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_OPUS]: 4096,
|
||||
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET]: 4096,
|
||||
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET_V2]: 4096,
|
||||
[BEDROCK_MODELS.META_LLAMA2_13B_CHAT]: 2048,
|
||||
[BEDROCK_MODELS.META_LLAMA2_70B_CHAT]: 2048,
|
||||
[BEDROCK_MODELS.META_LLAMA3_8B_INSTRUCT]: 2048,
|
||||
|
||||
@@ -1,5 +1,78 @@
|
||||
# @llamaindex/core
|
||||
|
||||
## 0.3.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 691c5bc: fix: export embeddings utils
|
||||
|
||||
## 0.3.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fa60fc6]
|
||||
- @llamaindex/env@0.1.16
|
||||
|
||||
## 0.3.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- e2a0876: Remove chunk size limit for prompt helper (use LLM default)
|
||||
|
||||
## 0.3.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0493f67: fix(core): inline `python-format-js`
|
||||
|
||||
## 0.3.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4ba2cfe]
|
||||
- @llamaindex/env@0.1.15
|
||||
|
||||
## 0.3.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a75af83: refactor: move some llm and embedding to single package
|
||||
- Updated dependencies [ae49ff4]
|
||||
- Updated dependencies [a75af83]
|
||||
- @llamaindex/env@0.1.14
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 1364e8e: update metadata extractors to use PromptTemplate
|
||||
- 96fc69c: add defaultQuestionExtractPrompt
|
||||
|
||||
## 0.2.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 5f67820: Fix that node parsers generate nodes with UUIDs
|
||||
|
||||
## 0.2.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ee697fb: fix: generate uuid when inserting to Qdrant
|
||||
|
||||
## 0.2.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3489e7d: fix: num output incorrect in prompt helper
|
||||
- 468bda5: fix: correct warning when chunk size smaller than 0
|
||||
|
||||
## 0.2.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b17d439: Fix #1278: resolved issue where the id\_ was not correctly passed as the id when creating a TextNode. As a result, the upsert operation to the vector database was using a generated ID instead of the provided document ID, if available.
|
||||
|
||||
## 0.2.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": "./dist/index.js",
|
||||
"private": true
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/core",
|
||||
"type": "module",
|
||||
"version": "0.2.8",
|
||||
"version": "0.3.6",
|
||||
"description": "LlamaIndex Core Module",
|
||||
"exports": {
|
||||
"./agent": {
|
||||
@@ -258,16 +258,44 @@
|
||||
},
|
||||
"./vector-store": {
|
||||
"require": {
|
||||
"types": "./dist/vector-store/index.d.cts",
|
||||
"default": "./dist/vector-store/index.cjs"
|
||||
"types": "./vector-store/dist/index.d.cts",
|
||||
"default": "./vector-store/dist/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/vector-store/index.d.ts",
|
||||
"default": "./dist/vector-store/index.js"
|
||||
"types": "./vector-store/dist/index.d.ts",
|
||||
"default": "./vector-store/dist/index.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./dist/vector-store/index.d.ts",
|
||||
"default": "./dist/vector-store/index.js"
|
||||
"types": "./vector-store/dist/index.d.ts",
|
||||
"default": "./vector-store/dist/index.js"
|
||||
}
|
||||
},
|
||||
"./tools": {
|
||||
"require": {
|
||||
"types": "./tools/dist/index.d.cts",
|
||||
"default": "./tools/dist/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./tools/dist/index.d.ts",
|
||||
"default": "./tools/dist/index.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./tools/dist/index.d.ts",
|
||||
"default": "./tools/dist/index.js"
|
||||
}
|
||||
},
|
||||
"./data-structs": {
|
||||
"require": {
|
||||
"types": "./data-structs/dist/index.d.cts",
|
||||
"default": "./data-structs/dist/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./data-structs/dist/index.d.ts",
|
||||
"default": "./data-structs/dist/index.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./data-structs/dist/index.d.ts",
|
||||
"default": "./data-structs/dist/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -289,7 +317,10 @@
|
||||
"./storage",
|
||||
"./response-synthesizers",
|
||||
"./chat-engine",
|
||||
"./retriever"
|
||||
"./retriever",
|
||||
"./vector-store",
|
||||
"./tools",
|
||||
"./data-structs"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "bunchee --watch",
|
||||
@@ -303,15 +334,15 @@
|
||||
"devDependencies": {
|
||||
"@edge-runtime/vm": "^4.0.3",
|
||||
"ajv": "^8.17.1",
|
||||
"bunchee": "5.3.2",
|
||||
"bunchee": "5.5.1",
|
||||
"happy-dom": "^15.7.4",
|
||||
"natural": "^8.0.1",
|
||||
"python-format-js": "^1.4.3"
|
||||
"natural": "^8.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@llamaindex/env": "workspace:*",
|
||||
"@types/node": "^22.5.1",
|
||||
"magic-bytes.js": "^1.10.0",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.23.8",
|
||||
"zod-to-json-schema": "^3.23.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { randomUUID } from "@llamaindex/env";
|
||||
import type { UUID } from "../global";
|
||||
import { IndexStructType } from "./struct-type";
|
||||
|
||||
export abstract class IndexStruct {
|
||||
indexId: string;
|
||||
summary: string | undefined;
|
||||
|
||||
constructor(
|
||||
indexId: UUID = randomUUID(),
|
||||
summary: string | undefined = undefined,
|
||||
) {
|
||||
this.indexId = indexId;
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
toJson(): Record<string, unknown> {
|
||||
return {
|
||||
indexId: this.indexId,
|
||||
summary: this.summary,
|
||||
};
|
||||
}
|
||||
|
||||
getSummary(): string {
|
||||
if (this.summary === undefined) {
|
||||
throw new Error("summary field of the index struct is not set");
|
||||
}
|
||||
return this.summary;
|
||||
}
|
||||
}
|
||||
|
||||
// A table of keywords mapping keywords to text chunks.
|
||||
export class KeywordTable extends IndexStruct {
|
||||
table: Map<string, Set<string>> = new Map();
|
||||
type: IndexStructType = IndexStructType.KEYWORD_TABLE;
|
||||
|
||||
addNode(keywords: string[], nodeId: string): void {
|
||||
keywords.forEach((keyword) => {
|
||||
if (!this.table.has(keyword)) {
|
||||
this.table.set(keyword, new Set());
|
||||
}
|
||||
this.table.get(keyword)!.add(nodeId);
|
||||
});
|
||||
}
|
||||
|
||||
deleteNode(keywords: string[], nodeId: string) {
|
||||
keywords.forEach((keyword) => {
|
||||
if (this.table.has(keyword)) {
|
||||
this.table.get(keyword)!.delete(nodeId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
toJson(): Record<string, unknown> {
|
||||
return {
|
||||
...super.toJson(),
|
||||
table: Array.from(this.table.entries()).reduce(
|
||||
(acc, [keyword, nodeIds]) => {
|
||||
acc[keyword] = Array.from(nodeIds);
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, string[]>,
|
||||
),
|
||||
type: this.type,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export { IndexStruct, KeywordTable } from "./data-structs";
|
||||
export { IndexStructType } from "./struct-type";
|
||||
@@ -0,0 +1,39 @@
|
||||
export const IndexStructType = {
|
||||
NODE: "node",
|
||||
TREE: "tree",
|
||||
LIST: "list",
|
||||
KEYWORD_TABLE: "keyword_table",
|
||||
DICT: "dict",
|
||||
SIMPLE_DICT: "simple_dict",
|
||||
WEAVIATE: "weaviate",
|
||||
PINECONE: "pinecone",
|
||||
QDRANT: "qdrant",
|
||||
LANCEDB: "lancedb",
|
||||
MILVUS: "milvus",
|
||||
CHROMA: "chroma",
|
||||
MYSCALE: "myscale",
|
||||
CLICKHOUSE: "clickhouse",
|
||||
VECTOR_STORE: "vector_store",
|
||||
OPENSEARCH: "opensearch",
|
||||
DASHVECTOR: "dashvector",
|
||||
CHATGPT_RETRIEVAL_PLUGIN: "chatgpt_retrieval_plugin",
|
||||
DEEPLAKE: "deeplake",
|
||||
EPSILLA: "epsilla",
|
||||
MULTIMODAL_VECTOR_STORE: "multimodal",
|
||||
SQL: "sql",
|
||||
KG: "kg",
|
||||
SIMPLE_KG: "simple_kg",
|
||||
SIMPLE_LPG: "simple_lpg",
|
||||
NEBULAGRAPH: "nebulagraph",
|
||||
FALKORDB: "falkordb",
|
||||
EMPTY: "empty",
|
||||
COMPOSITE: "composite",
|
||||
PANDAS: "pandas",
|
||||
DOCUMENT_SUMMARY: "document_summary",
|
||||
VECTARA: "vectara",
|
||||
ZILLIZ_CLOUD_PIPELINE: "zilliz_cloud_pipeline",
|
||||
POSTGRESML: "postgresml",
|
||||
} as const;
|
||||
|
||||
export type IndexStructType =
|
||||
(typeof IndexStructType)[keyof typeof IndexStructType];
|
||||
@@ -2,4 +2,10 @@ export { BaseEmbedding, batchEmbeddings } from "./base";
|
||||
export type { BaseEmbeddingOptions, EmbeddingInfo } from "./base";
|
||||
export { MultiModalEmbedding } from "./muti-model";
|
||||
export { truncateMaxTokens } from "./tokenizer";
|
||||
export { DEFAULT_SIMILARITY_TOP_K, SimilarityType, similarity } from "./utils";
|
||||
export {
|
||||
DEFAULT_SIMILARITY_TOP_K,
|
||||
SimilarityType,
|
||||
getTopKEmbeddings,
|
||||
getTopKMMREmbeddings,
|
||||
similarity,
|
||||
} from "./utils";
|
||||
|
||||
@@ -62,3 +62,121 @@ export function similarity(
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top K embeddings from a list of embeddings ordered by similarity to the query.
|
||||
* @param queryEmbedding
|
||||
* @param embeddings list of embeddings to consider
|
||||
* @param similarityTopK max number of embeddings to return, default 2
|
||||
* @param embeddingIds ids of embeddings in the embeddings list
|
||||
* @param similarityCutoff minimum similarity score
|
||||
* @returns
|
||||
*/
|
||||
// eslint-disable-next-line max-params
|
||||
export function getTopKEmbeddings(
|
||||
queryEmbedding: number[],
|
||||
embeddings: number[][],
|
||||
similarityTopK: number = 2,
|
||||
embeddingIds: any[] | null = null,
|
||||
similarityCutoff: number | null = null,
|
||||
): [number[], any[]] {
|
||||
if (embeddingIds == null) {
|
||||
embeddingIds = Array(embeddings.length).map((_, i) => i);
|
||||
}
|
||||
|
||||
if (embeddingIds.length !== embeddings.length) {
|
||||
throw new Error(
|
||||
"getTopKEmbeddings: embeddings and embeddingIds length mismatch",
|
||||
);
|
||||
}
|
||||
|
||||
const similarities: { similarity: number; id: number }[] = [];
|
||||
|
||||
for (let i = 0; i < embeddings.length; i++) {
|
||||
const sim = similarity(queryEmbedding, embeddings[i]!);
|
||||
if (similarityCutoff == null || sim > similarityCutoff) {
|
||||
similarities.push({ similarity: sim, id: embeddingIds[i] });
|
||||
}
|
||||
}
|
||||
|
||||
similarities.sort((a, b) => b.similarity - a.similarity); // Reverse sort
|
||||
|
||||
const resultSimilarities: number[] = [];
|
||||
const resultIds: any[] = [];
|
||||
|
||||
for (let i = 0; i < similarityTopK; i++) {
|
||||
if (i >= similarities.length) {
|
||||
break;
|
||||
}
|
||||
resultSimilarities.push(similarities[i]!.similarity);
|
||||
resultIds.push(similarities[i]!.id);
|
||||
}
|
||||
|
||||
return [resultSimilarities, resultIds];
|
||||
}
|
||||
|
||||
// eslint-disable-next-line max-params
|
||||
export function getTopKMMREmbeddings(
|
||||
queryEmbedding: number[],
|
||||
embeddings: number[][],
|
||||
similarityFn: ((...args: any[]) => number) | null = null,
|
||||
similarityTopK: number | null = null,
|
||||
embeddingIds: any[] | null = null,
|
||||
_similarityCutoff: number | null = null,
|
||||
mmrThreshold: number | null = null,
|
||||
): [number[], any[]] {
|
||||
const threshold = mmrThreshold || 0.5;
|
||||
similarityFn = similarityFn || similarity;
|
||||
|
||||
if (embeddingIds === null || embeddingIds.length === 0) {
|
||||
embeddingIds = Array.from({ length: embeddings.length }, (_, i) => i);
|
||||
}
|
||||
const fullEmbedMap = new Map(embeddingIds.map((value, i) => [value, i]));
|
||||
const embedMap = new Map(fullEmbedMap);
|
||||
const embedSimilarity: Map<any, number> = new Map();
|
||||
let score: number = Number.NEGATIVE_INFINITY;
|
||||
let highScoreId: any | null = null;
|
||||
|
||||
for (let i = 0; i < embeddings.length; i++) {
|
||||
const emb = embeddings[i];
|
||||
const similarity = similarityFn(queryEmbedding, emb);
|
||||
embedSimilarity.set(embeddingIds[i], similarity);
|
||||
if (similarity * threshold > score) {
|
||||
highScoreId = embeddingIds[i];
|
||||
score = similarity * threshold;
|
||||
}
|
||||
}
|
||||
|
||||
const results: [number, any][] = [];
|
||||
|
||||
const embeddingLength = embeddings.length;
|
||||
const similarityTopKCount = similarityTopK || embeddingLength;
|
||||
|
||||
while (results.length < Math.min(similarityTopKCount, embeddingLength)) {
|
||||
results.push([score, highScoreId]);
|
||||
embedMap.delete(highScoreId);
|
||||
const recentEmbeddingId = highScoreId;
|
||||
score = Number.NEGATIVE_INFINITY;
|
||||
for (const embedId of Array.from(embedMap.keys())) {
|
||||
const overlapWithRecent = similarityFn(
|
||||
embeddings[embedMap.get(embedId)!],
|
||||
embeddings[fullEmbedMap.get(recentEmbeddingId)!],
|
||||
);
|
||||
if (
|
||||
threshold * embedSimilarity.get(embedId)! -
|
||||
(1 - threshold) * overlapWithRecent >
|
||||
score
|
||||
) {
|
||||
score =
|
||||
threshold * embedSimilarity.get(embedId)! -
|
||||
(1 - threshold) * overlapWithRecent;
|
||||
highScoreId = embedId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const resultSimilarities = results.map(([s, _]) => s);
|
||||
const resultIds = results.map(([_, n]) => n);
|
||||
|
||||
return [resultSimilarities, resultIds];
|
||||
}
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
import { type Tokenizer, tokenizers } from "@llamaindex/env";
|
||||
import {
|
||||
DEFAULT_CHUNK_OVERLAP_RATIO,
|
||||
DEFAULT_CHUNK_SIZE,
|
||||
DEFAULT_CONTEXT_WINDOW,
|
||||
DEFAULT_NUM_OUTPUTS,
|
||||
DEFAULT_PADDING,
|
||||
Settings,
|
||||
} from "../global";
|
||||
import type { LLMMetadata } from "../llms";
|
||||
import { SentenceSplitter } from "../node-parser";
|
||||
import type { PromptTemplate } from "../prompts";
|
||||
import { TextSplitter, TokenTextSplitter, truncateText } from "../node-parser";
|
||||
import { BasePromptTemplate, PromptTemplate } from "../prompts";
|
||||
|
||||
/**
|
||||
* Get the empty prompt text given a prompt.
|
||||
*/
|
||||
function getEmptyPromptTxt(prompt: PromptTemplate) {
|
||||
return prompt.format({
|
||||
...Object.fromEntries(
|
||||
[...prompt.templateVars.keys()].map((key) => [key, ""]),
|
||||
),
|
||||
});
|
||||
function getEmptyPromptTxt(prompt: PromptTemplate): string {
|
||||
return prompt.format(
|
||||
Object.fromEntries([...prompt.templateVars.keys()].map((key) => [key, ""])),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,24 +32,24 @@ export function getBiggestPrompt(prompts: PromptTemplate[]): PromptTemplate {
|
||||
}
|
||||
|
||||
export type PromptHelperOptions = {
|
||||
contextWindow?: number;
|
||||
numOutput?: number;
|
||||
chunkOverlapRatio?: number;
|
||||
chunkSizeLimit?: number;
|
||||
tokenizer?: Tokenizer;
|
||||
separator?: string;
|
||||
contextWindow?: number | undefined;
|
||||
numOutput?: number | undefined;
|
||||
chunkOverlapRatio?: number | undefined;
|
||||
chunkSizeLimit?: number | undefined;
|
||||
tokenizer?: Tokenizer | undefined;
|
||||
separator?: string | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* A collection of helper functions for working with prompts.
|
||||
*/
|
||||
export class PromptHelper {
|
||||
contextWindow = DEFAULT_CONTEXT_WINDOW;
|
||||
numOutput = DEFAULT_NUM_OUTPUTS;
|
||||
chunkOverlapRatio = DEFAULT_CHUNK_OVERLAP_RATIO;
|
||||
contextWindow: number;
|
||||
numOutput: number;
|
||||
chunkOverlapRatio: number;
|
||||
chunkSizeLimit: number | undefined;
|
||||
tokenizer: Tokenizer;
|
||||
separator = " ";
|
||||
separator: string;
|
||||
|
||||
constructor(options: PromptHelperOptions = {}) {
|
||||
const {
|
||||
@@ -72,68 +69,93 @@ export class PromptHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a prompt, return the maximum size of the inputs to the prompt.
|
||||
* @param prompt
|
||||
* @returns
|
||||
* Calculate the available context size based on the number of prompt tokens.
|
||||
*/
|
||||
private getAvailableContextSize(prompt: PromptTemplate) {
|
||||
const emptyPromptText = getEmptyPromptTxt(prompt);
|
||||
const promptTokens = this.tokenizer.encode(emptyPromptText);
|
||||
const numPromptTokens = promptTokens.length;
|
||||
|
||||
return this.contextWindow - numPromptTokens - this.numOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the maximum size of each chunk given a prompt.
|
||||
*/
|
||||
private getAvailableChunkSize(
|
||||
prompt: PromptTemplate,
|
||||
numChunks = 1,
|
||||
padding = 5,
|
||||
): number {
|
||||
const availableContextSize = this.getAvailableContextSize(prompt);
|
||||
|
||||
const result = Math.floor(availableContextSize / numChunks) - padding;
|
||||
|
||||
if (this.chunkSizeLimit) {
|
||||
return Math.min(this.chunkSizeLimit, result);
|
||||
} else {
|
||||
return result;
|
||||
#getAvailableContextSize(numPromptTokens: number): number {
|
||||
const contextSizeTokens =
|
||||
this.contextWindow - numPromptTokens - this.numOutput;
|
||||
if (contextSizeTokens < 0) {
|
||||
throw new Error(
|
||||
`Calculated available context size ${contextSizeTokens} is not non-negative.`,
|
||||
);
|
||||
}
|
||||
return contextSizeTokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a text splitter with the correct chunk sizes and overlaps given a prompt.
|
||||
* Calculate the available chunk size based on the prompt and other parameters.
|
||||
*/
|
||||
#getAvailableChunkSize<Template extends BasePromptTemplate>(
|
||||
prompt: Template,
|
||||
numChunks: number = 1,
|
||||
padding: number = 5,
|
||||
): number {
|
||||
let numPromptTokens = 0;
|
||||
|
||||
if (prompt instanceof PromptTemplate) {
|
||||
numPromptTokens = this.tokenizer.encode(getEmptyPromptTxt(prompt)).length;
|
||||
}
|
||||
|
||||
const availableContextSize = this.#getAvailableContextSize(numPromptTokens);
|
||||
let result = Math.floor(availableContextSize / numChunks) - padding;
|
||||
|
||||
if (this.chunkSizeLimit !== undefined) {
|
||||
result = Math.min(this.chunkSizeLimit, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a text splitter configured to maximally pack the available context window.
|
||||
*/
|
||||
getTextSplitterGivenPrompt(
|
||||
prompt: PromptTemplate,
|
||||
numChunks = 1,
|
||||
padding = DEFAULT_PADDING,
|
||||
) {
|
||||
const chunkSize = this.getAvailableChunkSize(prompt, numChunks, padding);
|
||||
if (chunkSize === 0) {
|
||||
throw new Error("Got 0 as available chunk size");
|
||||
prompt: BasePromptTemplate,
|
||||
numChunks: number = 1,
|
||||
padding: number = DEFAULT_PADDING,
|
||||
): TextSplitter {
|
||||
const chunkSize = this.#getAvailableChunkSize(prompt, numChunks, padding);
|
||||
if (chunkSize <= 0) {
|
||||
throw new TypeError(`Chunk size ${chunkSize} is not positive.`);
|
||||
}
|
||||
const chunkOverlap = this.chunkOverlapRatio * chunkSize;
|
||||
return new SentenceSplitter({
|
||||
const chunkOverlap = Math.floor(this.chunkOverlapRatio * chunkSize);
|
||||
return new TokenTextSplitter({
|
||||
separator: this.separator,
|
||||
chunkSize,
|
||||
chunkOverlap,
|
||||
separator: this.separator,
|
||||
tokenizer: this.tokenizer,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Repack resplits the strings based on the optimal text splitter.
|
||||
* Truncate text chunks to fit within the available context window.
|
||||
*/
|
||||
truncate(
|
||||
prompt: BasePromptTemplate,
|
||||
textChunks: string[],
|
||||
padding: number = DEFAULT_PADDING,
|
||||
): string[] {
|
||||
const textSplitter = this.getTextSplitterGivenPrompt(
|
||||
prompt,
|
||||
textChunks.length,
|
||||
padding,
|
||||
);
|
||||
return textChunks.map((chunk) => truncateText(chunk, textSplitter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Repack text chunks to better utilize the available context window.
|
||||
*/
|
||||
repack(
|
||||
prompt: PromptTemplate,
|
||||
prompt: BasePromptTemplate,
|
||||
textChunks: string[],
|
||||
padding = DEFAULT_PADDING,
|
||||
) {
|
||||
padding: number = DEFAULT_PADDING,
|
||||
): string[] {
|
||||
const textSplitter = this.getTextSplitterGivenPrompt(prompt, 1, padding);
|
||||
const combinedStr = textChunks.join("\n\n");
|
||||
const combinedStr = textChunks
|
||||
.map((c) => c.trim())
|
||||
.filter((c) => c.length > 0)
|
||||
.join("\n\n");
|
||||
return textSplitter.splitText(combinedStr);
|
||||
}
|
||||
|
||||
@@ -148,13 +170,14 @@ export class PromptHelper {
|
||||
) {
|
||||
const {
|
||||
chunkOverlapRatio = DEFAULT_CHUNK_OVERLAP_RATIO,
|
||||
chunkSizeLimit = DEFAULT_CHUNK_SIZE,
|
||||
chunkSizeLimit = undefined,
|
||||
tokenizer = Settings.tokenizer,
|
||||
separator = " ",
|
||||
} = options ?? {};
|
||||
return new PromptHelper({
|
||||
contextWindow: metadata.contextWindow,
|
||||
numOutput: metadata.maxTokens ?? DEFAULT_NUM_OUTPUTS,
|
||||
// fixme: numOutput is not in LLMMetadata
|
||||
numOutput: DEFAULT_NUM_OUTPUTS,
|
||||
chunkOverlapRatio,
|
||||
chunkSizeLimit,
|
||||
tokenizer,
|
||||
|
||||
@@ -13,6 +13,7 @@ export { MetadataAwareTextSplitter, NodeParser, TextSplitter } from "./base";
|
||||
export { MarkdownNodeParser } from "./markdown";
|
||||
export { SentenceSplitter } from "./sentence-splitter";
|
||||
export { SentenceWindowNodeParser } from "./sentence-window";
|
||||
export { TokenTextSplitter } from "./token-text-splitter";
|
||||
export type { SplitterParams } from "./type";
|
||||
export {
|
||||
splitByChar,
|
||||
@@ -20,5 +21,6 @@ export {
|
||||
splitByRegex,
|
||||
splitBySentenceTokenizer,
|
||||
splitBySep,
|
||||
truncateText,
|
||||
} from "./utils";
|
||||
export type { TextSplitterFn } from "./utils";
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
import type { Tokenizer } from "@llamaindex/env";
|
||||
import { z } from "zod";
|
||||
import { DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, Settings } from "../global";
|
||||
import { MetadataAwareTextSplitter } from "./base";
|
||||
import type { SplitterParams } from "./type";
|
||||
import { splitByChar, splitBySep } from "./utils";
|
||||
|
||||
const DEFAULT_METADATA_FORMAT_LEN = 2;
|
||||
|
||||
const tokenTextSplitterSchema = z.object({
|
||||
chunkSize: z.number().positive().default(DEFAULT_CHUNK_SIZE),
|
||||
chunkOverlap: z.number().nonnegative().default(DEFAULT_CHUNK_OVERLAP),
|
||||
separator: z.string().default(" "),
|
||||
backupSeparators: z.array(z.string()).default(["\n"]),
|
||||
});
|
||||
|
||||
export class TokenTextSplitter extends MetadataAwareTextSplitter {
|
||||
chunkSize: number = DEFAULT_CHUNK_SIZE;
|
||||
chunkOverlap: number = DEFAULT_CHUNK_OVERLAP;
|
||||
separator: string = " ";
|
||||
backupSeparators: string[] = ["\n"];
|
||||
#tokenizer: Tokenizer;
|
||||
#splitFns: Array<(text: string) => string[]> = [];
|
||||
|
||||
constructor(
|
||||
params?: SplitterParams & Partial<z.infer<typeof tokenTextSplitterSchema>>,
|
||||
) {
|
||||
super();
|
||||
|
||||
if (params) {
|
||||
const parsedParams = tokenTextSplitterSchema.parse(params);
|
||||
this.chunkSize = parsedParams.chunkSize;
|
||||
this.chunkOverlap = parsedParams.chunkOverlap;
|
||||
this.separator = parsedParams.separator;
|
||||
this.backupSeparators = parsedParams.backupSeparators;
|
||||
}
|
||||
|
||||
if (this.chunkOverlap > this.chunkSize) {
|
||||
throw new Error(
|
||||
`Got a larger chunk overlap (${this.chunkOverlap}) than chunk size (${this.chunkSize}), should be smaller.`,
|
||||
);
|
||||
}
|
||||
|
||||
this.#tokenizer = params?.tokenizer ?? Settings.tokenizer;
|
||||
|
||||
const allSeparators = [this.separator, ...this.backupSeparators];
|
||||
this.#splitFns = allSeparators.map((sep) => splitBySep(sep));
|
||||
this.#splitFns.push(splitByChar());
|
||||
}
|
||||
|
||||
/**
|
||||
* Split text into chunks, reserving space required for metadata string.
|
||||
* @param text The text to split.
|
||||
* @param metadata The metadata string.
|
||||
* @returns An array of text chunks.
|
||||
*/
|
||||
splitTextMetadataAware(text: string, metadata: string): string[] {
|
||||
const metadataLength =
|
||||
this.tokenSize(metadata) + DEFAULT_METADATA_FORMAT_LEN;
|
||||
const effectiveChunkSize = this.chunkSize - metadataLength;
|
||||
|
||||
if (effectiveChunkSize <= 0) {
|
||||
throw new Error(
|
||||
`Metadata length (${metadataLength}) is longer than chunk size (${this.chunkSize}). ` +
|
||||
`Consider increasing the chunk size or decreasing the size of your metadata to avoid this.`,
|
||||
);
|
||||
} else if (effectiveChunkSize < 50) {
|
||||
console.warn(
|
||||
`Metadata length (${metadataLength}) is close to chunk size (${this.chunkSize}). ` +
|
||||
`Resulting chunks are less than 50 tokens. Consider increasing the chunk size or decreasing the size of your metadata to avoid this.`,
|
||||
);
|
||||
}
|
||||
|
||||
return this._splitText(text, effectiveChunkSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Split text into chunks.
|
||||
* @param text The text to split.
|
||||
* @returns An array of text chunks.
|
||||
*/
|
||||
splitText(text: string): string[] {
|
||||
return this._splitText(text, this.chunkSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to split text into chunks up to a specified size.
|
||||
* @param text The text to split.
|
||||
* @param chunkSize The maximum size of each chunk.
|
||||
* @returns An array of text chunks.
|
||||
*/
|
||||
private _splitText(text: string, chunkSize: number): string[] {
|
||||
if (text === "") return [text];
|
||||
|
||||
// Dispatch chunking start event
|
||||
Settings.callbackManager.dispatchEvent("chunking-start", { text: [text] });
|
||||
|
||||
const splits = this._split(text, chunkSize);
|
||||
const chunks = this._merge(splits, chunkSize);
|
||||
|
||||
Settings.callbackManager.dispatchEvent("chunking-end", { chunks });
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Break text into splits that are smaller than the chunk size.
|
||||
* @param text The text to split.
|
||||
* @param chunkSize The maximum size of each split.
|
||||
* @returns An array of text splits.
|
||||
*/
|
||||
private _split(text: string, chunkSize: number): string[] {
|
||||
if (this.tokenSize(text) <= chunkSize) {
|
||||
return [text];
|
||||
}
|
||||
|
||||
for (const splitFn of this.#splitFns) {
|
||||
const splits = splitFn(text);
|
||||
if (splits.length > 1) {
|
||||
const newSplits: string[] = [];
|
||||
for (const split of splits) {
|
||||
const splitLen = this.tokenSize(split);
|
||||
if (splitLen <= chunkSize) {
|
||||
newSplits.push(split);
|
||||
} else {
|
||||
newSplits.push(...this._split(split, chunkSize));
|
||||
}
|
||||
}
|
||||
return newSplits;
|
||||
}
|
||||
}
|
||||
|
||||
return [text];
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge splits into chunks with overlap.
|
||||
* @param splits The array of text splits.
|
||||
* @param chunkSize The maximum size of each chunk.
|
||||
* @returns An array of merged text chunks.
|
||||
*/
|
||||
private _merge(splits: string[], chunkSize: number): string[] {
|
||||
const chunks: string[] = [];
|
||||
let currentChunk: string[] = [];
|
||||
let currentLength = 0;
|
||||
|
||||
for (const split of splits) {
|
||||
const splitLength = this.tokenSize(split);
|
||||
|
||||
if (splitLength > chunkSize) {
|
||||
console.warn(
|
||||
`Got a split of size ${splitLength}, larger than chunk size ${chunkSize}.`,
|
||||
);
|
||||
}
|
||||
|
||||
if (currentLength + splitLength > chunkSize) {
|
||||
const chunk = currentChunk.join("").trim();
|
||||
if (chunk) {
|
||||
chunks.push(chunk);
|
||||
}
|
||||
|
||||
currentChunk = [];
|
||||
currentLength = 0;
|
||||
|
||||
const overlapTokens = this.chunkOverlap;
|
||||
const overlapSplits: string[] = [];
|
||||
|
||||
let overlapLength = 0;
|
||||
while (
|
||||
overlapSplits.length < splits.length &&
|
||||
overlapLength < overlapTokens
|
||||
) {
|
||||
const overlapSplit = currentChunk.shift();
|
||||
if (!overlapSplit) break;
|
||||
overlapSplits.push(overlapSplit);
|
||||
overlapLength += this.tokenSize(overlapSplit);
|
||||
}
|
||||
|
||||
for (const overlapSplit of overlapSplits.reverse()) {
|
||||
currentChunk.push(overlapSplit);
|
||||
currentLength += this.tokenSize(overlapSplit);
|
||||
if (currentLength >= overlapTokens) break;
|
||||
}
|
||||
}
|
||||
|
||||
currentChunk.push(split);
|
||||
currentLength += splitLength;
|
||||
}
|
||||
|
||||
const finalChunk = currentChunk.join("").trim();
|
||||
if (finalChunk) {
|
||||
chunks.push(finalChunk);
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the number of tokens in the text using the tokenizer.
|
||||
* @param text The text to tokenize.
|
||||
* @returns The number of tokens.
|
||||
*/
|
||||
private tokenSize(text: string): number {
|
||||
return this.#tokenizer.encode(text).length;
|
||||
}
|
||||
}
|
||||